Tutorial: Step 5

Create ImageMap and Tooltip Information

To provide your chart with additionnal tooltips and image map information you have to provide an additional Java class or enhance an existing one like the one below. In this tutorial we will add some methods to the datasetproducer class which had been introduced at the beginning of this tutorial.

...
public String generateLink(Object data, int series, Object category) {
return seriesNames[series];
}

public String generateToolTip(CategoryDataset arg0, int series, int arg2) {
return seriesNames[series];
}
...

As you can see it is very easy to implement a class that produces image map and tooltips information. First of all it has to implement the interfaces CategoryItemLinkGenerator and CategoryToolTipGenerator (as it produces a CategoryDataset). For other data types refer to the cewolf java api.

To let your class produce links and tooltips for the chart image you have to change the <cewolf:img> tag as follows:

<cewolf:img chartid="line" renderer="cewolf" width="400" height="300">
<cewolf:map id="pageViews"/>
</cewolf:img>

Reload your page and you will see tooltips and links on data points. Internet Explorer browsers are handled slightly different as others as they are able to render a tooltip based on the alt attribute inside an image map. All other browser need the overlib.js for this. Cewolf tries to determine the used browser and renders a correct page transparently.

For further information on using Cewolf refer to the Tag Library Reference and the Cewolf JavaDoc.

If you want to see more examples of how to implement catchy charts in your webapp, you should deploy the example webapp (downloadable from the Cewolf home page and have a look at its sourcecode.

SourceForge Logo