com.github.mikephil.charting.utils.PointD Java Examples
The following examples show how to use
com.github.mikephil.charting.utils.PointD.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YAxisRenderer.java From iMoney with Apache License 2.0 | 6 votes |
/** * Computes the axis values. * * @param yMin - the minimum y-value in the data object for this axis * @param yMax - the maximum y-value in the data object for this axis */ public void computeAxis(float yMin, float yMax) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) { PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); if (!mYAxis.isInverted()) { yMin = (float) p2.y; yMax = (float) p1.y; } else { yMin = (float) p1.y; yMax = (float) p2.y; } } computeAxisValues(yMin, yMax); }
Example #2
Source File: YAxisRendererHorizontalBarChart.java From iMoney with Apache License 2.0 | 6 votes |
/** * Computes the axis values. * * @param yMin - the minimum y-value in the data object for this axis * @param yMax - the maximum y-value in the data object for this axis */ public void computeAxis(float yMin, float yMax) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentHeight() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (!mYAxis.isInverted()) { yMin = (float) p1.x; yMax = (float) p2.x; } else { yMin = (float) p2.x; yMax = (float) p1.x; } } computeAxisValues(yMin, yMax); }
Example #3
Source File: BarLineChartBase.java From Notification-Analyser with MIT License | 6 votes |
/** * Returns the x and y values in the chart at the given touch point * (encapsulated in a PointD). This method transforms pixel coordinates to * coordinates / values in the chart. This is the opposite method to * getPixelsForValues(...). * * @param x * @param y * @return */ public PointD getValuesByTouchPoint(float x, float y) { // create an array of the touch-point float[] pts = new float[2]; pts[0] = x; pts[1] = y; Matrix tmp = new Matrix(); // invert all matrixes to convert back to the original value mMatrixOffset.invert(tmp); tmp.mapPoints(pts); mMatrixTouch.invert(tmp); tmp.mapPoints(pts); mMatrixValueToPx.invert(tmp); tmp.mapPoints(pts); double xTouchVal = pts[0]; double yTouchVal = pts[1]; return new PointD(xTouchVal, yTouchVal); }
Example #4
Source File: BarLineChartBase.java From Stayfit with Apache License 2.0 | 6 votes |
/** * This will move the left side of the current viewport to the specified x-position * and center the viewport to the specified y-position animated. * This also refreshes the chart by calling invalidate(). * * @param xIndex * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void moveViewToAnimated(float xIndex, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { PointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float valsInView = getDeltaY(axis) / mViewPortHandler.getScaleY(); Runnable job = new AnimatedMoveViewJob(mViewPortHandler, xIndex, yValue + valsInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); } else { Log.e(LOG_TAG, "Unable to execute moveViewToAnimated(...) on API level < 11"); } }
Example #5
Source File: BarLineChartBase.java From Stayfit with Apache License 2.0 | 6 votes |
/** * This will move the center of the current viewport to the specified * x-value and y-value animated. * * @param xIndex * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void centerViewToAnimated(float xIndex, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { PointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float valsInView = getDeltaY(axis) / mViewPortHandler.getScaleY(); float xsInView = getXAxis().getValues().size() / mViewPortHandler.getScaleX(); Runnable job = new AnimatedMoveViewJob(mViewPortHandler, xIndex - xsInView / 2f, yValue + valsInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); } else { Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11"); } }
Example #6
Source File: YAxisRendererHorizontalBarChart.java From NetKnight with Apache License 2.0 | 6 votes |
/** * Computes the axis values. * * @param yMin - the minimum y-value in the data object for this axis * @param yMax - the maximum y-value in the data object for this axis */ public void computeAxis(float yMin, float yMax) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentHeight() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (!mYAxis.isInverted()) { yMin = (float) p1.x; yMax = (float) p2.x; } else { yMin = (float) p2.x; yMax = (float) p1.x; } } computeAxisValues(yMin, yMax); }
Example #7
Source File: YAxisRenderer.java From NetKnight with Apache License 2.0 | 6 votes |
/** * Computes the axis values. * * @param yMin - the minimum y-value in the data object for this axis * @param yMax - the maximum y-value in the data object for this axis */ public void computeAxis(float yMin, float yMax) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) { PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); if (!mYAxis.isInverted()) { yMin = (float) p2.y; yMax = (float) p1.y; } else { yMin = (float) p1.y; yMax = (float) p2.y; } } computeAxisValues(yMin, yMax); }
Example #8
Source File: YAxisRenderer.java From Stayfit with Apache License 2.0 | 6 votes |
/** * Computes the axis values. * * @param yMin - the minimum y-value in the data object for this axis * @param yMax - the maximum y-value in the data object for this axis */ public void computeAxis(float yMin, float yMax) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) { PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom()); if (!mYAxis.isInverted()) { yMin = (float) p2.y; yMax = (float) p1.y; } else { yMin = (float) p1.y; yMax = (float) p2.y; } } computeAxisValues(yMin, yMax); }
Example #9
Source File: YAxisRendererHorizontalBarChart.java From Stayfit with Apache License 2.0 | 6 votes |
/** * Computes the axis values. * * @param yMin - the minimum y-value in the data object for this axis * @param yMax - the maximum y-value in the data object for this axis */ public void computeAxis(float yMin, float yMax) { // calculate the starting and entry point of the y-labels (depending on // zoom / contentrect bounds) if (mViewPortHandler.contentHeight() > 10 && !mViewPortHandler.isFullyZoomedOutX()) { PointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop()); PointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop()); if (!mYAxis.isInverted()) { yMin = (float) p1.x; yMax = (float) p2.x; } else { yMin = (float) p2.x; yMax = (float) p1.x; } } computeAxisValues(yMin, yMax); }
Example #10
Source File: BarLineChartBase.java From NetKnight with Apache License 2.0 | 6 votes |
/** * This will move the left side of the current viewport to the specified x-position * and center the viewport to the specified y-position animated. * This also refreshes the chart by calling invalidate(). * * @param xIndex * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void moveViewToAnimated(float xIndex, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { PointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float valsInView = getDeltaY(axis) / mViewPortHandler.getScaleY(); Runnable job = new AnimatedMoveViewJob(mViewPortHandler, xIndex, yValue + valsInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); } else { Log.e(LOG_TAG, "Unable to execute moveViewToAnimated(...) on API level < 11"); } }
Example #11
Source File: BarLineChartBase.java From NetKnight with Apache License 2.0 | 6 votes |
/** * This will move the center of the current viewport to the specified * x-value and y-value animated. * * @param xIndex * @param yValue * @param axis * @param duration the duration of the animation in milliseconds */ @TargetApi(11) public void centerViewToAnimated(float xIndex, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { PointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); float valsInView = getDeltaY(axis) / mViewPortHandler.getScaleY(); float xsInView = getXAxis().getValues().size() / mViewPortHandler.getScaleX(); Runnable job = new AnimatedMoveViewJob(mViewPortHandler, xIndex - xsInView / 2f, yValue + valsInView / 2f, getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration); addViewportJob(job); } else { Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11"); } }
Example #12
Source File: BarLineChartBase.java From Notification-Analyser with MIT License | 5 votes |
/** * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * * @param x * @param y * @return */ public PointD getPixelsForValues(float x, float y) { float[] pts = new float[] { x, y }; transformPointArray(pts); return new PointD(pts[0], pts[1]); }
Example #13
Source File: BarLineChartBase.java From iMoney with Apache License 2.0 | 5 votes |
/** * Returns the x and y values in the chart at the given touch point * (encapsulated in a PointD). This method transforms pixel coordinates to * coordinates / values in the chart. This is the opposite method to * getPixelsForValues(...). * * @param x * @param y * @return */ public PointD getValuesByTouchPoint(float x, float y, AxisDependency axis) { // create an array of the touch-point float[] pts = new float[2]; pts[0] = x; pts[1] = y; getTransformer(axis).pixelsToValue(pts); double xTouchVal = pts[0]; double yTouchVal = pts[1]; return new PointD(xTouchVal, yTouchVal); }
Example #14
Source File: BarLineChartBase.java From NetKnight with Apache License 2.0 | 5 votes |
/** * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * * @param x * @param y * @return */ public PointD getPixelsForValues(float x, float y, AxisDependency axis) { float[] pts = new float[]{ x, y }; getTransformer(axis).pointValuesToPixel(pts); return new PointD(pts[0], pts[1]); }
Example #15
Source File: BarLineChartBase.java From NetKnight with Apache License 2.0 | 5 votes |
/** * Returns the x and y values in the chart at the given touch point * (encapsulated in a PointD). This method transforms pixel coordinates to * coordinates / values in the chart. This is the opposite method to * getPixelsForValues(...). * * @param x * @param y * @return */ public PointD getValuesByTouchPoint(float x, float y, AxisDependency axis) { // create an array of the touch-point float[] pts = new float[2]; pts[0] = x; pts[1] = y; getTransformer(axis).pixelsToValue(pts); double xTouchVal = pts[0]; double yTouchVal = pts[1]; return new PointD(xTouchVal, yTouchVal); }
Example #16
Source File: BarLineChartBase.java From NetKnight with Apache License 2.0 | 5 votes |
/** * Zooms by the specified scale factor to the specified values on the specified axis. * * @param scaleX * @param scaleY * @param xValue * @param yValue * @param axis * @param duration */ @TargetApi(11) public void zoomAndCenterAnimated(float scaleX, float scaleY, float xValue, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { PointD origin = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); Runnable job = new AnimatedZoomJob(mViewPortHandler, this, getTransformer(axis), getAxis(axis), mXAxis.getValues().size(), scaleX, scaleY, mViewPortHandler.getScaleX(), mViewPortHandler.getScaleY(), xValue, yValue, (float) origin.x, (float) origin.y, duration); addViewportJob(job); } else { Log.e(LOG_TAG, "Unable to execute zoomAndCenterAnimated(...) on API level < 11"); } }
Example #17
Source File: BarLineChartBase.java From Stayfit with Apache License 2.0 | 5 votes |
/** * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * * @param x * @param y * @return */ public PointD getPixelsForValues(float x, float y, AxisDependency axis) { float[] pts = new float[]{ x, y }; getTransformer(axis).pointValuesToPixel(pts); return new PointD(pts[0], pts[1]); }
Example #18
Source File: BarLineChartBase.java From Stayfit with Apache License 2.0 | 5 votes |
/** * Returns the x and y values in the chart at the given touch point * (encapsulated in a PointD). This method transforms pixel coordinates to * coordinates / values in the chart. This is the opposite method to * getPixelsForValues(...). * * @param x * @param y * @return */ public PointD getValuesByTouchPoint(float x, float y, AxisDependency axis) { // create an array of the touch-point float[] pts = new float[2]; pts[0] = x; pts[1] = y; getTransformer(axis).pixelsToValue(pts); double xTouchVal = pts[0]; double yTouchVal = pts[1]; return new PointD(xTouchVal, yTouchVal); }
Example #19
Source File: BarLineChartBase.java From Stayfit with Apache License 2.0 | 5 votes |
/** * Zooms by the specified scale factor to the specified values on the specified axis. * * @param scaleX * @param scaleY * @param xValue * @param yValue * @param axis * @param duration */ @TargetApi(11) public void zoomAndCenterAnimated(float scaleX, float scaleY, float xValue, float yValue, AxisDependency axis, long duration) { if (android.os.Build.VERSION.SDK_INT >= 11) { PointD origin = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis); Runnable job = new AnimatedZoomJob(mViewPortHandler, this, getTransformer(axis), getAxis(axis), mXAxis.getValues().size(), scaleX, scaleY, mViewPortHandler.getScaleX(), mViewPortHandler.getScaleY(), xValue, yValue, (float) origin.x, (float) origin.y, duration); addViewportJob(job); } else { Log.e(LOG_TAG, "Unable to execute zoomAndCenterAnimated(...) on API level < 11"); } }
Example #20
Source File: BarLineChartBase.java From iMoney with Apache License 2.0 | 5 votes |
/** * Transforms the given chart values into pixels. This is the opposite * method to getValuesByTouchPoint(...). * * @param x * @param y * @return */ public PointD getPixelsForValues(float x, float y, AxisDependency axis) { float[] pts = new float[] { x, y }; getTransformer(axis).pointValuesToPixel(pts); return new PointD(pts[0], pts[1]); }