Sign in to follow this  
posthume

Are Dynamic Charts Possible?

Recommended Posts

Hi everyone,

 

I am new to this forum and I hope you can help me in that issue.

 

I am developing a web application with JSP/Tomcat and I have already created a complex project in java that allows to do statistic calculs on data taken from a text file and I have shown those results in multiple tables using displaytag library in a JSP file.

 

Now i would like to show the same results but in bar charts and I found FusionCharts which corresponds exactly to what I want. But I have a question as I couldn't really find the answer on the net. Is it possible to use dynamic data on those charts, like for example data taken from a HashMap that I coded in java?

 

The data I need to represent on a bar chart are in that loop :

  
for (String string : mapV.keySet()) {

                     // Name of the gene
                      String gene = string; // That's one of the data I need to represent on the top of each bar.

                 //Non-redundant sequences
                 int nbSeqNonRedG = 0;

                 //Redundant sequences
                 int nbSeqRedG = 0;

                 //Distinct sequences
                 int nbSeqDistinctG = 0;

                 //Parcours du tableau des gènes 
                 for (String string2 : table1.keySet()) { 
                    if (string.equals(string2)) {
                       Enumeration lesSeq2 = (table1.get(string2)).keys();
                       for (Entry<String, Integer> entryG : (table1.get(string2)).entrySet()) { 

                            String seq2 = (String)lesSeq2.nextElement();

                            int nbOcc2 = ((Integer)(table1.get(string2)).get(seq2)).intValue();   

                            if (nbOcc2 == 1) { nbSeqNonRedG = nbSeqNonRedG + 1;
                                             }

                            else { nbSeqRedG = nbSeqRedG + 1;

                       }

                             nbSeqDistinctG = nbSeqNonRedG + nbSeqRedG;  // that's one of the data I need to represent on the bar chart on the y  axis

                          try {
                          Class.forName(driverName);

                       } catch (ClassNotFoundException e1) {
                          System.out.println(e1.getMessage());
                       }   

                        Connection con = null;
                       try{
                           con = DriverManager.getConnection(url, username, pass);
                        }catch(SQLException e){
                              System.out.println(e.getMessage());
                        }

                           Statement st = null;
                        ResultSet rs = null;

                        try {
                          st = con.createStatement();
                           st.executeQuery("select name1, deb, fin from  genomicpositions g where (g.name1 like '%" + string +  "%') ");
                          rs = st.getResultSet();


                       } catch (SQLException e) {
                          System.out.println(e.getMessage());
                       }

                       try {
                          while (rs.next()) {

                                          int start = rs.getInt(2) //  That's the last data I need to represent on the bar chart on the x-axis


                            }


                       } catch (SQLException e) {
                          e.printStackTrace();
                       }


                       try {
                          rs.close();
                          st.close();
                          con.close();
                       } catch (SQLException e) {
                          e.printStackTrace();
                       }
                    }

                 }


                 }


             }


 

I need to represent a bar chart with (cf. the comments on my code):

-on the y axis: the number of distinct sequences for a gene --> int nbSeqDistinctG

-on the x-axis: the position of the gene in the locus (taken from a database) --> int start

-on the top of each bar, the name of the corresponding gene --> String gene

 

Is it possible to do this with that library? If so, can you give me some directions on how to get to start please or maybe just an example of how to do it?

 

Any help would be very appreciated.

 

Ps: sorry for my english, i am french.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this