Image Map generation not flexible enough
Image Map generation not flexible enough
JFreeChart needs a small framework, that allows developers to plug in custom image map generators, like that in jCharts.
Looking first through the developer guide, that I bought, and then through the source code, I detected, that, in order to use a tooltip library different from overlib, I actually have to patch the ChartEntity.getImageMapAreaTag() method.
This is, because, for instance, BarRenderer.drawHorizontalItem() simply does a "... new CategoryItemEntity(...)", when collecting the entity info.
Instead, there should be something like "...getEntityGenerator().getEntity(...)", such, that the renderers do not need to know the entity class.
Anyway, thanks for the great charting library.
Looking first through the developer guide, that I bought, and then through the source code, I detected, that, in order to use a tooltip library different from overlib, I actually have to patch the ChartEntity.getImageMapAreaTag() method.
This is, because, for instance, BarRenderer.drawHorizontalItem() simply does a "... new CategoryItemEntity(...)", when collecting the entity info.
Instead, there should be something like "...getEntityGenerator().getEntity(...)", such, that the renderers do not need to know the entity class.
Anyway, thanks for the great charting library.
-
- Posts: 115
- Joined: Fri Mar 14, 2003 3:13 pm
- Location: London, England
- Contact:
Image Map generation not flexible enough
Giorgio,
I would agree the current image map generation is not flexible enough. I've made some changes to support pluggable generation of tooltip and URL area tag fragments. The changes do involve any API changes for those people who are currently using the ChartUtilties class to generate HTML image maps. I'll try and check the changes into CVS in the day or two.
In the meantime if anyone would like any other tooltip libraries supported in the core JFreeChart library (other than OverLib or the HTML title attribute), please let me know and I'll add them in.
Thanks and regards,
Richard...
New ChartUtilities method
New interfaces
org.jfree.chart.imagemap.ToolTipTagFragmentGenerator
org.jfree.chart.imagemap.URLTagFragmentGenerator
New classes
org.jfree.chart.imagemap.StandardURLTagFragmentGenerator
org.jfree.chart.imagemap.StandardToolTipTagFragmentGenerator
org.jfree.chart.imagemap.OverLIBToolTipTagFragmentGenerator
I would agree the current image map generation is not flexible enough. I've made some changes to support pluggable generation of tooltip and URL area tag fragments. The changes do involve any API changes for those people who are currently using the ChartUtilties class to generate HTML image maps. I'll try and check the changes into CVS in the day or two.
In the meantime if anyone would like any other tooltip libraries supported in the core JFreeChart library (other than OverLib or the HTML title attribute), please let me know and I'll add them in.
Thanks and regards,
Richard...
New ChartUtilities method
Code: Select all
import org.jfree.chart.imagemap.ToolTipTagFragmentGenerator;
import org.jfree.chart.imagemap.URLTagFragmentGenerator;
public static void writeImageMap(PrintWriter writer, String name, ChartRenderingInfo info,
ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
URLTagFragmentGenerator urlTagFragmentGenerator) throws IOException
org.jfree.chart.imagemap.ToolTipTagFragmentGenerator
org.jfree.chart.imagemap.URLTagFragmentGenerator
New classes
org.jfree.chart.imagemap.StandardURLTagFragmentGenerator
org.jfree.chart.imagemap.StandardToolTipTagFragmentGenerator
org.jfree.chart.imagemap.OverLIBToolTipTagFragmentGenerator
-
- Posts: 115
- Joined: Fri Mar 14, 2003 3:13 pm
- Location: London, England
- Contact:
Image Map generation not flexible enough
Sorry just read my previous post and there is a rather critical typo.
The changes do not involve any API changes for those people who are currently using the ChartUtilities class to generate HTML image maps.
Anyway, the changes seem to be working well and are now checked into CVS. I've created an additional ToolTipTagFragmentGenerator to generate tooltips for the Dynamic Drive DHTML Tip Message library (http://www.dynamicdrive.com) which is rather cool. The library is similar to overLIB (actually it was originally based on overLIB) however it is lighter weight and provides some very funky transition effects.
Regards,
Richard...
The changes do not involve any API changes for those people who are currently using the ChartUtilities class to generate HTML image maps.
Anyway, the changes seem to be working well and are now checked into CVS. I've created an additional ToolTipTagFragmentGenerator to generate tooltips for the Dynamic Drive DHTML Tip Message library (http://www.dynamicdrive.com) which is rather cool. The library is similar to overLIB (actually it was originally based on overLIB) however it is lighter weight and provides some very funky transition effects.
Regards,
Richard...
Richard,
thanks for taking this up so quickly!
I am looking forward to the next release
(By the way, the javascript library I am using to display tooltips is domTT, http://www.mojavelinux.com/forum/viewtopic.php?t=127).
Georg
thanks for taking this up so quickly!
I am looking forward to the next release

(By the way, the javascript library I am using to display tooltips is domTT, http://www.mojavelinux.com/forum/viewtopic.php?t=127).
Georg
onMouseOver and onMouseOut events
I like to set the window status when my users roll over the hotspots. I also need links from them. In order to accomplish this, I loop through the ChartEntities and change the tooltips by adding in:
onMouseOver="... and onMouseOut="...
Currently, it appears that the tooltips support the use of the ALT/TITLE tag for popups, and an HREF tag for URL's, but nothing more. It was very easy for me to add to the necessary tooltip generation code to accomplish what I wanted for my javascript functions, so I was hoping that you could consider adding expanded support for custom text to be added to the map generation inside the map tag.
Therefore, the map logic would be something like:
Another advantage of this is that people could code their own DHTML popups that popup quicker, and have a different color than the default browser popups that take 3 seconds to appear.
Michael
onMouseOver="... and onMouseOut="...
Currently, it appears that the tooltips support the use of the ALT/TITLE tag for popups, and an HREF tag for URL's, but nothing more. It was very easy for me to add to the necessary tooltip generation code to accomplish what I wanted for my javascript functions, so I was hoping that you could consider adding expanded support for custom text to be added to the map generation inside the map tag.
Therefore, the map logic would be something like:
Code: Select all
<AREA SHAPE="POLY" COORDS="5,5,10,10" alt="ALTLABEL" href="HREFLABEL" CUSTOMTEXT>
Michael
-
- Posts: 115
- Joined: Fri Mar 14, 2003 3:13 pm
- Location: London, England
- Contact:
More flexible image map generation
If you use JFreeChart 0.9.12, you can implement your own org.jfree.chart.imagemap.ToolTipTagFragmentGenerator to do whatever you require. See the ChartUtilities class for details on how it is called.
Regards,
Richard...
Regards,
Richard...
Increase in flexibility in tag generators
I'll admit I like JFreeChart in general (I'm toying with 1.0.0) but I do have a complaint similar to the original posting -- namely that the generators for tool tips and URLs still aren't quite flexible enough.
Ideally, the ToolTipTagFragmentGenerator and URLGenerator (or their replacements/additions) would be able to get at the series number, point number, X value (if applicable), Y value, and maybe the category; I'm not entirely sure but a string passed in as a single String parameter doesn't quite cut it.
However, since they're interfaces and already defined, this poses a minor problem in how to properly extend this functionality.
I would hope that JFreeChart, at some point, can support the usage
where popup() and popoff() are defined elsewhere somewhere in the Javascript. Apart from generating the strings 'popup(' and 'popoff(', there's no real need for the generators to do anything horribly strange here; it's just generating a bit of text.
The series I can hack in, if only because the format I'm getting to the ToolTipTagFragmentGenerator is of the form 'n: (x,y)', where n is a series number (0-whatever), and x and y are the point coordinates. (I'm primarily interested in flyovers for the scatter plot, although bar graph and line graph flyovers would also be useful). The odd thing is that the URL Fragment generator *does* get the point number, so it's obviously available ... somewhere.
I'm not sure I like the notion of a ToolTipTagExFragmentGenerator or a ToolTipBaseFragmentGenerator, but am wondering what plans, if any, are being contemplated to allow for more flexible tooltip generation in 1.1.0 (or 1.0.1?). Or should I just get a read-only CVS copy and dig?
I suppose in a pinch I could generate another implementation for ChartUtilities.getImageMap(), if I absolutely have to. That would make three, which as you no doubt already know gets unwieldly.
Thanks in advance.
Ideally, the ToolTipTagFragmentGenerator and URLGenerator (or their replacements/additions) would be able to get at the series number, point number, X value (if applicable), Y value, and maybe the category; I'm not entirely sure but a string passed in as a single String parameter doesn't quite cut it.

