Easy Chart configChart flashing?

def configureChart(self, chart):
	# Put your code here
	self.startDate = self.parent.startDT
	self.endDate = self.parent.endDT
	
	headers = ["NAME","TAG_PATH","AGGREGATION_MODE","AXIS","SUBPLOT","ENABLED","COLOR","DASH_PATTERN","RENDER_STYLE","LINE_WEIGHT","SHAPE","FILL_SHAPE","LABELS","GROUP_NAME","DIGITAL","OVERRIDE_AUTOCOLOR","HIDDEN","USER_SELECTABLE","SORT_ORDER","USER_REMOVABLE"]
	data = []
	
	data.append(["LIT0101","[default]Item1/Sensors/LIT0101/SensorStatus/value","MinMax","cm","1","true","color(255,85,85,255)","","1","1.0","0","true","false","","false","false","false","true",3,"true"])
	data.append(["LIT0201","[default]Item1/Sensors/LIT0201/SensorStatus/value","MinMax","cm","1","true","color(85,85,255,255)","","1","1.0","0","true","false","","false","false","false","true",2,"true"])
	data.append(["LIT0202","[default]Item1/Sensors/LIT0202/SensorStatus/value","MinMax","cm","1","true","color(85,255,85,255)","","1","1.0","0","true","false","","false","false","false","true",1,"true"])
	dataset  = system.dataset.toDataSet(headers, data)
	
	self.tagPens = dataset

When this chart show, it always flashing?

I don't believe I would do any of that in configureChart. The dataset, once saved in the designer shouldn't need to be recreated, but if it needed to be scripted at initialization for some reason, the easy chart's propertyChange event handler would be where I would put it. The code would look something like this:

# Run only once at initialization
# componentRunning only works in the designer if preview mode is on before the window is opened
if event.propertyName == 'componentRunning' and event.newValue:

	# Get the tag pen headers
	headers = list(system.dataset.getColumnHeaders(event.source.tagPens))
	
	# Get the tag pen parameter information in some way and assemble it into a list of lists
	data = [
		["LIT0101","[default]Item1/Sensors/LIT0101/SensorStatus/value","MinMax","cm","1","true","color(255,85,85,255)","","1","1.0","0","true","false","","false","false","false","true",3,"true"],
		["LIT0201","[default]Item1/Sensors/LIT0201/SensorStatus/value","MinMax","cm","1","true","color(85,85,255,255)","","1","1.0","0","true","false","","false","false","false","true",2,"true"],
		["LIT0202","[default]Item1/Sensors/LIT0202/SensorStatus/value","MinMax","cm","1","true","color(85,255,85,255)","","1","1.0","0","true","false","","false","false","false","true",1,"true"]]
	
	# Compile the data into a dataset and assign it to the tag pens property
	event.source.tagPens = system.dataset.toDataSet(headers, data)

As for the dynamic start and end parameters, I would move this script out of configureChart and onto the parent container's propertyChange event handler:

# Validate the events, so this script only runs when the start and end date properties change
if event.propertyName in ['startDT', 'endDT']:

	# Get the current start and end dates
	startDate = event.source.startDT
	endDate = event.source.endDT
	
	# Validate the start and end dates in some way before assigning them to the chart parameters
	if endDate and startDate and endDate > startDate:
		easyChart = event.source.parent.getComponent('Easy Chart')
		easyChart.startDate = startDate
		easyChart.endDate = endDate

The configureChart method is called when the component has gathered and analyzed all of the pen data and base configuration data to plot. It gives you a chance to tweak the presentation. Assignment to chart properties makes the component re-analyze everything, and call configureChart again.

Don't assign to component properties in configureChart. Ever.

I set the tagPens in propertyChange Script.

I set DT in configChart Script.

Maybe it's right now!

No! Resetting the start/end in configureChart causes configureChart to run again.

:man_shrugging:

2 Likes

Use the parent container's property change event handler to set the start and end dates whenever the custom properties change. I assume the custom properties have some type of binding? See my example.

if event.propertyName in ['startDT', 'endDT']:

There's nothing you said in the propertyName startDT endDT...
There is startDate or endDate .

In this case startDate , change two times.

That's because you're displaying the property change events of the easy chart itself and not the property change events of the easy chart's parent where your custom properties are.