I have a bar graph that has selection enabled. When I click on a bar, that generates a new query for another graph. In this way I am drilling down into the equipment downtime problem.
I notice that when the graph is redrawn because of a change, the highlight around the bar that was selected is still there, even though the bar is drawn in a different location. Everything functions correctly, but the outline is still over the graph. Do I need to reset that some how, or change a setting when the graph refreshes?
Hmm, we should probably reset the selection when the data changes. in the meantime, if you toggle the selectionEnabled, that should clear the selection.
Sorry, it turns out that toggling selectionEnabled won’t do what you want (as you discovered) in version 3.1.6.
We’ll add the ability to clear the chart selection programmatically in the next release, but until then, here is a hack that’ll clear it. You’d put this on the chart’s propertyChange event like you tried to before:
if event.propertyName == 'Data':
chart = event.source
from java.awt.event import MouseEvent
click = MouseEvent(chart, MouseEvent.MOUSE_CLICKED, event.when, 0,0,0,1,0)
chart.dispatchEvent(click)
Thanks Carl,
But I still have a problem. I’m not sure if I put it in the correct location, with regard to the rest of the script, but now I am getting the following error. It looks like it doesn’t like the when portion.
Traceback (innermost last):
File “”, line 10, in ?
AttributeError: instance of ‘java.beans.PropertyChangeEvent’ has no attribute ‘when’
Here is the script, with the new portion.
#Create 2nd dataset for line graph portion
if event.propertyName == ‘Data’: #Work around to clear outline of selected graph part
chart = event.source
from java.awt.event import MouseEvent
click = MouseEvent(chart, MouseEvent.MOUSE_CLICKED, event.when, 0,0,0,1,0)
chart.dispatchEvent(click)
data = fpmi.db.toPyDataSet(event.newValue)
headers = ["x","Cumulative"]
# First, calculate the total
total = 0
for row in data:
total += row[1]
# Now, generate the new dataset
rows = []
pct = 0
for row in data:
if total > 0:
pct += (float(row[1])/float(total))*100
rows.append([row[0], pct])
event.source.Cumulative = fpmi.db.toDataSet(headers,rows)
[code]#Create 2nd dataset for line graph portion
if event.propertyName == ‘Data’: #Work around to clear outline of selected graph part
chart = event.source
from java.awt.event import MouseEvent
when = java.lang.System.currentTimeMillis()
click = MouseEvent(chart, MouseEvent.MOUSE_CLICKED, when, 0,0,0,1,0)
chart.dispatchEvent(click)
data = fpmi.db.toPyDataSet(event.newValue)
headers = [“x”,“Cumulative”]
First, calculate the total
total = 0
for row in data:
total += row[1]
Now, generate the new dataset
rows = []
pct = 0
for row in data:
if total > 0:
pct += (float(row[1])/float(total))*100
rows.append([row[0], pct])