Search code examples
androidtimechartssurfaceview

surfaceview time chart using drawline


I am trying to draw a simple dynamic line (time chart refreshed every 0.25 seconds) in my SurfaceView

for (int i=0; i<100; i++) { 
canvas.drawLine(array_of_x[i],array_of_y[i],array_of_x[i+1], array_of_y[i+1],mPaint);
}

However, it shows all past lines (I want to show only the current line); I tried invalidate() but it does not seem to do the trick.


Solution

  • try :

    Canvas.drawColor(Color.WHITE) 
    

    or whatever color you want to clear your Canvas with before drawing next line. Hope it helps.