Selectable bar graph still shows selection after graph chnge

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?

Sorry, I posted this in the SQL portion and it was supposed to go under the PMI forum.

Hmm, we should probably reset the selection when the data changes. in the meantime, if you toggle the selectionEnabled, that should clear the selection.

I put the following lines in the chart “event propertychange”

if event.propertyName == ‘Data’:
event.source.selectionEnabled = 0
event.source.selectionEnabled = 1

Thinking that when the data changed, it would toggle the selection enabled option but it did not seem to make any difference.

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)

Hope this helps,

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)

My mistake, try this:

[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])

event.source.Cumulative = fpmi.db.toDataSet(headers,rows)[/code]

Also, please use the [code] block when posting code to the forum to preserve formatting. (See inductiveautomation.com/foru … ode=bbcode for more info)

Thanks for the code, but I still get this error:

Traceback (innermost last):
File “”, line 6, in ?
NameError: java

Any idea why? Should I just be waiting for the next release when this problem will be addresses?

[quote]Thanks for the code, but I still get this error:

Traceback (innermost last):
File “”, line 6, in ?
NameError: java

Any idea why? Should I just be waiting for the next release when this problem will be addresses?[/quote]

This would indicate to me that you have not imported the appropriate java package. Try adding

[code]import java.lang.System

[/code]before

when = java.lang.System.currentTimeMillis()

That was it. Works like a charm now. Thanks a lot.