0

jfreechart datapoint hover over tooltip imagemap

asked 2010-06-01 22:59:45 +0800

kazimbeg gravatar image kazimbeg
45 4

Hi,
I am using jfreechart using imagemap in the zul file. Everything is done now the only problem I have is to get a tooltip when I move the mouse on a datapoint. I am using imagemap and its a simple XY line chart.
Here is my code:
Zul code:
<imagemap id="myimage">
</imagemap>
Javacode:
........
JFreeChart chart = trackerGraph.createChart(chartData, addEditTrackerVO.isTimeFieldVisible());
XYLineAndShapeRenderer r = new XYLineAndShapeRenderer();
r.setToolTipGenerator(new StandardXYToolTipGenerator());
chart.getXYPlot().setRenderer(r);
trackerGraph.createGraph(myimage, chart);
..........

public void createGraph(Imagemap myimage, JFreeChart chart){
try {
ChartRenderingInfo info = new ChartRenderingInfo();
BufferedImage bi = chart.createBufferedImage(600, 400, BufferedImage.TRANSLUCENT, info);

//BufferedImage bi = chart.createBufferedImage(500, 300, BufferedImage.TRANSLUCENT , null);
byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

AImage image = new AImage("Line Chart", bytes);
myimage.setContent(image);
}catch (Exception ex){
LOG.info("Exception!! while creating jfreeChart. The exception is: "+ex.getMessage());
}

}

public JFreeChart createChart(ChartData chartData , boolean isTimeFieldVisible) {
XYDataset dataset = createDataset(chartData, isTimeFieldVisible);
Plot plot = createPlot(chartData, dataset, isTimeFieldVisible);

return new JFreeChart(chartData.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, createLegend(chartData));
}

public void writeChart(OutputStream out, JFreeChart chart, ChartData chartData) throws Exception {
ChartUtilities.writeChartAsPNG(out, chart, chartData.getWidth(), chartData.getHeight());
}

What am I missing? How can I get a tooltip when I move my mouse over a datapoint on the graph?

I will really appreciate if you could provide some help.

Regards,

Kazim

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2010-06-03 23:03:01 +0800

PeterKuo gravatar image PeterKuo
481 2

Please refer to
http://docs.zkoss.org/wiki/Integrating_JFreeChart_to_ZK_Framework%2C_Part_II

It has excellent example.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-06-01 22:59:45 +0800

Seen: 1,695 times

Last updated: Jun 03 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More