Search in sources :

Example 1 with IShapeRenderer

use of com.github.mikephil.charting.renderer.scatter.IShapeRenderer in project MPAndroidChart by PhilJay.

the class ScatterChartRenderer method drawDataSet.

protected void drawDataSet(Canvas c, IScatterDataSet dataSet) {
    ViewPortHandler viewPortHandler = mViewPortHandler;
    Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());
    float phaseY = mAnimator.getPhaseY();
    IShapeRenderer renderer = dataSet.getShapeRenderer();
    if (renderer == null) {
        Log.i("MISSING", "There's no IShapeRenderer specified for ScatterDataSet");
        return;
    }
    int max = (int) (Math.min(Math.ceil((float) dataSet.getEntryCount() * mAnimator.getPhaseX()), (float) dataSet.getEntryCount()));
    for (int i = 0; i < max; i++) {
        Entry e = dataSet.getEntryForIndex(i);
        mPixelBuffer[0] = e.getX();
        mPixelBuffer[1] = e.getY() * phaseY;
        trans.pointValuesToPixel(mPixelBuffer);
        if (!viewPortHandler.isInBoundsRight(mPixelBuffer[0]))
            break;
        if (!viewPortHandler.isInBoundsLeft(mPixelBuffer[0]) || !viewPortHandler.isInBoundsY(mPixelBuffer[1]))
            continue;
        mRenderPaint.setColor(dataSet.getColor(i / 2));
        renderer.renderShape(c, dataSet, mViewPortHandler, mPixelBuffer[0], mPixelBuffer[1], mRenderPaint);
    }
}
Also used : IShapeRenderer(com.github.mikephil.charting.renderer.scatter.IShapeRenderer) Entry(com.github.mikephil.charting.data.Entry) Transformer(com.github.mikephil.charting.utils.Transformer) ViewPortHandler(com.github.mikephil.charting.utils.ViewPortHandler)

Aggregations

Entry (com.github.mikephil.charting.data.Entry)1 IShapeRenderer (com.github.mikephil.charting.renderer.scatter.IShapeRenderer)1 Transformer (com.github.mikephil.charting.utils.Transformer)1 ViewPortHandler (com.github.mikephil.charting.utils.ViewPortHandler)1