use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class YAxisRendererHorizontalBarChart method computeAxis.
/**
* 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
*/
@Override
public void computeAxis(float yMin, float yMax, boolean inverted) {
// zoom / contentrect bounds)
if (mViewPortHandler.contentHeight() > 10 && !mViewPortHandler.isFullyZoomedOutX()) {
MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop());
MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop());
if (!inverted) {
yMin = (float) p1.x;
yMax = (float) p2.x;
} else {
yMin = (float) p2.x;
yMax = (float) p1.x;
}
MPPointD.recycleInstance(p1);
MPPointD.recycleInstance(p2);
}
computeAxisValues(yMin, yMax);
}
use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class BarLineChartBase method centerViewToAnimated.
/**
* 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");
}
}
use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class BarLineChartBase method getValuesByTouchPoint.
/**
* Returns a recyclable MPPointD instance
* Returns the x and y values in the chart at the given touch point
* (encapsulated in a MPPointD). This method transforms pixel coordinates to
* coordinates / values in the chart. This is the opposite method to
* getPixelForValues(...).
*
* @param x
* @param y
* @return
*/
public MPPointD getValuesByTouchPoint(float x, float y, AxisDependency axis) {
MPPointD result = MPPointD.getInstance(0, 0);
getValuesByTouchPoint(x, y, axis, result);
return result;
}
use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class BarLineChartBase method moveViewToAnimated.
/**
* This will move the left side of the current viewport to the specified x-value
* and center the viewport to the y value animated.
* This also refreshes the chart by calling invalidate().
*
* @param xValue
* @param yValue
* @param axis
* @param duration the duration of the animation in milliseconds
*/
@TargetApi(11)
public void moveViewToAnimated(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();
Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler, xValue, 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 moveViewToAnimated(...) on API level < 11");
}
}
use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class CandleStickChartRenderer method drawHighlighted.
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
CandleData candleData = mChart.getCandleData();
for (Highlight high : indices) {
ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex());
if (set == null || !set.isHighlightEnabled())
continue;
CandleEntry e = set.getEntryForXValue(high.getX(), high.getY());
if (!isInBoundsX(e, set))
continue;
float lowValue = e.getLow() * mAnimator.getPhaseY();
float highValue = e.getHigh() * mAnimator.getPhaseY();
float y = (lowValue + highValue) / 2f;
MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), y);
high.setDraw((float) pix.x, (float) pix.y);
// draw the lines
drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
}
}
Aggregations