From c550db6d37f991c452079a12105a21bfbc99e5bf Mon Sep 17 00:00:00 2001 From: Lammert Westerhoff Date: Tue, 29 Nov 2016 16:41:24 +0100 Subject: [PATCH] Add mapping for valueTextColors --- .../mandata/react_native_mpchart/MPBarChartManager.java | 9 +++++++++ .../mandata/react_native_mpchart/MPLineChartManager.java | 8 ++++++++ .../mandata/react_native_mpchart/MPPieChartManager.java | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/android/src/main/java/cn/mandata/react_native_mpchart/MPBarChartManager.java b/android/src/main/java/cn/mandata/react_native_mpchart/MPBarChartManager.java index fbc6b88..3a09968 100644 --- a/android/src/main/java/cn/mandata/react_native_mpchart/MPBarChartManager.java +++ b/android/src/main/java/cn/mandata/react_native_mpchart/MPBarChartManager.java @@ -67,6 +67,15 @@ public void setData(BarChart chart,ReadableMap rm){ entries.add(be);*/ BarDataSet dataSet=new BarDataSet(entries,label); ReadableMap config= map.getMap("config"); + + if(config.hasKey("valueTextColors")){ + ReadableArray colorsArray = config.getArray("valueTextColors"); + ArrayList colors = new ArrayList<>(); + for(int c = 0; c < colorsArray.size(); c++){ + colors.add(Color.parseColor(colorsArray.getString(c))); + } + dataSet.setValueTextColors(colors); + }else if(config.hasKey("valueTextColor")) dataSet.setValueTextColor(Color.parseColor(config.getString("valueTextColor"))); // Text Size for bar value diff --git a/android/src/main/java/cn/mandata/react_native_mpchart/MPLineChartManager.java b/android/src/main/java/cn/mandata/react_native_mpchart/MPLineChartManager.java index 844d23d..222f48d 100644 --- a/android/src/main/java/cn/mandata/react_native_mpchart/MPLineChartManager.java +++ b/android/src/main/java/cn/mandata/react_native_mpchart/MPLineChartManager.java @@ -81,6 +81,14 @@ public void setData(LineChart chart,ReadableMap rm){ if(config.hasKey("drawCircles")) dataSet.setDrawCircles(config.getBoolean("drawCircles")); if(config.hasKey("circleSize")) dataSet.setCircleSize((float) config.getDouble("circleSize")); if(config.hasKey("lineWidth")) dataSet.setLineWidth((float) config.getDouble("lineWidth")); + if(config.hasKey("valueTextColors")){ + ReadableArray colorsArray = config.getArray("valueTextColors"); + ArrayList colors = new ArrayList<>(); + for(int c = 0; c < colorsArray.size(); c++){ + colors.add(Color.parseColor(colorsArray.getString(c))); + } + dataSet.setValueTextColors(colors); + }else if(config.hasKey("drawValues")) dataSet.setDrawValues(config.getBoolean("drawValues")); if(config.hasKey("valueTextColor")) dataSet.setValueTextColor(Color.parseColor(config.getString("valueTextColor"))); diff --git a/android/src/main/java/cn/mandata/react_native_mpchart/MPPieChartManager.java b/android/src/main/java/cn/mandata/react_native_mpchart/MPPieChartManager.java index 11f46a1..fd6a560 100644 --- a/android/src/main/java/cn/mandata/react_native_mpchart/MPPieChartManager.java +++ b/android/src/main/java/cn/mandata/react_native_mpchart/MPPieChartManager.java @@ -126,6 +126,14 @@ public void setData(PieChart chart,ReadableMap rm){ dataSet.setColors(colors); } if(config.hasKey("drawValues")) dataSet.setDrawValues(config.getBoolean("drawValues")); + if(config.hasKey("valueTextColors")){ + ReadableArray colorsArray = config.getArray("valueTextColors"); + ArrayList colors = new ArrayList<>(); + for(int c = 0; c < colorsArray.size(); c++){ + colors.add(Color.parseColor(colorsArray.getString(c))); + } + dataSet.setValueTextColors(colors); + }else if(config.hasKey("valueTextColor")) dataSet.setValueTextColor(Color.parseColor(config.getString("valueTextColor"))); dataSet.setSliceSpace(3f); pieData.addDataSet(dataSet);