• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating Primefaces 4.0 charts from database objects

 
Jay Tai
Ranch Hand
Posts: 221
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to create a simple bar chart from integer values (measuring number of bulldozers) stored in a mySql DB, in the following schema:


I want to plot the date on the x-axis and quantity on y-axis.

I can't seem to find any examples of how to render charts from a database. I just find the generic Primefaces 4.0 examples which uses static data like this:



I'm really not sure how to adapt the above to a database method nor have any web searches produced useful examples. I tried something like this, but would really appreciate any advice of how to find examples or the type of methods I need to use to create a bar graph from Db values:



 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about what the ChartSeries is? It's a map with the key as the x-axis and value the y-axis.

sql = select recordDate, rigQty from bulldozer;
chartSeries.set(bulldozer.getRecordDate(), bulldozer.getRigQty());

I will let you figure out the rest.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!