i'm reading data serial port , displaying in ms-chart control. don't know have in chart area 5 vertical bars in total (1 second apart) -> total of 5 seconds data in chart area , have no. of seconds displayed on x axis.
` timer = new timer(); timer.tick += timer_tick; timer.interval = 100; chart1.chartareas[0].axisy.maximum = 1024; chart1.chartareas["chartarea1"].axisy.majorgrid.enabled = false; private void timer_tick(object sender, eventargs e) { string data; data = _port.readexisting(); var datablocks = data.split('\n'); foreach (var block in datablocks) { var numbers = block.split(new [] {' '}, stringsplitoptions.removeemptyentries); (int = 0; < numbers.length; i++) { double n = double.nan; bool ok = double.tryparse(numbers[i], out n); if (ok) { if (n > 30) { chart1.series[i].points.addxy(x, n); if (chart1.series[0].points.count > 700) chart1.series[0].points.removeat(0); } } } } }`
Comments
Post a Comment