-2

I have a simple chart that prints values read by a photoresistor. Also the chart prints 2 thresholds. My problem is that when more than 300 or 400 points are printed in the chart, it becomes quite unreadable (extraordinarily difficult to read or comprehend all the values printed).

Look at this:

enter image description here

I thought that using an incremental counter and doing this:

if (i > 300) {
   chart1.Invoke(new Action(() => {chart1.Series[0].Points.Clear(); }));
   chart1.Invoke(new Action(() => { chart1.Series[1].Points.Clear(); }));
   chart1.Invoke(new Action(() => { chart1.Series[2].Points.Clear(); }));
   i = 0;
}

The problem is solved as my chart becomes empty and readable again, but I don't want to clear and lose all my previous data.

What alternative solutions can I try so my data won't be deleted, but keeping my chart readable?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Keka Bron
  • 419
  • 4
  • 17
  • Becuase you didn't explain what "unreadable" means ... it pretty obvious that it will looks bad if you wana put 400 points in less than 400 pixels (especially if line has thickness more than 1px) – Selvin Jan 01 '19 at 18:05
  • @Selvin thanks for the explanation, try to remember that although it is not mandatory, the Exchange community recommends to explain why you down vote a post [link here](https://meta.stackexchange.com/questions/135/encouraging-people-to-explain-downvotes) so we can all improve our posts... – Keka Bron Jan 01 '19 at 18:11
  • You may look into setting up a scale view window. A few [examples](https://stackoverflow.com/search?q=user%3A3152130+chart+zoom) – TaW Jan 01 '19 at 20:16

1 Answers1

0

When you go to add a new point, check if you have more than 300 points. If you do, then remove the oldest point and add the newest one.

if (chart1.Series[0].Points.Count > 300)
{
    chart1.Series[0].Points.RemoveAt(0);
}

Then add your new point.

Baddack
  • 1,947
  • 1
  • 24
  • 33