However, since they're interfaces and already defined, this poses a minor problem in how to properly extend this functionality.
I would hope that JFreeChart, at some point, can support the usage
Code: Select all
<AREA onmouseover='popup(series,point#)' onmouseout='popoff()' ...>
The series I can hack in, if only because the format I'm getting to the ToolTipTagFragmentGenerator is of the form 'n: (x,y)', where n is a series number (0-whatever), and x and y are the point coordinates. (I'm primarily interested in flyovers for the scatter plot, although bar graph and line graph flyovers would also be useful). The odd thing is that the URL Fragment generator *does* get the point number, so it's obviously available ... somewhere.
I'm not sure I like the notion of a ToolTipTagExFragmentGenerator or a ToolTipBaseFragmentGenerator, but am wondering what plans, if any, are being contemplated to allow for more flexible tooltip generation in 1.1.0 (or 1.0.1?). Or should I just get a read-only CVS copy and dig?

I suppose in a pinch I could generate another implementation for ChartUtilities.getImageMap(), if I absolutely have to. That would make three, which as you no doubt already know gets unwieldly.
Thanks in advance.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
I don't know the best approach, but another place to look is the getImageMapAreaTag() method in the ChartEntity class - perhaps some flexibility can be injected there.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


I just got done looking at this in order to add a 'onclick' attribute to the imagemap tag. The easiest way I found was to create my own org.jfree.chart.imagemap.URLTagFragmentGenerator and org.jfree.chart.url.CategoryURLGenerator (in my test case I was using a CategoryPlot).
I had the generateURL() method from JavascriptCategoryURLGenerator return a JSON object (surrounded by parens), the prefix is used for the function name:
Then the JavascriptURLTagFragmentGenerator was pretty simple:
Then when I'm building my image map:
So when the mapped areas are clicked, they execute "functionName( { series: '15', month: 'Jan'} ); return false;".
Then just make sure you have the javascript code:
I had the generateURL() method from JavascriptCategoryURLGenerator return a JSON object (surrounded by parens), the prefix is used for the function name:
Code: Select all
public String generateURL(CategoryDataset dataset, int series,
int category) {
String url = this.prefix;
Comparable seriesKey = dataset.getRowKey(series);
Comparable categoryKey = dataset.getColumnKey(category);
url += "( {" + this.seriesParameterName + ": "
+ "'" + seriesKey.toString() + "', ";
url += this.categoryParameterName + ": "
+ "'" + categoryKey.toString() + "' } )";
return url;
}
Code: Select all
public String generateURLFragment(String onclickText) {
return " href=\"#\" onclick=\"" + onclickText + "; return false\"";
}
Code: Select all
renderer.setItemURLGenerator(new JavascriptCategoryURLGenerator("drillDown", "series", "month") );
...
ChartUtilities.writeImageMap(
pw,
"chart",
info,
new StandardToolTipTagFragmentGenerator(),
new JavascriptURLTagFragmentGenerator()
);
Then just make sure you have the javascript code:
Code: Select all
function drillDown( data ) {
var series = data.series;
var month = data.month;
alert("Series: " + series + "\nMonth: " + month);
}
Hi,
I am hitting similar walls with image map generation not being
flexible enough.
My problem is that I would like to overwrite the default image map
areas for a particular point. For example, I would like
a line chart to be clickable on the entire X-Axis, and not just at the point
on the line.
If there is already a way to do this, any hints would be greatly
appreciated.
Cheers,
Nick
I am hitting similar walls with image map generation not being
flexible enough.
My problem is that I would like to overwrite the default image map
areas for a particular point. For example, I would like
a line chart to be clickable on the entire X-Axis, and not just at the point
on the line.
If there is already a way to do this, any hints would be greatly
appreciated.
Cheers,
Nick