Java Code Examples for com.github.mikephil.charting.interfaces.datasets.ILineDataSet#getFillDrawable()

The following examples show how to use com.github.mikephil.charting.interfaces.datasets.ILineDataSet#getFillDrawable() . 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: LineChartRenderer.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) {

        float fillMin = dataSet.getFillFormatter()
                .getFillLinePosition(dataSet, mChart);

        spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin);
        spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin);
        spline.close();

        trans.pathValueToPixel(spline);

        final Drawable drawable = dataSet.getFillDrawable();
        if (drawable != null) {

            drawFilledPath(c, spline, drawable);
        } else {

            drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
        }
    }
 
Example 2
Source File: LineChartRenderer.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) {

        float fillMin = dataSet.getFillFormatter()
                .getFillLinePosition(dataSet, mChart);

        spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin);
        spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin);
        spline.close();

        trans.pathValueToPixel(spline);

        final Drawable drawable = dataSet.getFillDrawable();
        if (drawable != null) {

            drawFilledPath(c, spline, drawable);
        } else {

            drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
        }
    }
 
Example 3
Source File: LineChartRenderer.java    From android-kline with Apache License 2.0 6 votes vote down vote up
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) {

        float fillMin = dataSet.getFillFormatter()
                .getFillLinePosition(dataSet, mChart);

        spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin);
        spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin);
        spline.close();

        trans.pathValueToPixel(spline);

        final Drawable drawable = dataSet.getFillDrawable();
        if (drawable != null) {

            drawFilledPath(c, spline, drawable);
        } else {

            drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
        }
    }
 
Example 4
Source File: LineChartRenderer.java    From android-kline with Apache License 2.0 6 votes vote down vote up
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) {

        float fillMin = dataSet.getFillFormatter()
                .getFillLinePosition(dataSet, mChart);

        spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin);
        spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin);
        spline.close();

        trans.pathValueToPixel(spline);

        final Drawable drawable = dataSet.getFillDrawable();
        if (drawable != null) {

            drawFilledPath(c, spline, drawable);
        } else {

            drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
        }
    }
 
Example 5
Source File: LineChartRenderer.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
protected void drawLinearFill(Canvas c, ILineDataSet dataSet, int minx,
                              int maxx,
                              Transformer trans) {

    Path filled = generateFilledPath(
            dataSet, minx, maxx);

    trans.pathValueToPixel(filled);

    final Drawable drawable = dataSet.getFillDrawable();
    if (drawable != null) {

        drawFilledPath(c, filled, drawable);
    } else {

        drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha());
    }
}
 
Example 6
Source File: LineChartRenderer.java    From NetKnight with Apache License 2.0 6 votes vote down vote up
protected void drawLinearFill(Canvas c, ILineDataSet dataSet, int minx,
                              int maxx,
                              Transformer trans) {

    Path filled = generateFilledPath(
            dataSet, minx, maxx);

    trans.pathValueToPixel(filled);

    final Drawable drawable = dataSet.getFillDrawable();
    if (drawable != null) {

        drawFilledPath(c, filled, drawable);
    } else {

        drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha());
    }
}
 
Example 7
Source File: LineChartRenderer.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
/**
 * Draws a filled linear path on the canvas.
 *
 * @param c
 * @param dataSet
 * @param trans
 * @param bounds
 */
protected void drawLinearFill(Canvas c, ILineDataSet dataSet, Transformer trans, XBounds bounds) {

    final Path filled = mGenerateFilledPathBuffer;

    final int startingIndex = bounds.min;
    final int endingIndex = bounds.range + bounds.min;
    final int indexInterval = 128;

    int currentStartIndex = 0;
    int currentEndIndex = indexInterval;
    int iterations = 0;

    // Doing this iteratively in order to avoid OutOfMemory errors that can happen on large bounds sets.
    do {
        currentStartIndex = startingIndex + (iterations * indexInterval);
        currentEndIndex = currentStartIndex + indexInterval;
        currentEndIndex = currentEndIndex > endingIndex ? endingIndex : currentEndIndex;

        if (currentStartIndex <= currentEndIndex) {
            generateFilledPath(dataSet, currentStartIndex, currentEndIndex, filled);

            trans.pathValueToPixel(filled);

            final Drawable drawable = dataSet.getFillDrawable();
            if (drawable != null) {

                drawFilledPath(c, filled, drawable);
            } else {

                drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha());
            }
        }

        iterations++;

    } while (currentStartIndex <= currentEndIndex);

}
 
Example 8
Source File: LineChartRenderer.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
/**
 * Draws a filled linear path on the canvas.
 *
 * @param c
 * @param dataSet
 * @param trans
 * @param bounds
 */
protected void drawLinearFill(Canvas c, ILineDataSet dataSet, Transformer trans, XBounds bounds) {

    final Path filled = mGenerateFilledPathBuffer;

    final int startingIndex = bounds.min;
    final int endingIndex = bounds.range + bounds.min;
    final int indexInterval = 128;

    int currentStartIndex = 0;
    int currentEndIndex = indexInterval;
    int iterations = 0;

    // Doing this iteratively in order to avoid OutOfMemory errors that can happen on large bounds sets.
    do {
        currentStartIndex = startingIndex + (iterations * indexInterval);
        currentEndIndex = currentStartIndex + indexInterval;
        currentEndIndex = currentEndIndex > endingIndex ? endingIndex : currentEndIndex;

        if (currentStartIndex <= currentEndIndex) {
            generateFilledPath(dataSet, currentStartIndex, currentEndIndex, filled);

            trans.pathValueToPixel(filled);

            final Drawable drawable = dataSet.getFillDrawable();
            if (drawable != null) {

                drawFilledPath(c, filled, drawable);
            } else {

                drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha());
            }
        }

        iterations++;

    } while (currentStartIndex <= currentEndIndex);

}
 
