The real-time graph only shows the data of the last minute on the x-axis, and the VisibleRange property setting is invalid
private void InitializeChart()
{
for (int i = 0; i < 50; i++)
{
var dataSeries = new XyDataSeries<DateTime, double> { FifoCapacity = 10 };
Color color = Color.FromArgb(0xAA, (byte)random.Next(1, 256), (byte)random.Next(1, 256), (byte)random.Next(1, 256));
var lineSeries = new FastLineRenderableSeries()
{
DataSeries = dataSeries,
StrokeThickness = 2,
Stroke = color
};
sciChart.RenderableSeries.Add(lineSeries);
fastLines.Add(dataSeries);
}
}
private void StartTimer()
{
var timer = new Timer(1000);
timer.Elapsed += (sender, e) =>
{
Dispatcher.Invoke(() =>
{
var currentDate = DateTime.Now;
for (int i = 0; i < fastLines.Count; i++)
{
var xAxis = sciChart.XAxes.OfType().FirstOrDefault();
if (xAxis != null&& xAxis.DataRange!=null)
{
var newRange = new DateRange(currentDate.AddSeconds(-60), currentDate);
fastLines[i].XRange.Min = newRange.Min;
//xAxis.VisibleRange = newRange;
Application.Current.Dispatcher.BeginInvoke((Action)(() =>
{
xAxis.InvalidateElement();
}));
sciChart.ZoomExtents();
}
if (fastLines[i].Count > 5 &&i>40)
{
break;
}
double y = (i + 1);
fastLines[i].Append(currentDate, y);
}
});
};
timer.Start();
}
- jyj jyj asked 2 months ago
- You must login to post comments
Hi,
Thanks for your inquiry.
Please accept my apologies for the late response.
Unfortunately, it’s not clear enough what are you trying to achieve.
We have a couple of real-time examples in our WPF Examples Suite that should help you though. Here are the corresponding links:
WPF Chart FIFO 1 billion points demo – SciChart
WPF Realtime Scrolling Charts with FIFO – SciChart
WPF Realtime Ticking Stock Charts – SciChart
Hope this helps.
Otherwise please provide us with a more detailed description of your requirements.
Kind regards,
Lex,
SciChart Technical Support Engineer
- Lex answered 2 months ago
- You must login to post comments
My requirement is that initially, for example, there are 10 curves drawn in parallel on the interface. After drawing for a period of time, some of them, including 5, stop. If 50 points have been drawn so far, the remaining 5 will continue to be drawn on the screen. I only want to display the last 100 points on the screen because the 5 curves that stopped in the front will never meet my previous condition if they are not drawn again. Therefore, I increased the time range value and only displayed the last hour without taking effect
- jyj jyj answered 2 months ago
- last edited 4 weeks ago
- You must login to post comments
You can run my previous code to clearly identify my issue
- jyj jyj answered 2 months ago
- last edited 4 weeks ago
- You must login to post comments
Please login first to submit.