Tooltips in a GanttChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Sergio

Tooltips in a GanttChart

Post by Sergio » Wed Jan 22, 2003 11:20 pm

Hi, I'm trying to get tooltips for a gantt chart, but I've not been able to achieve it, this is my code:

FreeChart chart = ChartFactory.createGanttChart("Activities for " + fdm, "Activity", "Date", dataset, true);
CategoryPlot plot = chart.getCategoryPlot();
CategoryItemRenderer renderer = plot.getRenderer();
//renderer.setToolTipGenerator(new IntervalCategoryToolTipGenerator());
JFreeChart chart2 = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
ChartUtilities.writeChartAsJPEG(out, chart2, 1024, 768);

What kind of plot should I use? or what kind of renderer in order to create the tooltips?, thanks

Regards.

David Gilbert

Re: Tooltips in a GanttChart

Post by David Gilbert » Fri Jan 24, 2003 10:56 am

The IntervalCategoryToolTipGenerator should work. Tooltips are displayed by the ChartPanel class when you display a chart on screen. I notice that you are writing you chart to a JPEG file. If this is for display in a web browser, then you need to create an image map if you want to display tooltips.

Regards,

Dave Gilbert

Sergio

Re: Tooltips in a GanttChart

Post by Sergio » Fri Jan 24, 2003 9:17 pm

Hi David, thanks I got an area map for my picture, but something was wrong with the tooltips because didnt get displayed, although the Graph is displayed not in a good shape... and I try to fix this and now everytime I try to execute my servlet it prompts me a dialog window that says "Yo have chosen to download a file from this location" followed byt my servlet name and then all I can do is trying to download my image, what I'm doing wrong?, could you tell me? thanks a lot
This is the code how I create the image:
IntervalCategoryDataset dataset = createGanttDataset();

Plot plot = chart.getCategoryPlot();
plot.setSeriesPaint(myPaintArray);

chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(java.awt.Color.white);

CategoryAxis categoryAxis = new VerticalCategoryAxis("Activity");
DateAxis dateAxis = new HorizontalDateAxis("Date");
CategoryToolTipGenerator toolTipGenerator = new IntervalCategoryToolTipGenerator(sdf);

CategoryItemRenderer renderer = new HorizontalIntervalBarRenderer(toolTipGenerator);
Plot plot = new HorizontalCategoryPlot(dataset, categoryAxis, dateAxis,renderer);
JFreeChart chart = new JFreeChart("Activities for " + fdm,JFreeChart.DEFAULT_TITLE_FONT, plot, true);
//ChartUtilities.writeChartAsJPEG(out, chart, 850, 700);
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
String filename = ServletUtilities.saveChartAsPNG(chart, 850, 700, info, request.getSession());
ChartUtilities.writeImageMap(out, filename, info);
out.flush();
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
out.println("<div align=center> <img src=" + graphURL + " height=850 width= 700 border=0 usemap=\"#" + filename + "\"> </div>");


Thanks for your help

Locked