Hello all,
I'm using JSP and MySQL : I'm having alot of fun with JFREE.
One thing I am stuck with is customizing URLs in an imagemap.
I am doing a timeseries graph (simple) : I would like the url to be different for every data point instead of being
index.html?ID=1,
index.html?ID=2,
index.html?ID=3
etc..
I tried different methods by had no success. Is there a way to re-write the URL's?? here is my code.
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Line",
"Date",
"price",
dataset1,
true,
true,
true
);
XYPlot plot = (XYPlot) chart.getPlot();
StandardXYItemRenderer renderer = new StandardXYItemRenderer();
XYURLGenerator setURL = new StandardXYURLGenerator();
renderer.setBaseShapesVisible(true);
renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
plot.setRenderer(0, renderer);
response.setContentType("text/html");
PrintWriter pw = new PrintWriter(out);
String filename = ServletUtilities.saveChartAsPNG(chart, 450, 400, info, session);
ImageMapUtilities.writeImageMap(pw, filename, info);
pw.flush();
String graphURL = System.getProperty("java.io.tmpdir") + filename;
thank alot in advance
Custom URL
?
in order to have in your <map> tag the correcte and customizable href: which class should you change to have...
href="me.jsp?series=0&item=17"
href="test.jsp?series=0&item=16"
href="index.jsp?series=0&item=15"
href="frames.jsp?series=0&item=14"
instead of
href="index.html?series=0&item=17"
href="index.html?series=0&item=16"
href="index.html?series=0&item=15"
href="index.html?series=0&item=14"
thanks
href="me.jsp?series=0&item=17"
href="test.jsp?series=0&item=16"
href="index.jsp?series=0&item=15"
href="frames.jsp?series=0&item=14"
instead of
href="index.html?series=0&item=17"
href="index.html?series=0&item=16"
href="index.html?series=0&item=15"
href="index.html?series=0&item=14"
thanks
-
- Posts: 6
- Joined: Tue Feb 14, 2006 10:56 pm
This is easy to do--I've done it. For full control, you need to implement your own version of a URL generator (such as org.jfree.chart.urls.XYURLGenerator or org.jfree.chart.urls.CategoryURLGenerator, depending on your renderer) and then supply that to the renderer. All the URL generator has to do is supply a string given the particular data point, so it can have as complicated an algorithm as you need. **
You may be able to use an existing implementation of a URL generator (see the org.jfree.chart.urls package), but I doubt it, if you need a different base URL for each point.
By the way, this is separate from the image map generator, which takes in a URL (created by a URL generator) and a tooltip and outputs them in image-map format. You don't need to change the image map code at all for this.
Did that help?
** By the way, kudos to David Gilbert, Richard Atkinson, and others who architected JFreeChart. The extensive use of simple (often one-function) interfaces for each separate customization facet is simply brilliant.
You may be able to use an existing implementation of a URL generator (see the org.jfree.chart.urls package), but I doubt it, if you need a different base URL for each point.
By the way, this is separate from the image map generator, which takes in a URL (created by a URL generator) and a tooltip and outputs them in image-map format. You don't need to change the image map code at all for this.
Did that help?
** By the way, kudos to David Gilbert, Richard Atkinson, and others who architected JFreeChart. The extensive use of simple (often one-function) interfaces for each separate customization facet is simply brilliant.