MappView - LineChart

Hello,

I’ve been using the LineChart in mappView and I’m not sure how to achieve the effect I want.

My data array is 2880 entries long and I am displaying the past 24 hours worth of data (1 data point for every 30 seconds). For the X-axis, I have a LineChartTimeAxis and for the Y-axis, I have a LineChartYAxis with a LineChartGraph widgets attached.

I have shortcut buttons that I wish to lock the viewport to 1hr, 4hr, 8hr, and 24hr options. Changing the TimeAxis to represent these intervals is straightforward (binding the minValue and maxValue), but I’m not sure how to ‘crop’ the data array to match. It seems that reducing numberOfSamples simply chops the display prematurely, but does not affect plotting in relation to the TimeAxis. Is there a way to display just a portion of the data but have it stretch the full length of the graph? The same effect could be possible if I could bind the zoom levels, but that does not seem possible.

Separately from this question, I also have a Timeline widget that I am trying to match with the LineChart. It doesn’t appear there’s a way to get the current zoom level out of the LineChart, so I don’t think this is possible, but I figure I’d ask.

Thanks!

Hi Jonathan,

There are 2 ways to get the results you are looking for.
Since you are collecting and displaying the past 24 hours instead of loading in a 24 hour period of data, you may want to look into using the OnlineChartHDA.
Once you set up this widget it will automatically track the values so you won’t need to collect it on the backend.
The OnlineChartHDA widget has a timespan input that you can use to assign the 1,4,8, and 24 hr options.

However if you want to continue with the LineChart then you will need to sort the data yourself, I don’t believe there is anyway to have the widget do it for you at the moment.
I recommend you have a data array of all the values for the last 24 hours, and another data array just for the chart.
If the customer is viewing 24 hours it is a one to one match, but if it’s 8hrs then you will take a datapoint from the original array and copy it over 3 times (24/8 = 3) into the display array so that when finished the display array only has data from an 8 hour period but it’s blown up to still fill up the full array and your number of samples doesn’t need to change.
You will also need to adjust the timestamps to match.

Also, you’re correct that the zoom level cannot be read out, but you can try to keep track of it. If you are using gesture then this won’t be possible, but if zoom is being controlled by actions (like button presses) you can add an opcua action to the event and try to track it in logic.