Example 9
Source File: LineChartRenderer.java    From android-kline with Apache License 2.0 5 votes vote down vote up
/**
 * Draws a filled linear path on the canvas.
 *
 * @param c
 * @param dataSet
 * @param trans
 * @param bounds
 */
protected void drawLinearFill(Canvas c, ILineDataSet dataSet, Transformer trans, XBounds bounds) {

    final Path filled = mGenerateFilledPathBuffer;

    final int startingIndex = bounds.min;
    final int endingIndex = bounds.range + bounds.min;
    final int indexInterval = 128;

    int currentStartIndex = 0;
    int currentEndIndex = indexInterval;
    int iterations = 0;

    // Doing this iteratively in order to avoid OutOfMemory errors that can happen on large bounds sets.
    do {
        currentStartIndex = startingIndex + (iterations * indexInterval);
        currentEndIndex = currentStartIndex + indexInterval;
        currentEndIndex = currentEndIndex > endingIndex ? endingIndex : currentEndIndex;

        if (currentStartIndex <= currentEndIndex) {
            generateFilledPath(dataSet, currentStartIndex, currentEndIndex, filled);

            trans.pathValueToPixel(filled);

            final Drawable drawable = dataSet.getFillDrawable();
            if (drawable != null) {

                drawFilledPath(c, filled, drawable);
            } else {

                drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha());
            }
        }

        iterations++;

    } while (currentStartIndex <= currentEndIndex);

}
 
Example 10
Source File: LineChartRenderer.java    From android-kline with Apache License 2.0 5 votes vote down vote up
/**
 * Draws a filled linear path on the canvas.
 *
 * @param c
 * @param dataSet
 * @param trans
 * @param bounds
 */
protected void drawLinearFill(Canvas c, ILineDataSet dataSet, Transformer trans, XBounds bounds) {

    final Path filled = mGenerateFilledPathBuffer;

    final int startingIndex = bounds.min;
    final int endingIndex = bounds.range + bounds.min;
    final int indexInterval = 128;

    int currentStartIndex = 0;
    int currentEndIndex = indexInterval;
    int iterations = 0;

    // Doing this iteratively in order to avoid OutOfMemory errors that can happen on large bounds sets.
    do {
        currentStartIndex = startingIndex + (iterations * indexInterval);
        currentEndIndex = currentStartIndex + indexInterval;
        currentEndIndex = currentEndIndex > endingIndex ? endingIndex : currentEndIndex;

        if (currentStartIndex <= currentEndIndex) {
            generateFilledPath(dataSet, currentStartIndex, currentEndIndex, filled);

            trans.pathValueToPixel(filled);

            final Drawable drawable = dataSet.getFillDrawable();
            if (drawable != null) {

                drawFilledPath(c, filled, drawable);
            } else {

                drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha());
            }
        }

        iterations++;

    } while (currentStartIndex <= currentEndIndex);

}
 
Example 11
Source File: LineChartRenderer.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans,
                             int from, int to) {

    if (to - from <= 1)
        return;

    float fillMin = dataSet.getFillFormatter()
            .getFillLinePosition(dataSet, mChart);
    
    // Take the from/to xIndex from the entries themselves,
    // so missing entries won't screw up the filling.
    // What we need to draw is line from points of the xIndexes - not arbitrary entry indexes!

    final Entry toEntry = dataSet.getEntryForIndex(to - 1);
    final Entry fromEntry = dataSet.getEntryForIndex(from);
    final float xTo = toEntry == null ? 0 : toEntry.getXIndex();
    final float xFrom = fromEntry == null ? 0 : fromEntry.getXIndex();

    spline.lineTo(xTo, fillMin);
    spline.lineTo(xFrom, fillMin);
    spline.close();

    trans.pathValueToPixel(spline);

    final Drawable drawable = dataSet.getFillDrawable();
    if (drawable != null) {

        drawFilledPath(c, spline, drawable);
    } else {

        drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
    }
}
 
Example 12
Source File: LineChartRenderer.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans,
                             int from, int to) {

    if (to - from <= 1)
        return;

    float fillMin = dataSet.getFillFormatter()
            .getFillLinePosition(dataSet, mChart);
    
    // Take the from/to xIndex from the entries themselves,
    // so missing entries won't screw up the filling.
    // What we need to draw is line from points of the xIndexes - not arbitrary entry indexes!

    final Entry toEntry = dataSet.getEntryForIndex(to - 1);
    final Entry fromEntry = dataSet.getEntryForIndex(from);
    final float xTo = toEntry == null ? 0 : toEntry.getXIndex();
    final float xFrom = fromEntry == null ? 0 : fromEntry.getXIndex();

    spline.lineTo(xTo, fillMin);
    spline.lineTo(xFrom, fillMin);
    spline.close();

    trans.pathValueToPixel(spline);

    final Drawable drawable = dataSet.getFillDrawable();
    if (drawable != null) {

        drawFilledPath(c, spline, drawable);
    } else {

        drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
    }
}