SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

1
0

Hi, i have follow the guide to create a chart but i would insert data every 1 second in a Line chart… i have do it but this is the result.

Version
1.2.0.1455
Attachments
Images
  • Andrew
    That’s really strange. Can you share your code how you are Appending to the DataSeries please?
  • Paolo Mastrangelo
    Shared :)
  • You must to post comments
1
1

Hi Paolo,

I took a look on your code and found the problem in insertData() method:

 public void insertData() {
    Random random = new Random();

    long xValue = new Date().getTime() + DateIntervalUtil.fromDays(day);
    xValues.add(new Date(xValue));
    yValues.add(random.nextDouble());

    //the data values can be appended to the DataSeries
    dataSeries.append(xValues, yValues);
    day++;

    setZoomExtents(chartSurface_1);
}

When you append xValues and yValues they contain all previously added values. So first call of insertData() will append 1 data point, second will append 2 points(1 from previous call and 1 new data point), third call will append 3 points(2 from previous call and 1 new data point) and so on.

To fix this issue you just need to clear xValues/yValues collection before adding new points:

xValues.clear(); 
yValues.clear();

Hope it helps!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.