Skip to content

Commit

Permalink
Fix Drawable LineChart Fill Bug
Browse files Browse the repository at this point in the history
The LineChart fill draws using intervals to avoid
memory issues, but with a larger data set and many
different (darker) colors Android does not draw the
drawable all the way to the edge of the interval.
This makes it look like there are spaces between the fill.
Draw a little beyond the existing interval so there are no gaps.

PhilJay#5284
  • Loading branch information
Grant Kaming authored and hannesa2 committed Apr 2, 2022
1 parent 40223e2 commit fa9ef73
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,14 +462,25 @@ protected void drawLinearFill(Canvas c, ILineDataSet dataSet, Transformer trans,
do {
currentStartIndex = startingIndex + (iterations * indexInterval);
currentEndIndex = currentStartIndex + indexInterval;
currentEndIndex = currentEndIndex > endingIndex ? endingIndex : currentEndIndex;
currentEndIndex = Math.min(currentEndIndex, endingIndex);

if (currentStartIndex <= currentEndIndex) {
generateFilledPath(dataSet, currentStartIndex, currentEndIndex, filled);
final Drawable drawable = dataSet.getFillDrawable();

int startIndex = currentStartIndex;
int endIndex = currentEndIndex;

// Add a little extra to the path for drawables, larger data sets were showing space between adjacent drawables
if (drawable != null) {

startIndex = Math.max(0, currentStartIndex - 1);
endIndex = Math.min(endingIndex, currentEndIndex + 1);
}

generateFilledPath(dataSet, startIndex, endIndex, filled);

trans.pathValueToPixel(filled);

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

drawFilledPath(c, filled, drawable);
Expand Down

0 comments on commit fa9ef73

Please sign in to comment.