I am drawing a chart using JFreeChart. I would like to get its output in SVG format so using JFreeSVG.
Is it possible to create charts using JFreeChart and attach some handlers to it in the SVG format? For example, in case of bar chart - click on a bar should have a handler(which will drill-down the chart) or click on a legend could be recognized(to take some action on it). Thus, I am looking for a way to attach my handlers to different JFreeChartEntities in its SVG output format to make them interactive at the browser end.
Interactive SVG charts/images
Re: Interactive SVG charts/images
I'll tell what I do to achieve a similar result.
First, give each data point a unique id before it is drawn (requires extending renderers):
We have a UI for assigning actions to be executed for events in the browser (click, mouse out, mouse over, and so on). These events are assigned to the uniqueId for a data point and stored on the server in JSON format.
When the page loads we retrieve the JSON object and attach the event handler (in my case all the details are in the JSON object and I use JQuery):
First, give each data point a unique id before it is drawn (requires extending renderers):
Code: Select all
g2.setRenderingHint(SVGHints.KEY_ELEMENT_ID, uniqueId);
When the page loads we retrieve the JSON object and attach the event handler (in my case all the details are in the JSON object and I use JQuery):
Code: Select all
$.getJSON(url, function(data) {
var dp = $("#"+data.id);
dp.click(function(e) {
eval(data.click);
});
});
Re: Interactive SVG charts/images
Thanks,
Will look into it.
Will look into it.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Interactive SVG charts/images
Just for anyone that is interested, this approach has been implemented in Orson Charts, there are some examples here:
http://www.object-refinery.com/blog/blog-20140509.html
…and the same approach will eventually be incorporated into JFreeChart.
http://www.object-refinery.com/blog/blog-20140509.html
…and the same approach will eventually be incorporated into JFreeChart.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

