/** * This will move the center of the current viewport to the specified * x and y value. * This also refreshes the chart by calling invalidate(). * * @param xValue * @param yValue * @param axis - which axis should be used as a reference for the y axis */ public void centerViewTo(float xValue, float yValue, AxisDependency axis) { float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this); addViewportJob(job); }
/** * This will move the center of the current viewport to the specified * x and y value animated. * * @param xValue * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void centerViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration) { MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); MPPointD.recycleInstance(bounds); }
@Override public void run() { Matrix save = mRunMatrixBuffer; mViewPortHandler.zoom(scaleX, scaleY, save); mViewPortHandler.refresh(save, view, false); float yValsInView = ((BarLineChartBase) view).getAxis(axisDependency).mAxisRange / mViewPortHandler.getScaleY(); float xValsInView = ((BarLineChartBase) view).getXAxis().mAxisRange / mViewPortHandler.getScaleX(); pts[0] = xValue - xValsInView / 2f; pts[1] = yValue + yValsInView / 2f; mTrans.pointValuesToPixel(pts); mViewPortHandler.translate(pts, save); mViewPortHandler.refresh(save, view, false); ((BarLineChartBase) view).calculateOffsets(); view.postInvalidate(); recycleInstance(this); }
/** * This will move the center of the current viewport to the specified * x and y value. * This also refreshes the chart by calling invalidate(). * * @param xValue * @param yValue * @param axis - which axis should be used as a reference for the y axis */ public void centerViewTo(float xValue, float yValue, AxisDependency axis) { float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this); addViewportJob(job); }
/** * This will move the center of the current viewport to the specified * x and y value. * This also refreshes the chart by calling invalidate(). * * @param xValue * @param yValue * @param axis - which axis should be used as a reference for the y axis */ public void centerViewTo(float xValue, float yValue, AxisDependency axis) { float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this); addViewportJob(job); }
/** * This will move the center of the current viewport to the specified * x and y value. * This also refreshes the chart by calling invalidate(). * * @param xValue * @param yValue * @param axis - which axis should be used as a reference for the y axis */ public void centerViewTo(float xValue, float yValue, AxisDependency axis) { float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this); addViewportJob(job); }
/** * This will move the center of the current viewport to the specified * x and y value. * This also refreshes the chart by calling invalidate(). * * @param xValue * @param yValue * @param axis - which axis should be used as a reference for the y axis */ public void centerViewTo(float xValue, float yValue, AxisDependency axis) { float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = MoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this); addViewportJob(job); }
/** * This will move the center of the current viewport to the specified * x and y value animated. * * @param xValue * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void centerViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); MPPointD.recycleInstance(bounds); } else { Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11"); } }
/** * This will move the center of the current viewport to the specified * x and y value animated. * * @param xValue * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void centerViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); MPPointD.recycleInstance(bounds); } else { Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11"); } }
/** * This will move the center of the current viewport to the specified * x and y value animated. * * @param xValue * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void centerViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); MPPointD.recycleInstance(bounds); } else { Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11"); } }
/** * This will move the center of the current viewport to the specified * x and y value animated. * * @param xValue * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void centerViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY(); float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX(); Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler, xValue - xInView / 2f, yValue + yInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); MPPointD.recycleInstance(bounds); } else { Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11"); } }
@Override public void run() { Matrix save = mRunMatrixBuffer; mViewPortHandler.zoom(scaleX, scaleY, save); mViewPortHandler.refresh(save, view, false); float yValsInView = ((BarLineChartBase) view).getAxis(axisDependency).mAxisRange / mViewPortHandler.getScaleY(); float xValsInView = ((BarLineChartBase) view).getXAxis().mAxisRange / mViewPortHandler.getScaleX(); pts[0] = xValue - xValsInView / 2f; pts[1] = yValue + yValsInView / 2f; mTrans.pointValuesToPixel(pts); mViewPortHandler.translate(pts, save); mViewPortHandler.refresh(save, view, false); ((BarLineChartBase) view).calculateOffsets(); view.postInvalidate(); recycleInstance(this); }
@Override public void run() { Matrix save = mRunMatrixBuffer; mViewPortHandler.zoom(scaleX, scaleY, save); mViewPortHandler.refresh(save, view, false); float yValsInView = ((BarLineChartBase) view).getAxis(axisDependency).mAxisRange / mViewPortHandler.getScaleY(); float xValsInView = ((BarLineChartBase) view).getXAxis().mAxisRange / mViewPortHandler.getScaleX(); pts[0] = xValue - xValsInView / 2f; pts[1] = yValue + yValsInView / 2f; mTrans.pointValuesToPixel(pts); mViewPortHandler.translate(pts, save); mViewPortHandler.refresh(save, view, false); ((BarLineChartBase) view).calculateOffsets(); view.postInvalidate(); recycleInstance(this); }
@Override public void run() { Matrix save = mRunMatrixBuffer; mViewPortHandler.zoom(scaleX, scaleY, save); mViewPortHandler.refresh(save, view, false); float yValsInView = ((BarLineChartBase) view).getAxis(axisDependency).mAxisRange / mViewPortHandler.getScaleY(); float xValsInView = ((BarLineChartBase) view).getXAxis().mAxisRange / mViewPortHandler.getScaleX(); pts[0] = xValue - xValsInView / 2f; pts[1] = yValue + yValsInView / 2f; mTrans.pointValuesToPixel(pts); mViewPortHandler.translate(pts, save); mViewPortHandler.refresh(save, view, false); ((BarLineChartBase) view).calculateOffsets(); view.postInvalidate(); recycleInstance(this); }
@Override public void run() { Matrix save = mRunMatrixBuffer; mViewPortHandler.zoom(scaleX, scaleY, save); mViewPortHandler.refresh(save, view, false); float yValsInView = ((BarLineChartBase) view).getAxis(axisDependency).mAxisRange / mViewPortHandler.getScaleY(); float xValsInView = ((BarLineChartBase) view).getXAxis().mAxisRange / mViewPortHandler.getScaleX(); pts[0] = xValue - xValsInView / 2f; pts[1] = yValue + yValsInView / 2f; mTrans.pointValuesToPixel(pts); mViewPortHandler.translate(pts, save); mViewPortHandler.refresh(save, view, false); ((BarLineChartBase) view).calculateOffsets(); view.postInvalidate(); recycleInstance(this); }
chart.getXAxis().setDrawGridLines(false); chart.getAxisLeft().setValueFormatter(new GraphValueFormatter()); chart.getAxisRight().setValueFormatter(new GraphValueFormatter());
protected void setup(Chart<?> chart) { mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); // no description text chart.getDescription().setEnabled(false); // enable touch gestures chart.setTouchEnabled(true); if (chart instanceof BarLineChartBase) { BarLineChartBase mChart = (BarLineChartBase) chart; mChart.setDrawGridBackground(false); // enable scaling and dragging mChart.setDragEnabled(true); mChart.setScaleEnabled(true); // if disabled, scaling can be done on x- and y-axis separately mChart.setPinchZoom(false); YAxis leftAxis = mChart.getAxisLeft(); leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines leftAxis.setTypeface(mTf); leftAxis.setTextSize(8f); leftAxis.setTextColor(Color.DKGRAY); leftAxis.setValueFormatter(new PercentFormatter()); XAxis xAxis = mChart.getXAxis(); xAxis.setTypeface(mTf); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setTextSize(8f); xAxis.setTextColor(Color.DKGRAY); mChart.getAxisRight().setEnabled(false); } }