I am trying to develop a realtime moving chart which reads data and plots. It has four channels. Both X and Y axis intervals are dynamic. ie, required to change the axis interval runtime so that graph plots accordingly.
I implemetd it. Y axis is ok. As it is an moving chart I need to reset the visible range so as to move the chart along X axis . Even if I change the interval of X axis, when I reset the visible it changes to old value.
Following is the code:
On Load:
double SclX=10; // no of intervals in x axis(major ticks)
sciChartSurface.XAxis.AutoTicks = false;
sciChartSurface.XAxis.AutoRange = AutoRange.Never;
sciChartSurface.XAxis.MajorDelta = 100; //Convert.ToDouble(trackFactorX[XCur, 1])
sciChartSurface.XAxis.MinorDelta = 20; //((Convert.ToDouble(trackFactorX[XCur, 1]) /SclX)*2)
XCurMin = 100; // Convert.ToDouble(trackFactorX[XCur, 1]);
XCurMax = 1000; //SclX * Convert.ToDouble(trackFactorX[XCur, 1]);
sciChartSurface.XAxis.VisibleRange = new DoubleRange(XCurMin, XCurMax );
Resetting visible range to implement moving chart
timer.Interval = TimeSpan.FromMilliseconds(1);
timer.Tick += (s, e) =>
{
if (i > XCurMax)
{
XCurMin = XCurMin + Convert.ToDouble(trackFactorX[XCur, 1]);
XCurMax = XCurMin + (SclX * Convert.ToDouble(trackFactorX[XCur, 1]));
sciChartSurface.XAxis.VisibleRange = new DoubleRange(XCurMin, XCurMax);
}
};
Changing interval from 100 to 200 (button click)
sciChartSurface.XAxis.AutoTicks = false;
sciChartSurface.XAxis.MajorDelta = 200; //Convert.ToDouble(trackFactorX[XCur, 1]);
sciChartSurface.XAxis.MinorDelta = 40; // ((Convert.ToDouble(trackFactorX[XCur, 1]) / SclX) * 2);
XCurMin = XCurMin;
XCurMax = XCurMin + (SclX * Convert.ToDouble(trackFactorX[XCur, 1]));
sciChartSurface.XAxis.VisibleRange = new DoubleRange(XCurMin, XCurMax);
Please check any thing else is required.
- Sophiya K asked 5 years ago
- You must login to post comments
I am not sure what the problem is / or fully understand the question, however you seem to be wanting to make a Strip Chart with SciChart WPF (a chart which scrolls automatically when new data arrives).
We have a KB article on how to do this here: How to Create a Scrolling Strip Chart in SciChart?
And also a code sample here: https://github.com/ABTSoftware/SciChart.WPF.Examples/tree/master/v5.x/Sandbox/UsefulExamples/Examples/StripChart
Please let me know if this helps,
Best regards
Andrew
- Andrew Burnett-Thompson answered 5 years ago
- You must login to post comments
Please login first to submit.