Getting and Setting Bar Chart tooltips

Is there a way to override the functionality for the bar chart’s tooltips? I’m trying to find a way to change what is displayed when you mouse over one of the bars. I was hoping there would be an easy way to find what the default value would be, change it, and then write back the text I want.

The getToolTipText() and setToolTipText() functions get and set the Mouseover Text, which is what appears when your mouse is not over a bar. Is there a feature in here that I’m missing?

Hi, Dan,

Not out of the box, but Phil Turmel has mad a module for such things.

https://inductiveautomation.com/forum/viewtopic.php?f=89&t=13874&p=50555&hilit=Note#p50555

[quote=“JordanCClark”]Hi, Dan,

Not out of the box, but Phil Turmel has mad a module for such things.

https://inductiveautomation.com/forum/viewtopic.php?f=89&t=13874&p=50555&hilit=Note#p50555[/quote]Sadly, it doesn’t add anything to bar chart tooltips. In fact, the classic NoteChart doesn’t support bar charts at all. (It’s built for time series historical data.)

Add the following to the bar chart’s property change script.

1 Like

[quote=“jpark”]Add the following to the bar chart’s property change script.

[code]if event.propertyName == “data”:
from org.jfree.chart.labels import CategoryToolTipGenerator

class CustomToolTipGenerator(CategoryToolTipGenerator):
	def generateToolTip(self,dataset,row,column):
		return "TIP: %s = %d %%"%(dataset.getRowKey(row),(dataset.getValue(row,column)))

chart = event.source.getChart()
renderer = chart.getPlot().getRenderer()
renderer.setToolTipGenerator(CustomToolTipGenerator())

[/code][/quote]Sweet!

Brilliant! That got me started, and a combination of google, trial, and error got me the exact tooltips I was looking for.

Many thanks.