Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Drawable LineChart Fill Bug #5284

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public abstract class AxisBase extends ComponentBase {
* the number of decimal digits to use
*/
public int mDecimals;

/**
* if the user set a custom number of decimals
*/
public boolean mHasCustomDecimals = false;

/**
* the number of label entries the axis should have, default 6
Expand Down Expand Up @@ -813,4 +818,13 @@ public void setSpaceMax(float mSpaceMax)
{
this.mSpaceMax = mSpaceMax;
}

/**
* Sets the number of decimals to use when formatting values on the axis
*/
public void setDecimals(int mDecimals)
{
this.mDecimals = mDecimals;
this.mHasCustomDecimals = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,12 @@ else if (last == first && n == 0) {
}

// set decimals
if (interval < 1) {
mAxis.mDecimals = (int) Math.ceil(-Math.log10(interval));
} else {
mAxis.mDecimals = 0;
if (!mAxis.mHasCustomDecimals) {
if (interval < 1) {
mAxis.mDecimals = (int) Math.ceil(-Math.log10(interval));
} else {
mAxis.mDecimals = 0;
}
}

if (mAxis.isCenterAxisLabelsEnabled()) {
Expand Down
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 && dataSet.getEntryCount() > 200) {

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