Easy Chart Pen ToolTips

Need some help with the Easy Chart configureChart method. I am trying to change the mouse hover over tooltip on pens to display the tag documentation property from the tag itself.

The problem I’m having is figuring out how to expose and update the jfree chart for the mouse over tooltips on pens.

Has anyone accomplished this? I’ve searched through the forums and couldn’t find any straight forward solution.


Bump. I’d like to be able to change the numeric format of these tool tips. Any ideas?

Bump. This has come up as a request again.

@pturmel showed us how to expose the chart here, and he exposes a lot of hidden properties in his Note Chart Module

Below is a recent forum example of his code being used to find the mode. I'm sure you could adapt it for this purpose:

Here is an example of creating a customMouseListener, which is what you will need. I think this example was for a Standard Chart component, but it will work for an easy chart as well. It's not exactly what you're looking for but its a pretty good start.

1 Like

@eckman.tech - I experimented with this, and I was able to manipulate the format of an easy chart's tool tips using a button's actionPerformed event handler. It should be easy to modify the method for any usage case. Here is the code:

from org.jfree.chart.labels import StandardXYToolTipGenerator
renderer = event.source.parent.getComponent('Easy Chart').getComponent(0).getComponent(0).chart.getPlot().getRenderer()
xFormat = renderer.getBaseToolTipGenerator().getXFormat().getInstance()
yFormat = renderer.getBaseToolTipGenerator().getYFormat().getInstance()
renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator("{2}% Full", yFormat, xFormat))

Tool tip before edit:

Tool tip after edit:

The key is the is the first field in the StandardXYToolTipGenerator. Using reflection, I was able to determine that the DEFAULT_TOOLTIP_FORMAT = "{0}: ({1}, {2})" where {0} is the field, {1} is the y axis, and {2} is the x axis.

The format string behaves like a MessageFormat, but for the xFormat, you will have to modify the format using the methods in java.txt.NumberFormat prior to applying the tool tip generator. Likewise the yFormat will have to be modified using the methods in java.text.DateFormat.

Finally, the getRenderer() method does not apply to all plots, so if you are using a piePlot for example, simply omit it, and use a StandardPieToolTipGenerator instead of a StandardXYToolTipGenerator:

toolTipGenerator = event.source.parent.getComponent('Easy Chart').getComponent(0).getComponent(0).chart.getPlot().getToolTipGenerator()
#	.getLabelFormat() = {0}: ({1}, {2})
#	.getNumberFormat() = java.text.DecimalFormat
#	.getPercentFormat() = java.text.DecimalFormat

1 Like