From cef967fd71ff18b0908ffa21c795faefde3ff120 Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Fri, 7 Feb 2020 17:53:40 +0700 Subject: [PATCH 1/4] fix NPE when use solid color with barchart --- .../github/mikephil/charting/renderer/BarChartRenderer.java | 6 +++++- .../charting/renderer/HorizontalBarChartRenderer.java | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java index d6ce3898e1..99a1249932 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java @@ -144,7 +144,11 @@ protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { trans.pointValuesToPixel(buffer.buffer); - final boolean isCustomFill = dataSet.getFills().size() > 0; + boolean isCustomFill = false; + if(dataSet.getFills() != null) { + isCustomFill = !dataSet.getFills().isEmpty(); + } + final boolean isSingleColor = dataSet.getColors().size() == 1; final boolean isInverted = mChart.isInverted(dataSet.getAxisDependency()); diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java index f9431702ad..6ca6ff0e8d 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java @@ -112,7 +112,10 @@ protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { trans.pointValuesToPixel(buffer.buffer); - final boolean isCustomFill = dataSet.getFills().size() > 0; + boolean isCustomFill = false; + if(dataSet.getFills() != null) { + isCustomFill = !dataSet.getFills().isEmpty(); + } final boolean isSingleColor = dataSet.getColors().size() == 1; final boolean isInverted = mChart.isInverted(dataSet.getAxisDependency()); From 4b67673da908378fda8fd7449a5a19c30d45c8d2 Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Fri, 7 Feb 2020 22:03:20 +0700 Subject: [PATCH 2/4] Update BarChartRenderer.java --- .../github/mikephil/charting/renderer/BarChartRenderer.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java index 99a1249932..ca8b8c1504 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java @@ -144,10 +144,7 @@ protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { trans.pointValuesToPixel(buffer.buffer); - boolean isCustomFill = false; - if(dataSet.getFills() != null) { - isCustomFill = !dataSet.getFills().isEmpty(); - } + boolean isCustomFill = dataSet.getFills() != null && !dataSet.getFills().isEmpty(); final boolean isSingleColor = dataSet.getColors().size() == 1; final boolean isInverted = mChart.isInverted(dataSet.getAxisDependency()); From 33240f9225bea0b23d8d82a786867f8446fd5dfd Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Fri, 7 Feb 2020 22:09:07 +0700 Subject: [PATCH 3/4] Update HorizontalBarChartRenderer.java --- .../charting/renderer/HorizontalBarChartRenderer.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java index 6ca6ff0e8d..b42ef1284a 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java @@ -112,10 +112,7 @@ protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { trans.pointValuesToPixel(buffer.buffer); - boolean isCustomFill = false; - if(dataSet.getFills() != null) { - isCustomFill = !dataSet.getFills().isEmpty(); - } + final boolean isCustomFill = dataSet.getFills() != null && !dataSet.getFills().isEmpty(); final boolean isSingleColor = dataSet.getColors().size() == 1; final boolean isInverted = mChart.isInverted(dataSet.getAxisDependency()); From 90e523042cfae25c8271b60f2cf68a947c46e018 Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Fri, 7 Feb 2020 22:09:57 +0700 Subject: [PATCH 4/4] Update BarChartRenderer.java --- .../github/mikephil/charting/renderer/BarChartRenderer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java index ca8b8c1504..18975557cd 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java @@ -144,8 +144,7 @@ protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { trans.pointValuesToPixel(buffer.buffer); - boolean isCustomFill = dataSet.getFills() != null && !dataSet.getFills().isEmpty(); - + final boolean isCustomFill = dataSet.getFills() != null && !dataSet.getFills().isEmpty(); final boolean isSingleColor = dataSet.getColors().size() == 1; final boolean isInverted = mChart.isInverted(dataSet.getAxisDependency());