Hi,
iam facing an issue with JFree Chart i.e while displaying the XYLine chart in servlet iam able to display the chart but here iam not able to display the TOOLTIP which is required for me,but same code is working fine for simple java class iam able to display tooltip as well as chart iam pasting the code snippet which i have used can anyone help me to resolve this issue?
OutputStream out =response.getOutputStream();
final XYSeries s1 = new XYSeries("Today");
final XYSeries s2 = new XYSeries("Yesterday");
final XYSeries s3 = new XYSeries("One-Week Ago");
for (int i = 0; i < 50; i++) {
s1.add(00.0, 10.0);
s1.add(10.0, 20.0);
s2.add(00.0, 20.0);
s2.add(50.0, 45.0);
s3.add(00.0, 15.0);
s3.add(35.0, 45.0);
}
final XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
dataset.addSeries(s3);
final JFreeChart chart = ChartFactory.createXYLineChart("All Ticket Trends","Number of Tickets","Network Time",dataset,PlotOrientation.VERTICAL,true,true,false);
final XYPlot plot = chart.getXYPlot();
chart.setBackgroundPaint(Color.YELLOW);
plot.setOutlinePaint(Color.BLACK);
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(out, chart, 640, 480);
Thanks
Praveen
problem in Displaying a tooltip using servlet
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: problem in Displaying a tooltip using servlet
When your browser displays the PNG image you have created, it doesn't have any information about tooltips, or where they should be displayed. There is a solution - create an HTML image map for the PNG image. There is support for this in JFreeChart - see the ImageMapUtilities class.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Re: problem in Displaying a tooltip using servlet
I have this problem too.....
This code is in the servlet
while i view it on IE, i cannot read the html code, but it really show the png image.
I want to show the tooltip and use the stream output.
how can I do??
This code is in the servlet
Code: Select all
ChartRenderingInfo crInfo = new ChartRenderingInfo(new StandardEntityCollection());
OutputStream ops = response.getOutputStream();
ChartUtilities.writeChartAsPNG(ops, chart, 600, 124, crInfo);
PrintWriter pw = new PrintWriter(ops);
ChartUtilities.writeImageMap(pw, "chart", crInfo, false);
String map = ChartUtilities.getImageMap("chart", crInfo);
response.setContentType("image/png");
pw.flush();
while i view it on IE, i cannot read the html code, but it really show the png image.
I want to show the tooltip and use the stream output.
how can I do??
Re: problem in Displaying a tooltip using servlet
praveen & alloy
can try using this way,BarChart.png is created in the specified path and then displaying as writeimageMap as shown...
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
final File file = new File(request.getRealPath("/BarChart.png"));
ChartUtilities.saveChartAsPNG(file, jfreechart, 600, 400, info);
PrintWriter writer = response.getWriter();
writer.println("<HTML>");
writer.println("<HEAD><TITLE>Bar Chart</TITLE></HEAD>");
writer.println("<BODY>");
ChartUtilities.writeImageMap(writer, "chart", info, true);
writer.println("<IMG SRC=\"BarChart.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">");
writer.println("</BODY>");
writer.println("</HTML>");
writer.close();
can try using this way,BarChart.png is created in the specified path and then displaying as writeimageMap as shown...
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
final File file = new File(request.getRealPath("/BarChart.png"));
ChartUtilities.saveChartAsPNG(file, jfreechart, 600, 400, info);
PrintWriter writer = response.getWriter();
writer.println("<HTML>");
writer.println("<HEAD><TITLE>Bar Chart</TITLE></HEAD>");
writer.println("<BODY>");
ChartUtilities.writeImageMap(writer, "chart", info, true);
writer.println("<IMG SRC=\"BarChart.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">");
writer.println("</BODY>");
writer.println("</HTML>");
writer.close();