androidplot Get Y Value in Series From Touch -
so far can y value of touch on graph so.
mspeedplot.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { pointf click = new pointf(event.getx(),event.gety()); if ( mspeedplot.getgraphwidget().containspoint( click )) { log.d("hof","plot x: "+distancevalue.frommetres(mspeedplot.getxval(click).doublevalue()).km()+"km "+" y: "+mspeedplot.getyval(click)+"km/h"); } return false; } });
what want instead of return y value of touch was, want y value of series plotted on graph corresponds x value.
any way this?
ok solved it.
i use original number[]
used populate simplexyseries
. has x , y values interleaved i'm going need someway of finding index of x value in number[]
have retrieved using code in question.
so process data before add number[] splitting data segments of distance due smoothing , aesthetic reasons. find index of value returned touch following.
double xvalue = mspeedplot.getxval(click).doublevalue(); // gives me value of x int index = double.valueof(math.floor(xvalue / distancesegments)).intvalue()*2; log.d("hof","speed index: "+index+" y value: "+speedvalues[index+1]);
i divide xvalue distancesegments because gives how many distance segments used x value. times 2 because in number[]
x y values interleaved multiplying 2 avoids y values.
now have index of x value can find y value adding 1 index because values interleaved know value after x corresponding y.
Comments
Post a Comment