EasyChart Historical mode does not update with new data

I’ve noticed that the EasyChart using the Historical mode does not automatically pull in new trend data once the daterange has been set. If this range is set to a range that includes ‘now’ and beyond, new data is not pulled in until you modify the daterange slightly.

Is this intentional by design, or perhaps a bug?
Regardless, how can I force this to refresh its data every x seconds? I have tried to use a Timer component, but I’m not sure what property or method I can use to manually force the update.

Cheers,

Nick

It’s intentional - if you want realtime data…use realtime mode. That said, if you want to poll the chart (but also allow a date/time range, which I don’t entirely understand) then you should add your own date manipulation component(s) (ie, your own date range slider, using expressions to change the end date) and set the chart to ‘Manual’ mode, with the start date and end date bound to your date range. If you leave it in historical mode and attempt to bind those properties, you probably won’t get the results you expect, because the chart itself will change them on startup and during a few other events.

Thanks Paul. Most of the time our users want to see the current trend say for the day and have it update with new data as it comes in (or rather, every second). However they also want to be able to both go back in time to look at historical data as well, which you can’t do with the realtime mode. Hence the reason I need to be able to use the historical mode but also have it update the data at the same time.
So is this not possible to do properly?
Otherwise, I will simply write to the start or end date and cycle increasing/decreasing it by a millisecond to force it to think the daterange has changed and to hence pull in new data. I’d prefer to use a less hacky method though…

You can change the chart mode at runtime. For my charts, I have a button on the same window that is bound to the chart mode, to toggle it between the realtime mode and historical mode. It’s just a two-state toggle button toggling between 1 and 2 (the int values representing realtime mode and historical mode for an easy chart.) The built-in controls change to reflect the current mode.

2 Likes

While I could do this, I feel it’s a bit clunky having to swap between the modes. I actually haven’t used another SCADA platform where my described functionality isn’t the normal (then again, I also haven’t used another SCADA platform that offers the sheer amount of flexibility and ease of use that Ignition does).
I’ve worked around this with a Timer component that adds and subtracts 1ms to the endDate every time it updates. It’s a bit hacky, but it works.

# update the easychart and pull in new data by slightly changing the end date up and down by 1ms
chart = event.source.parent.getComponent('Easy Chart')
endDate = chart.endDate
now = system.date.now()
if system.date.isAfter(endDate, now):
	if event.source.value == 0:
		endDate = system.date.addMillis(endDate, 1)
	else:
		endDate = system.date.addMillis(endDate, -1)

	chart.endDate = endDate
1 Like

How do you intend to make the chart keep up with the data as time passes? Eventually, you will have enough data to fill the chart and without modifying the end date of the chart, you won’t see new data. And, after your chart is full, you’ll be continuing to hit your database to refresh data that hasn’t changed (I’m assuming, maybe not.)

IMO, having a button to toggle modes is pretty usable. I haven’t really had any operator complaints about it being a complicated system to use.

It looks like, from a brief scan of the code, you could call <chart>.updateQueryDateRange() from scripting to refresh the data without actually changing any values.

In another SCADA platform, they have a toggle button to toggle shifting the daterange +1s every second as it updates, which is essentially what the realtime mode is doing anyway except that the time period is fixed. I could achieve a similar thing in Ignition, again using the timer component. I would disable the timeshifting if the endDate < now.

Hmm, when I try that method, it says that the chart object doesn’t have the attribute. I can’t find this in the javadocs either, but this is essentially what I’m after :slight_smile:

This wasn’t really answered. What I do is give the users a checkbox which when checked will force the historical chart to update regularly. Add a checkbox and a timer set to trigger as often as you want the chart to refresh (say 10 seconds). Then put the following code in the timer’s propertyChange event:

if event.propertyName == 'value':
	if event.newValue == 0:
		chkAutoscroll = event.source.parent.getComponent('chkAutoscroll')
		if chkAutoscroll.selected:
			chart = event.source.parent.getComponent('Easy Chart')
			startDate = chart.startDate
			endDate = chart.endDate
			range = system.date.secondsBetween(startDate, endDate)
			chart.endDate = system.date.now()
			chart.startDate = system.date.addSeconds(chart.endDate, -range)

This lets you keep the chart in historical mode but also lets you force it to display the latest data. You may also want to update the outerRangeStart and outerRangeEnd properties to make the timeline update also.

2 Likes