Refactored ColorTemplate, library is now no longer dependant on .xml resources.
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java
index 603e293..83517c2 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java
+++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java
@@ -117,7 +117,7 @@
set.setLineWidth(2.5f);
set.setCircleSize(4.5f);
- int color = getResources().getColor(mColors[count % mColors.length]);
+ int color = mColors[count % mColors.length];
set.setColor(color);
set.setCircleColor(color);
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScatterChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScatterChartActivity.java
index 7f0ff29..9b19619 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScatterChartActivity.java
+++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScatterChartActivity.java
@@ -19,6 +19,7 @@
import com.github.mikephil.charting.data.filter.Approximator;
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
+import com.github.mikephil.charting.utils.ColorTemplate;
import com.github.mikephil.charting.utils.Legend;
import com.github.mikephil.charting.utils.Legend.LegendPosition;
import com.github.mikephil.charting.utils.XLabels;
@@ -49,15 +50,15 @@
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
-
+
mChart = (ScatterChart) findViewById(R.id.chart1);
mChart.setDescription("");
-
+
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart.setValueTypeface(tf);
-
+
mChart.setOnChartValueSelectedListener(this);
-
+
mChart.setDrawGridBackground(false);
mChart.setTouchEnabled(true);
@@ -71,14 +72,14 @@
mSeekBarX.setProgress(45);
mSeekBarY.setProgress(100);
-
+
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
l.setTypeface(tf);
-
+
YLabels yl = mChart.getYLabels();
yl.setTypeface(tf);
-
+
XLabels xl = mChart.getXLabels();
xl.setTypeface(tf);
}
@@ -129,7 +130,7 @@
}
case R.id.actionToggleAdjustXLegend: {
XLabels xLabels = mChart.getXLabels();
-
+
if (xLabels.isAdjustXLabelsEnabled())
xLabels.setAdjustXLabels(false);
else
@@ -139,9 +140,9 @@
break;
}
case R.id.actionToggleFilter: {
-
+
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
-
+
if (!mChart.isFilteringEnabled()) {
mChart.enableFiltering(a);
} else {
@@ -174,7 +175,7 @@
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
+
tvX.setText("" + (mSeekBarX.getProgress() + 1));
tvY.setText("" + (mSeekBarY.getProgress()));
@@ -205,14 +206,14 @@
// create a dataset and give it a type
ScatterDataSet set1 = new ScatterDataSet(yVals1, "DS 1");
set1.setScatterShape(ScatterShape.SQUARE);
- set1.setColor(getResources().getColor(R.color.colorful_1));
+ set1.setColor(ColorTemplate.COLORFUL_COLORS[0]);
ScatterDataSet set2 = new ScatterDataSet(yVals2, "DS 2");
set2.setScatterShape(ScatterShape.CIRCLE);
- set2.setColor(getResources().getColor(R.color.colorful_2));
+ set2.setColor(ColorTemplate.COLORFUL_COLORS[1]);
ScatterDataSet set3 = new ScatterDataSet(yVals3, "DS 3");
set3.setScatterShape(ScatterShape.TRIANGLE);
- set3.setColor(getResources().getColor(R.color.colorful_3));
-
+ set3.setColor(ColorTemplate.COLORFUL_COLORS[2]);
+
set1.setScatterShapeSize(8f);
set2.setScatterShapeSize(8f);
set3.setScatterShapeSize(8f);
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SimpleFragment.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SimpleFragment.java
index 0771182..cdc6bc9 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SimpleFragment.java
+++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SimpleFragment.java
@@ -38,7 +38,7 @@
}
BarDataSet ds = new BarDataSet(entries, getLabel(i));
- ds.setColors(ColorTemplate.VORDIPLOM_COLORS, getActivity());
+ ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
sets.add(ds);
}
@@ -63,7 +63,7 @@
ScatterDataSet ds = new ScatterDataSet(entries, getLabel(i));
ds.setScatterShapeSize(12f);
ds.setScatterShape(shapes[i % shapes.length]);
- ds.setColors(ColorTemplate.COLORFUL_COLORS, getActivity());
+ ds.setColors(ColorTemplate.COLORFUL_COLORS);
ds.setScatterShapeSize(9f);
sets.add(ds);
}
@@ -95,7 +95,7 @@
}
PieDataSet ds1 = new PieDataSet(entries1, "Quarterly Revenues 2014");
- ds1.setColors(ColorTemplate.VORDIPLOM_COLORS, getActivity());
+ ds1.setColors(ColorTemplate.VORDIPLOM_COLORS);
ds1.setSliceSpace(2f);
PieData d = new PieData(xVals, ds1);
diff --git a/MPChartLib/res/values/colors.xml b/MPChartLib/res/values/colors.xml
index 2661c7b..f88b8b7 100644
--- a/MPChartLib/res/values/colors.xml
+++ b/MPChartLib/res/values/colors.xml
@@ -1,6 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
+
+ <!--
+ <color name="liberty_1">#CFF8F6</color>
+ <color name="liberty_2">#94D4D4</color>
+ <color name="liberty_3">#88B4BB</color>
+ <color name="liberty_4">#76AEAF</color>
+ <color name="liberty_5">#2A6D82</color>
+ <color name="joyful_1">#D9508A</color>
+ <color name="joyful_2">#FE9507</color>
+ <color name="joyful_3">#FEF778</color>
+ <color name="joyful_4">#6AA786</color>
+ <color name="joyful_5">#35C2D1</color>
+
<color name="fresh_1">#FFFFB3</color>
<color name="fresh_2">#94FF85</color>
<color name="fresh_3">#75FFC2</color>
@@ -12,42 +25,30 @@
<color name="mono_3">#075075</color>
<color name="mono_4">#57BEF2</color>
<color name="mono_5">#326E8C</color>
-
- <color name="liberty_1">#CFF8F6</color>
- <color name="liberty_2">#94D4D4</color>
- <color name="liberty_3">#88B4BB</color>
- <color name="liberty_4">#76AEAF</color>
- <color name="liberty_5">#2A6D82</color>
-
- <color name="colorful_1">#C12552</color>
- <color name="colorful_2">#FF6600</color>
- <color name="colorful_3">#F5C700</color>
- <color name="colorful_4">#6A961F</color>
- <color name="colorful_5">#008885</color>
-
+
+ <color name="pastel_1">#405980</color>
+ <color name="pastel_2">#95A57C</color>
+ <color name="pastel_3">#D9B8A2</color>
+ <color name="pastel_4">#BF8686</color>
+ <color name="pastel_5">#B33050</color>
+
<color name="greens_1">#55FC70</color>
<color name="greens_2">#62E24C</color>
<color name="greens_3">#ACF960</color>
<color name="greens_4">#CBE24C</color>
<color name="greens_5">#FCF355</color>
- <color name="joyful_1">#D9508A</color>
- <color name="joyful_2">#FE9507</color>
- <color name="joyful_3">#FEF778</color>
- <color name="joyful_4">#6AA786</color>
- <color name="joyful_5">#35C2D1</color>
-
- <color name="pastel_1">#405980</color>
- <color name="pastel_2">#95A57C</color>
- <color name="pastel_3">#D9B8A2</color>
- <color name="pastel_4">#BF8686</color>
- <color name="pastel_5">#B33050</color>
-<!--
+ <color name="colorful_1">#C12552</color>
+ <color name="colorful_2">#FF6600</color>
+ <color name="colorful_3">#F5C700</color>
+ <color name="colorful_4">#6A961F</color>
+ <color name="colorful_5">#008885</color>
+
<color name="vordiplom_1">#C0FF8C</color>
<color name="vordiplom_2">#FFF78C</color>
<color name="vordiplom_3">#FFD08C</color>
<color name="vordiplom_4">#8CEAFF</color>
<color name="vordiplom_5">#FF8C9D</color>
-->
-
-</resources>
+
+</resources>
\ No newline at end of file
diff --git a/MPChartLib/src/com/github/mikephil/charting/utils/ColorTemplate.java b/MPChartLib/src/com/github/mikephil/charting/utils/ColorTemplate.java
index 293457d..dfe2878 100644
--- a/MPChartLib/src/com/github/mikephil/charting/utils/ColorTemplate.java
+++ b/MPChartLib/src/com/github/mikephil/charting/utils/ColorTemplate.java
@@ -9,7 +9,7 @@
import java.util.ArrayList;
/**
- * Class that holds predefined color arrays (e.g.
+ * Class that holds predefined color integer arrays (e.g.
* ColorTemplate.VORDIPLOM_COLORS) and convenience methods for loading colors
* from resources.
*
@@ -21,38 +21,40 @@
* THE COLOR THEMES ARE PREDEFINED (predefined color integer arrays), FEEL
* FREE TO CREATE YOUR OWN WITH AS MANY DIFFERENT COLORS AS YOU WANT
*/
-
- public static final int[] FRESH_COLORS = {
- R.color.fresh_1, R.color.fresh_2, R.color.fresh_3, R.color.fresh_4, R.color.fresh_5
- };
- public static final int[] MONO_COLORS = {
- R.color.mono_1, R.color.mono_2, R.color.mono_3, R.color.mono_4, R.color.mono_5
- };
public static final int[] LIBERTY_COLORS = {
- R.color.liberty_1, R.color.liberty_2, R.color.liberty_3, R.color.liberty_4,
- R.color.liberty_5
- };
- public static final int[] COLORFUL_COLORS = {
- R.color.colorful_1, R.color.colorful_2, R.color.colorful_3, R.color.colorful_4,
- R.color.colorful_5
- };
- public static final int[] GREEN_COLORS = {
- R.color.greens_1, R.color.greens_2, R.color.greens_3, R.color.greens_4,
- R.color.greens_5
+ Color.rgb(207, 248, 246), Color.rgb(148, 212, 212), Color.rgb(136, 180, 187),
+ Color.rgb(118, 174, 175), Color.rgb(42, 109, 130)
};
public static final int[] JOYFUL_COLORS = {
- R.color.joyful_1, R.color.joyful_2, R.color.joyful_3, R.color.joyful_4,
- R.color.joyful_5
+ Color.rgb(217, 80, 138), Color.rgb(254, 149, 7), Color.rgb(254, 247, 120),
+ Color.rgb(106, 167, 134), Color.rgb(53, 194, 209)
};
public static final int[] PASTEL_COLORS = {
- R.color.pastel_1, R.color.pastel_2, R.color.pastel_3, R.color.pastel_4,
- R.color.pastel_5
+ Color.rgb(64, 89, 128), Color.rgb(149, 165, 124), Color.rgb(217, 184, 162),
+ Color.rgb(191, 134, 134), Color.rgb(179, 48, 80)
+ };
+ public static final int[] COLORFUL_COLORS = {
+ Color.rgb(193, 37, 82), Color.rgb(255, 102, 0), Color.rgb(245, 199, 0),
+ Color.rgb(106, 150, 31), Color.rgb(179, 100, 53)
};
public static final int[] VORDIPLOM_COLORS = {
Color.rgb(192, 255, 140), Color.rgb(255, 247, 140), Color.rgb(255, 208, 140),
Color.rgb(140, 234, 255), Color.rgb(255, 140, 157)
};
+ // public static final int[] FRESH_COLORS = {
+ // R.color.fresh_1, R.color.fresh_2, R.color.fresh_3, R.color.fresh_4,
+ // R.color.fresh_5
+ // };
+ // public static final int[] MONO_COLORS = {
+ // R.color.mono_1, R.color.mono_2, R.color.mono_3, R.color.mono_4,
+ // R.color.mono_5
+ // };
+ // public static final int[] GREEN_COLORS = {
+ // R.color.greens_1, R.color.greens_2, R.color.greens_3, R.color.greens_4,
+ // R.color.greens_5
+ // };
+
/**
* turn an array of resource-colors (contains resource-id integers) into an
* array list of actual color integers
diff --git a/README.md b/README.md
index 79c4abd..91c468c 100644
--- a/README.md
+++ b/README.md
@@ -90,7 +90,6 @@
- **PieChart (with selection, ...)**
![alt tag](https://raw.github.com/PhilJay/MPAndroidChart/master/screenshots/simpledesign_piechart1.png)
-![alt tag](https://raw.github.com/PhilJay/MPAndroidChart/master/screenshots/piechart_holeradius_space.png)
- **ScatterChart** (with squares, triangles, circles, ... and more)