2

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) enter image description here

What I try to achieve:

enter image description here

Can someone help me to achieve this, please?

Deniz
  • 378
  • 3
  • 16
  • What ChartType do you use? For Point (or Line) you are free to set any coordinates you want and can either set the axis view or remove points as you please to get the vertical scrolling effect.. [Here](https://stackoverflow.com/questions/50076045/chart-auto-scroll-oscilloscope-effect/50077332#50077332) are examples for horizontal scrolling that should work for vertical types as well.. – TaW Oct 10 '22 at 08:50
  • @TaW I use a fast point chart – Deniz Oct 10 '22 at 10:23
  • Well that ought to work the same. Do note, that FastPoint (and FastLine) lack a few adornments but for the effect you seek they should work just as well.. Did you try to adapt the code in my link? – TaW Oct 10 '22 at 12:14
  • @TaW I managed to get the data vertically, I checked your link and tried to apply 2nd solution. However, whenever I try to remove points, it distorts X-axis. I am working on that. – Deniz Oct 11 '22 at 07:19
  • By default all sorts of things in MSChart are set to 'automatic' and therefore removing x-points from the left or right may change the scale. Better take control of it.. – TaW Oct 11 '22 at 11:01

0 Answers0