views:

27

answers:

0

In a similar approach to this question, I am looking for a way to plot data points on to a view in Android. Preferably, a library which will do this for arbitrary-ranged input, as well as allow panning and zooming (via pinch or zoom bar).

Right now, I have subclass-ed a view which does the following normalization:

for(int i = 0; i < data.length;++i) {
  if(i%2==0)
    data[i] = 
      (_data[i]-minA)/(maxA-minA) *
      View.MeasureSpec.getSize(this.widthMeasureSpec);
  else
    _data[i] =
      (_data[i]-minS)/(maxS-minS) *
      View.MeasureSpec.getSize(this.heightMeasureSpec);
}

and a call in onDraw() to the drawPoints method of a canvas (also, I update this.widthMeasureSpec and this.heightMeasureSpec in onMeasure()).

This is with minA/maxA as the bounds for my independent variable and minS/maxS as the bounds for my dependant variable.

This works fine for displaying the data, but I am hoping someone else has solved the problem of drawing the axes and panning/zooming.

I have ~150,000 data points, and I would prefer to keep these as floats to save half the memory. I don't know how big decimal numbers are in JavaScript, but I really don't want to resort to passing data in through JavaScript for the Google Charts API or an HTML-based solution for memory's sake.

I'm running this on a MyTouch 3g (the original, before 3.5mm jack and it's RAM upgrade), so performance is an issue. I'd like to release the final project under the GPLv3, so this excludes GraphView.

The graphs are of the same type as this, so any optimization by excluding points that are too close together to show up on screen would definitely make a difference.