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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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.