I am making use of the Gantt Chart in Vision and I am looking for a way to change the information in the mouse over tooltip.
Currently it will show the Row/task and show the time span in a (mmm, d, yyyy) format. My chart is only showing tasks that all occur on the same day so I would prefer the tooltip to display the time span as hh:mm:ss format.
Simply reformatting my query to only get the Time portion of the Datetime data is not accepted by the Gantt chart, which requires a Datetime for the Start and End Time data.
I've managed to change the tooltip using the code from the example, slightly changed and placed in the property change script. Its returning integer values for all 3 variables below.
Where my dataset (multiply rows, 4 columns) has "String", Datetime, Datetime, Integer
from org.jfree.chart.labels import CategoryToolTipGenerator
class CustomToolTipGenerator(CategoryToolTipGenerator):
def generateToolTip(self,dataset,row,column):
task = dataset.getValue(0,0)
start = dataset.getValue(0,1)
end = dataset.getValue(0,2)
return "%s, %s, %s"%(task,start,end)
chart = event.source.getChart()
renderer = chart.getPlot().getRenderer()
renderer.setToolTipGenerator(CustomToolTipGenerator())
Those three numbers are milliseconds UTC (jfreechart likes numbers in its datasets). Use system.date.fromMillis() to make date objects, and then format those as you see fit with system.date.format....
Thanks that worked out. I am still having some issues now with dataset.getValue function.
dataset.getValue(0,0) is returning a time value as well when in the dataset it is a string value.
Also trying dataset.getValue(Row,0) nothing happens.
When I view the client I get the new tooltips only some of the times, so I am not sure if my property change script is calling itself when I would like it to.