spoclate

Help creating Stacked Bar chart with JSP, Java and DB data

6 posts in this topic

Hi,

 

New to the forum. Loving Fusion charts. I am having some issues creating a stacked bar chart. I can create a normal bar chart and also the drill down version. Each row of my DB table has several columns. It is these columns I would like stacked. I cannot find any examples

 

An example is:

 

analyst attention delta theta lowAlpha highAlpha lowBeta highBeta lowGamma highGamma time Analyst 72 246836 119537 797902 677390 861178 944870 937669 636754 1.49E+12 Analyst 54 706781 641939 286041 605622 392724 433530 97563 253251 1.49E+12 Analyst 63 607845 131630 43136 709612 999633 110155 427353 918349 1.49E+12 Analyst 85 763426 249246 450154 726588 989483 740372 387877 440868 1.49E+12

 

Any help is appreciated.

 

Thanks

 

Share this post


Link to post
Share on other sites

 

Hi,
 
For implementing stacked bar chart in JSP using mysql database, please check this demo (also attached the sql file) example from the given dropbox link - https://www.dropbox.com/s/igei6jr3mto0amu/stacked-bar-db.zip?dl=0

 

Hi,

 

Thank you for your reply and sample code. I have implemented the JSP code and changed some areas to suit my DB and chart. I have hit an error on fusioncharts.js constructor.drawLabel as shown below

 

Uncaught TypeError: Cannot read property 'length' of undefined
    at constructor.drawLabel (fusioncharts.js:1508)
    at Q (fusioncharts.js:329)
 
I have only changed the areas shown in source below.
 // Form the SQL query that returns the top 10 most populous countries
            String sql="SELECT * from analystdata FETCH FIRST 50 ROWS ONLY";


 ArrayList categories = new ArrayList();
            categories.add(buildCategories("analystname", result,gson));
            
            //prepare dataset
            ArrayList dataset = new ArrayList();
            dataset.add(buildDataset("Beta Wave","highbeta", result, gson));
            dataset.add(buildDataset("Alpha Wave", "highalpha", result, gson));
            dataset.add(buildDataset("Theta Wave", "theta", result, gson));
            dataset.add(buildDataset("Gamma Wave", "highgamma", result, gson));
            

This is the extent of the changes I made. Have you had an experience with this issue?

 

Thanks in advance

Share this post


Link to post
Share on other sites

Hi,

Thanks for replying back.

Please check whether you are retrieving the data correctly or not. It seems like the category object is not generating properly.

Please provide us your sql files so that we can investigate at our end.

Share this post


Link to post
Share on other sites
 

Hi,

Thanks for replying back.

Please check whether you are retrieving the data correctly or not. It seems like the category object is not generating properly.

Please provide us your sql files so that we can investigate at our end.

Hi,

My DB is in postgresql. The create script is attached. ID is incremental the others have large values in them. Analyst name is varchar and timestamp is set everytime a row is added. I am struggling to find various ways of representing the data over time. Thanks for your help.

create.sql

Share this post


Link to post
Share on other sites

Hi, 

Thanks for replying back.

Please check the following 

1- Whether the database connectivity is properly made, and check whether you are able to fetch the required data using the sql query which you are using

2- Please check the whether you are able to restructure your data in fusioncharts datasource format in order to render it in the browser.

Please share your observations. 

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