Java Code Examples for com.github.mikephil.charting.data.ScatterData#getDataSetByIndex()

The following examples show how to use com.github.mikephil.charting.data.ScatterData#getDataSetByIndex() . 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: ScatterChartRenderer.java    From iMoney with Apache License 2.0 5 votes vote down vote up
@Override
public void initBuffers() {

    ScatterData scatterData = mChart.getScatterData();

    mScatterBuffers = new ScatterBuffer[scatterData.getDataSetCount()];

    for (int i = 0; i < mScatterBuffers.length; i++) {
        ScatterDataSet set = scatterData.getDataSetByIndex(i);
        mScatterBuffers[i] = new ScatterBuffer(set.getEntryCount() * 2);
    }
}
 
Example 2
Source File: ScatterChartRenderer.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
@Override
public void initBuffers() {

    ScatterData scatterData = mChart.getScatterData();

    mScatterBuffers = new ScatterBuffer[scatterData.getDataSetCount()];

    for (int i = 0; i < mScatterBuffers.length; i++) {
        IScatterDataSet set = scatterData.getDataSetByIndex(i);
        mScatterBuffers[i] = new ScatterBuffer(set.getEntryCount() * 2);
    }
}
 
Example 3
Source File: ScatterChartRenderer.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
@Override
public void initBuffers() {

    ScatterData scatterData = mChart.getScatterData();

    mScatterBuffers = new ScatterBuffer[scatterData.getDataSetCount()];

    for (int i = 0; i < mScatterBuffers.length; i++) {
        IScatterDataSet set = scatterData.getDataSetByIndex(i);
        mScatterBuffers[i] = new ScatterBuffer(set.getEntryCount() * 2);
    }
}
 
Example 4
Source File: ScatterChartRenderer.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@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);
    }
}
 
Example 5
Source File: ScatterChartRenderer.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
@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);
    }
}
 
Example 6
Source File: ScatterChartRenderer.java    From android-kline with Apache License 2.0 4 votes vote down vote up
@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);
    }
}
 
Example 7
Source File: ScatterChartRenderer.java    From android-kline with Apache License 2.0 4 votes vote down vote up
@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);
    }
}
 
Example 8
Source File: ScatterChartRenderer.java    From NetKnight with Apache License 2.0 4 votes vote down vote up
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    ScatterData scatterData = mChart.getScatterData();

    for (Highlight high : indices) {

        final int minDataSetIndex = high.getDataSetIndex() == -1
                ? 0
                : high.getDataSetIndex();
        final int maxDataSetIndex = high.getDataSetIndex() == -1
                ? scatterData.getDataSetCount()
                : (high.getDataSetIndex() + 1);
        if (maxDataSetIndex - minDataSetIndex < 1) continue;

        for (int dataSetIndex = minDataSetIndex;
             dataSetIndex < maxDataSetIndex;
             dataSetIndex++) {

            IScatterDataSet set = scatterData.getDataSetByIndex(dataSetIndex);

            if (set == null || !set.isHighlightEnabled())
                continue;

            int xIndex = high.getXIndex(); // get the
            // x-position


            if (xIndex > mChart.getXChartMax() * mAnimator.getPhaseX())
                continue;

            final float yVal = set.getYValForXIndex(xIndex);
            if (Float.isNaN(yVal))
                continue;

            float y = yVal * mAnimator.getPhaseY();

            float[] pts = new float[]{
                    xIndex, y
            };

            mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);

            // draw the lines
            drawHighlightLines(c, pts, set);
        }
    }
}