Could you please tell me how I can get the chart to autoscroll as new data is added in realtime on a non FIFO Time Axis?
I have seen you example using a numeric axis in your examples using SciStockChart which has a XAxisVisibleRange that you bind onto
if (XVisibleRange.Max > ds0.Count)
{
var existingRange = _xVisibleRange;
var newRange = new IndexRange(existingRange.Min + 1, existingRange.Max + 1);
XVisibleRange = newRange;
}
But I am not using a stock chart, and am using a time Axis
I thought it would have been sometthng like
IRange range = XAxis.VisibleRange;
if (endTime > (DateTime)XAxis.VisibleRange.Max)
{
TimeSpan ts = endTime - startTime;
var existingRange = _xAxis.VisibleRange;
var newRange = new IndexRange((DateTime)existingRange.Min + ts, (DateTime)existingRange.Max + ts);
XVisibleRange = newRange;
}
there is also a problem that it won’t let me get at XAxis.VisibleRange as it says it was created on different thread. I have tried using BeginInvoke etc but it still complains about it being on a different thread
- wilx asked 10 years ago
- You must login to post comments
Update: Jan 2015
We’ve added another example ‘How to create a Scrolling Strip Chart in SciChart‘ which uses a similar technique to above to manipulate VisibleRange and achieve a scrolling StripChart effect that works with modifiers, and without FIFO DataSeries.
Hope this helps people looking for similar solutions!
Best regards,
Andrew
- Andrew Burnett-Thompson answered 8 years ago
- You must login to post comments
Problem Solved I think
Ok I have sorted it myself, the problem was that I wasn’t using the right dispatcher, I needed to use the one from the application
void UpdateXScaleForScroll()
{
DateTime VisMax = (DateTime)XAxis.VisibleRange.Max;
DateTime ActMax = (DateTime)SeriesSource[0].DataSeries.XMax;
if (ActMax > VisMax)
{
DateRange range = (DateRange)XAxis.VisibleRange;
TimeSpan ts = ActMax - VisMax;
DateRange existingRange = (DateRange)_xAxis.VisibleRange;
DateRange newRange = new DateRange((DateTime)existingRange.Min + ts, (DateTime)existingRange.Max + ts);
XAxis.VisibleRange = newRange;
}
}
Call in my timer event
if (Application.Current != null)
{
Application.Current.Dispatcher.Invoke(new Action(UpdateXScaleForScroll));
}
- wilx answered 10 years ago
- Glad you got this sorted. Yes - any DependencyProperty in SciChart must be called on the UI thread. The DataSeries are not DependencyObjects so feel free to Append on background threads! Best regards, Andrew
- You must login to post comments
Please login first to submit.