For my chart, I create a TimeSpanAxisViewModel with a VisibleRangeLimit like this…
VisibleRange = new TimeSpanRange(new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 30))
VisibleRangeLimit = new TimeSpanRange(new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 30))
AutoRange = AutoRange.Never
Which properly shows the chart as having 30 seconds of time. Data is added to the chart and it displays as expected.
However, once that data reaches the 30-second limit I’m trying to increase the range by 30 more seconds.
I have a timer that evaluates the elapsed time of a Stopwatch and when that Stopwatch is greater than the current limit (30 seconds) I add to the maximum limit.
Kind of like this…
// If the stopwatch is greater than current range
if (MyStopwatch.Elapsed.TotalSeconds > VisibleRangeSeconds) {
VisibleRangeSeconds += 30;
TimeSpan minimumTime = new TimeSpan(0);
TimeSpan maximumTime = new TimeSpan(0, 0, VisibleRangeSeconds);
XAxes[0].VisibleRange = new TimeSpanRange(min: minimumTime, max: maximumTime);
XAxes[0].VisibleRangeLimit = new TimeSpanRange(min: minimumTime, max: maximumTime);
MySciChart.ChartModifier.ParentSurface.InvalidateElement();
}
I also noticed that VisibleRangeLimit was being updated after the Stopwatch became longer but VisibleRange was staying the same. It wasn’t being updated and I’m not sure why.
What could I be missing that would make the chart grow to the new maximum time?
- Greg Knox asked 6 years ago
- last edited 6 years ago
- You must login to post comments
From the code sample you’ve given me, it is possible that by setting VisibleRange before VisibleRangeLimit, the chart won’t update to the new desired range (as it’s outside the limit).
I can’t be sure, I haven’t tested this exact combination.
However, I can say there are many examples close to what you want in our Examples Suite, and one in particular here:
How to Create a Scrolling Strip Chart in SciChart?
Code for the example is here.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 6 years ago
- You must login to post comments
Setting the VisibleRange before VisibleRangeLimit was the exact problem. Now, everything works as expected. Thanks so much!
- Greg Knox answered 6 years ago
- That pesky VisibleRangeLimit, limiting the visible range like that! Hah! Just kidding, thanks and have a good day :)
- You must login to post comments
Please login first to submit.