android - Sync the two mpandroidcharts graphs dragging and zomming -
i using mpandroidchart , have requirement have sync dragging , zooming of 2 graphs, if zoom out, zoom in or drag 1 of 1 graph other graph should zoomed out, zoomed in or dragged same extent on x-axis. example: if drag upper graph 12th point on x-axis lower graph should dragged 12th point on x-axis automatically.
guys need need idea how this, enough familiar mpchartandroid library.
i wrote function this, calling function of drag , scale listener. working perfectly.
private void synccharts(chart mainchart, linechart[] othercharts) { matrix mainmatrix; float[] mainvals = new float[9]; matrix othermatrix; float[] othervals = new float[9]; mainmatrix = mainchart.getviewporthandler().getmatrixtouch(); mainmatrix.getvalues(mainvals); (linechart tempchart : othercharts) { othermatrix = tempchart.getviewporthandler().getmatrixtouch(); othermatrix.getvalues(othervals); othervals[matrix.mscale_x] = mainvals[matrix.mscale_x]; othervals[matrix.mtrans_x] = mainvals[matrix.mtrans_x]; othervals[matrix.mskew_x] = mainvals[matrix.mskew_x]; othermatrix.setvalues(othervals); tempchart.getviewporthandler().refresh(othermatrix, tempchart, true); } }
Comments
Post a Comment