I am trying to build a real-time scatter chart where data flow comes vertically. Whenever new data comes, it will add on top of the old data, so that it looks like data shifts down, unlike regular charts where data shifts horizontally.
The Y-axis shows when the data comes and the X-axis is the number of data (5k for this example) I take every 50ms to fill my array (chart timer interval). The whole data fills the array in 200 ms and then displays. The problem is that even though I give changing data to Y-axis when new data comes, it adds up horizontally. Scatter points look like a bar since the data comes fast. I tried to keep the time interval at 10 seconds on the Y-axis.
I checked the previously asked questions however I couldn't find a case similar to mine.
The code piece that plots the chart:
private void Plot() {
if (plot_data != null) {
for (int i = 0; i < plot_data.Length; i++) {
DateTime now = DateTime.Now;
int s = now.Second; // dispay Y axis in seconds
MyChart.Series[0].Points.AddXY(
i, s); // i -> data, s->time of the data coming
}
plot_data = null;
}
}
The code piece that shows chart settings:
MyChart.ChartAreas[0].AxisY.IsStartedFromZero = false;
MyChart.ChartAreas[0].AxisY.IntervalType = DateTimeIntervalType.Seconds;
MyChart.ChartAreas[0].AxisY.Interval = 10;
Axis yaxis = MyChart.ChartAreas[0].AxisY;
// yaxis.Maximum = yaxis.Minimum + 10;
MyChart.Series[0].YValueType = ChartValueType.Auto;
MyChart.ChartAreas[0].AxisY.LabelStyle.Format = "HH:mm:ss";
And the chart looks like this: (adds 5k horizontally)
What I try to achieve:
Can someone help me to achieve this, please?