Skip to content

Commit

Permalink
Merge pull request #62 from lammertw/value-text-colors
Browse files Browse the repository at this point in the history
Add mapping for valueTextColors
  • Loading branch information
hongyin163 authored Jan 9, 2017
2 parents 415f317 + c550db6 commit 8c7d516
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,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<Integer> 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")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> 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);
Expand Down

0 comments on commit 8c7d516

Please sign in to comment.