use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class ScatterChartRenderer method drawHighlighted.
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
ScatterData scatterData = mChart.getScatterData();
for (Highlight high : indices) {
IScatterDataSet set = scatterData.getDataSetByIndex(high.getDataSetIndex());
if (set == null || !set.isHighlightEnabled())
continue;
final Entry e = set.getEntryForXValue(high.getX(), high.getY());
if (!isInBoundsX(e, set))
continue;
MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), e.getY() * mAnimator.getPhaseY());
high.setDraw((float) pix.x, (float) pix.y);
// draw the lines
drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
}
}
use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class XAxisRenderer method computeAxis.
@Override
public void computeAxis(float min, float max, boolean inverted) {
// zoom / contentrect bounds)
if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutX()) {
MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop());
MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentRight(), mViewPortHandler.contentTop());
if (inverted) {
min = (float) p2.x;
max = (float) p1.x;
} else {
min = (float) p1.x;
max = (float) p2.x;
}
MPPointD.recycleInstance(p1);
MPPointD.recycleInstance(p2);
}
computeAxisValues(min, max);
}
use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class XAxisRendererHorizontalBarChart method computeAxis.
@Override
public void computeAxis(float min, float max, boolean inverted) {
// zoom / contentrect bounds)
if (mViewPortHandler.contentWidth() > 10 && !mViewPortHandler.isFullyZoomedOutY()) {
MPPointD p1 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentBottom());
MPPointD p2 = mTrans.getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop());
if (inverted) {
min = (float) p2.y;
max = (float) p1.y;
} else {
min = (float) p1.y;
max = (float) p2.y;
}
MPPointD.recycleInstance(p1);
MPPointD.recycleInstance(p2);
}
computeAxisValues(min, max);
}
use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class YAxisRenderer method drawZeroLine.
/**
* Draws the zero line.
*/
protected void drawZeroLine(Canvas c) {
int clipRestoreCount = c.save();
mZeroLineClippingRect.set(mViewPortHandler.getContentRect());
mZeroLineClippingRect.inset(0.f, -mYAxis.getZeroLineWidth());
c.clipRect(mZeroLineClippingRect);
// draw zero line
MPPointD pos = mTrans.getPixelForValues(0f, 0f);
mZeroLinePaint.setColor(mYAxis.getZeroLineColor());
mZeroLinePaint.setStrokeWidth(mYAxis.getZeroLineWidth());
Path zeroLinePath = mDrawZeroLinePath;
zeroLinePath.reset();
zeroLinePath.moveTo(mViewPortHandler.contentLeft(), (float) pos.y);
zeroLinePath.lineTo(mViewPortHandler.contentRight(), (float) pos.y);
// draw a path because lines don't support dashing on lower android versions
c.drawPath(zeroLinePath, mZeroLinePaint);
c.restoreToCount(clipRestoreCount);
}
use of com.github.mikephil.charting.utils.MPPointD in project MPAndroidChart by PhilJay.
the class YAxisRendererHorizontalBarChart method drawZeroLine.
@Override
protected void drawZeroLine(Canvas c) {
int clipRestoreCount = c.save();
mZeroLineClippingRect.set(mViewPortHandler.getContentRect());
mZeroLineClippingRect.inset(-mYAxis.getZeroLineWidth(), 0.f);
c.clipRect(mLimitLineClippingRect);
// draw zero line
MPPointD pos = mTrans.getPixelForValues(0f, 0f);
mZeroLinePaint.setColor(mYAxis.getZeroLineColor());
mZeroLinePaint.setStrokeWidth(mYAxis.getZeroLineWidth());
Path zeroLinePath = mDrawZeroLinePathBuffer;
zeroLinePath.reset();
zeroLinePath.moveTo((float) pos.x - 1, mViewPortHandler.contentTop());
zeroLinePath.lineTo((float) pos.x - 1, mViewPortHandler.contentBottom());
// draw a path because lines don't support dashing on lower android versions
c.drawPath(zeroLinePath, mZeroLinePaint);
c.restoreToCount(clipRestoreCount);
}
Aggregations