XY Chart doesn't update

Hello,

I’m using a XY chart in mode “column” to display the number of alarms that occured on the 10 past days (from yesterday).
I tried different approaches (with of without methods, by launching the script onStartup of the component or of the view, …), but nothing works as I want.
One of the approach I think well is below, I execute this script onStartup of the component. The idea is to give the source allowing to access the right alarms in function of the type of the filtration (I have two differents), and then to perform a loop to add successively the objects in the dataSources.data property of the XY chart component, and in these objects i put the date and the number of alarms retrieved for this specific day.

src = "prov:default:/tag:" + self.view.params.udtElements.Parameters.UDTName + "/" + self.view.params.filtrationType + "_Filtration/*"
self.props.dataSources.data = []
	
for i in range(9, -1, -1) :
	
	date = system.date.addDays(system.date.now(), -(i+1))
	startDate = system.date.setTime(date,0,0,0)
	endDate = system.date.setTime(date,23,59,59)
					
	#Alarm Journal query to retireve alarms which correspond to the criterias				
	query_results = system.alarm.queryJournal(startDate, endDate, journalName = "Alarming", displayPath=self.view.params.udtElements.Parameters.UDTName, source=src)
									
	new_object = {}
	new_object["date"] = date
	new_object["num_alarms"] = len(query_results)
	self.props.dataSources.data.append(new_object)

Here is the result I expect to have :

It sometimes works, but most of the time it doesn’t, I don’t really understand why. do you have an idea ?

Thanks in advance.

The onStartups dont always trigger on refreshes of the page or redirects

Polling with an expression binding on time or something would probably work

Oh, that's too bad, and quite unexpected :sweat_smile:
Effectively, when I launch the script onClick instead of onStartup then it seems to work, but it is not very convenient. I'll try to find something else, maybe with a time condition if I find one relevant.

seems like this should refresh when ever
self.view.params.udtElements.Parameters.UDTName
self.view.params.filtrationType
or the day changes

1 Like