diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.java b/MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.java index c90b4fc9b9..c69e2304f4 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.java @@ -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 @@ -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; + } } diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/AxisRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/AxisRenderer.java index 72ea2d17c8..f75fbc047c 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/AxisRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/AxisRenderer.java @@ -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()) { diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java index a86c16f76b..2df71adfb4 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java @@ -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);