1

I've been looking through examples online about charting libraries to work with in a Java Web Application but they all keep trying to implement some form of php to get the data before the chart is produced.

Ideally I would like to use google charts and then take data from my database through jsp/ servlet of some sort but I can't find any examples online without php.

I've tried Jfreechart but again can't find much documentation.

question I'm trying to ask is, How would I be able to draw charts that get data from MySQL and display them on my web page. All this is in Netbeans currently.

Thanks in advance,

Intrigued
  • 27
  • 1
  • 5

1 Answers1

2

Rather than using jsp/servlets, have you considered using Java Server Faces? You can find an explanation of the differences here.

If you were to use Java Server Faces, you would then be able to use PrimeFaces Charts to create something like this:

PrimeFaces Chart

You can see a full set of examples at the PrimeFaces website, and there is a tutorial on creating Generating a JavaServer Faces 2 Application here that covers creating an appplication lined to a MySQL database.

Using this method, you would place the chart data inside a bean and then reference it (the bean) from your webpage.

If you want to use JFreeChart, you can use ChartUtilities#saveChartAsXXXX to save an image of the chart on the server and then include a link to the the generated image inside your webpage.

Community
  • 1
  • 1
GrahamA
  • 5,875
  • 29
  • 39