Search code examples
memoryoptimizationgraphachartengine

Remove previus data from live-graph with AChartEngine


I have a real-time graph (like ECG graph). I need to display a range of 50 X. Whenever I receive a data, this increments X's value (0,1,2,etc), when i exceed 50th value, i need to display 1-51,2-52,etc values. So far everything it's ok, but i need to remove from memory the oldest values to lighten the app, for example if I'm displaying values from 35 to 85 i I would like to remove 0-34 values that they aren't displayed in graph, it's possible ? Thanks.


Solution

  • Set the limit as 50 and add a condition to remove the first values.

    private int MAX_SIZE = 50;
    

    Now add the below code to remove the initial value

    if(xySeries0.getItemCount()==50)
      xySeries0.remove(0);