Search in sources :

Example 11 with MPPointD

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);
    }
}
Also used : Entry(com.github.mikephil.charting.data.Entry) Highlight(com.github.mikephil.charting.highlight.Highlight) IScatterDataSet(com.github.mikephil.charting.interfaces.datasets.IScatterDataSet) MPPointD(com.github.mikephil.charting.utils.MPPointD) ScatterData(com.github.mikephil.charting.data.ScatterData)

Example 12 with MPPointD

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);
}
Also used : MPPointD(com.github.mikephil.charting.utils.MPPointD)

Example 13 with MPPointD

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);
}
Also used : MPPointD(com.github.mikephil.charting.utils.MPPointD)

Example 14 with MPPointD

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);
}
Also used : Path(android.graphics.Path) MPPointD(com.github.mikephil.charting.utils.MPPointD) Paint(android.graphics.Paint)

Example 15 with MPPointD

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);
}
Also used : Path(android.graphics.Path) MPPointD(com.github.mikephil.charting.utils.MPPointD) Paint(android.graphics.Paint)

Aggregations

MPPointD (com.github.mikephil.charting.utils.MPPointD)19 Entry (com.github.mikephil.charting.data.Entry)4 TargetApi (android.annotation.TargetApi)3 Highlight (com.github.mikephil.charting.highlight.Highlight)3 Paint (android.graphics.Paint)2 Path (android.graphics.Path)2 BarData (com.github.mikephil.charting.data.BarData)2 IBarDataSet (com.github.mikephil.charting.interfaces.datasets.IBarDataSet)2 ArrayList (java.util.ArrayList)2 BarEntry (com.github.mikephil.charting.data.BarEntry)1 CandleData (com.github.mikephil.charting.data.CandleData)1 CandleEntry (com.github.mikephil.charting.data.CandleEntry)1 LineData (com.github.mikephil.charting.data.LineData)1 ScatterData (com.github.mikephil.charting.data.ScatterData)1 ICandleDataSet (com.github.mikephil.charting.interfaces.datasets.ICandleDataSet)1 ILineDataSet (com.github.mikephil.charting.interfaces.datasets.ILineDataSet)1 IScatterDataSet (com.github.mikephil.charting.interfaces.datasets.IScatterDataSet)1