Web Application ChartsTooltips

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
kamal
Posts: 3
Joined: Mon Mar 24, 2008 8:36 pm

Web Application ChartsTooltips

Post by kamal » Mon Mar 24, 2008 8:41 pm

How do I display tooltips on a chart generated via servlet on a web page.

BubbleChart bubbleChart = new BubbleChart();
JFreeChart chart = bubbleChart.createChart(new SampleXYZDataset());
ChartUtilities.writeChartAsPNG(out, chart, 400, 300);

I searched the forum but can't find details, also i have the developer guide but no details.

Thanks,
Kamal

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Mar 25, 2008 4:07 am

For tooltips on a web page, you need to create an HTML image map to go along with the PNG image. The ImageMapUtilities class can help you with that.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

kamal
Posts: 3
Joined: Mon Mar 24, 2008 8:36 pm

Post by kamal » Tue Mar 25, 2008 3:12 pm

Thanks you for the reply David, it would be nice if you can include a sample code in the developer guide. Can you please post a code snip it or send me a simple example showing how to add tooltips to a web application.

deepujain
Posts: 21
Joined: Sat Jun 02, 2007 10:52 am
Location: Bangalore

Post by deepujain » Tue Mar 25, 2008 5:34 pm

Since you are using jfreechart with Webapp then your graph would be dumped into one of your image tags say like this
<img src="graph.jsp"/>
Graph.jsp will dump the graph as PNG.
Here is what you need to do
Read this tut http://www.w3schools.com/tags/tag_map.asp
1)
String toolTipFormat="{0}: {2}" + units + ", {1}";
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
Look @ the API docs StandardXYToolTipGenerator and instantiate properly.
2) Write a method that will dump the image map as defined in the tut into your JSP that has your <img/> tag.

Hope this helps. IT worked for me, So if you have doubts let me know.
Thanks
Deepak
Zzzzz....

philanthrophic
Posts: 9
Joined: Wed Mar 26, 2008 6:20 am

CEWOLF

Post by philanthrophic » Wed Mar 26, 2008 6:23 am

Hi all,
Just wanted to confirm if there is a way to render JFreechart on web without using CEWOLF tag library.
If yes then you suggest some pointers on that

deepujain
Posts: 21
Joined: Sat Jun 02, 2007 10:52 am
Location: Bangalore

Post by deepujain » Wed Mar 26, 2008 7:41 am

To use JFreechart for web you will need to use only those graph types [with out controls that some graph types offer] that can be rendered as image.

JFreecHart ---> Image [Graph] ---> Use this as a image in your web app.
Hope this helps.
Zzzzz....

Locked