Image Map not working for PiePlot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mjacobsca
Posts: 16
Joined: Thu Aug 21, 2003 4:59 pm

Image Map not working for PiePlot

Post by mjacobsca » Fri Sep 19, 2003 6:10 pm

I'm experiencing strage behavior with image maps in 0.9.11 and 0.9.12. Pie3DPlot image maps ARE working, but PiePlot image maps are NOT working. In the code listed below, note how when the PiePlot is used, the image map is empty:

Code: Select all

<MAP NAME="testmap">
</MAP>


----

To test the working plot, just uncomment the Pie3DPlot line, and comment out the PiePlot line.

Code: Select all

<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.entity.*" %>
<%@ page import="org.jfree.data.*" %>
<%@ page import="org.jfree.chart.axis.*" %>
<%@ page import="org.jfree.chart.plot.*" %>
<%@ page import="org.jfree.chart.renderer.*" %>
<%
	DefaultPieDataset dpd = new DefaultPieDataset();
	for (int i = 0; i < 5; i++)
		dpd.setValue("Cat " + i, new Integer(5));

	PiePlot plot = new PiePlot(dpd);
	//Pie3DPlot plot = new Pie3DPlot(dpd);
	JFreeChart chart = new JFreeChart("test", null, plot, true);

	ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
	ChartUtilities.saveChartAsPNG(new File("c:\\temp\\jfree.png"), chart, 500, 400, info);
%>
<html>
<body>
<h1>Test Chart With ImageMap</h1>
<img src="c:/temp/jfree.png" border="0" usemap="#testmap">
<br><br>
</body>
<%
	ChartUtilities.writeImageMap(new PrintWriter(out), "testmap", info);
%>
</html>
Has anyone else experienced this behavior? If so, what is the workaround?

Michael

mjacobsca
Posts: 16
Joined: Thu Aug 21, 2003 4:59 pm

image map not working

Post by mjacobsca » Tue Sep 23, 2003 10:58 pm

Can anyone duplicate this bug or is it just me?...

Michael

richard_atkinson
Posts: 115
Joined: Fri Mar 14, 2003 3:13 pm
Location: London, England
Contact:

Pie Problems

Post by richard_atkinson » Wed Sep 24, 2003 8:22 am

ImageMapDemo2 demonstrates an image map correctly working with a Pie Plot. You need to specify an PieItemLabelGenerator and/or a PieURLGenerator to get more content in your image map.

Code: Select all

<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.entity.*" %>
<%@ page import="org.jfree.data.*" %>
<%@ page import="org.jfree.chart.axis.*" %>
<%@ page import="org.jfree.chart.plot.*" %>
<%@ page import="org.jfree.chart.labels.*" %>
<%@ page import="org.jfree.chart.urls.*" %>
<%@ page import="org.jfree.chart.renderer.*" %>
<%
   DefaultPieDataset dpd = new DefaultPieDataset();
   for (int i = 0; i < 5; i++)
      dpd.setValue("Cat " + i, new Integer(5));

   PiePlot plot = new PiePlot(dpd);
	plot.setItemLabelGenerator(new StandardPieItemLabelGenerator());
	plot.setURLGenerator(new StandardPieURLGenerator("pie_chart_detail.jsp"));
   //Pie3DPlot plot = new Pie3DPlot(dpd);
   JFreeChart chart = new JFreeChart("test", null, plot, true);

   ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
   ChartUtilities.saveChartAsPNG(new File("c:\\temp\\jfree.png"), chart, 500, 400, info);
%>
<html>
<body>
<h1>Test Chart With ImageMap</h1>
<img src="c:/temp/jfree.png" border="0" usemap="#testmap">
<br><br>
</body>
<%
   ChartUtilities.writeImageMap(new PrintWriter(out), "testmap", info);
%>
</html>
Regards,
Richard...

mjacobsca
Posts: 16
Joined: Thu Aug 21, 2003 4:59 pm

thanks!

Post by mjacobsca » Wed Sep 24, 2003 4:45 pm

Thanks Richard. I guess I need to study the 0.9.12 generators a little more. I'm glad this wasn't a bug, and that the change actually occurred with some forthought.

Michael

Locked