Delete datas from chart series, after adding them on a chart

  • In the code script, i got datas from queue and add them into chart via series. Let say we have 10 data. When im adding the, i want to delete the first one. So, for showing new items on a chart, i should delete the old ones. How can i do such thing?

    static float q_x;
          double num=queue.dequeue();
          q_x += 0.1;
          series->append(q_x, num);
          qDebug() << q_x << num;

  • Lifetime Qt Champion

    @suslucoder There are several remove(...) methods in
    Did you check that?

  • @jsulm yes, i've checked them. I tried chart->series().removeFirst();

    But i cant decide where should it placed?
    It shoud remove after updating the chart with a new data, but when i placed it after chart->update, there are no lines in chart. I couldnt understand

  • @suslucoder
    Since your code only appends one point at a time, if you remove one point in the same place it will go empty.

    If you want to do something about

    When im adding the, i want to delete the first one.

    you need to write code to do that.

  • @JonB Hmmmm, i got. actually what i want to do is scrolling my chart. I have about 20 point, and i cant see all of them on the secreen. It shows just up to the size of the axis, and the others cant seen on the secreen. Ekran görüntüsü 2021-01-06 171507.png
    There are too many datas on the right but we cannot see.

Log in to reply