diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java index 603e293c0c..83517c2c44 100644 --- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java +++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java @@ -117,7 +117,7 @@ private void addDataSet() { 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 7f0ff296c3..9b19619aa6 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 @@ protected void onCreate(Bundle savedInstanceState) { 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 @@ protected void onCreate(Bundle savedInstanceState) { 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 @@ public boolean onOptionsItemSelected(MenuItem item) { } case R.id.actionToggleAdjustXLegend: { XLabels xLabels = mChart.getXLabels(); - + if (xLabels.isAdjustXLabelsEnabled()) xLabels.setAdjustXLabels(false); else @@ -139,9 +140,9 @@ public boolean onOptionsItemSelected(MenuItem item) { break; } case R.id.actionToggleFilter: { - + Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25); - + if (!mChart.isFilteringEnabled()) { mChart.enableFiltering(a); } else { @@ -174,7 +175,7 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - + tvX.setText("" + (mSeekBarX.getProgress() + 1)); tvY.setText("" + (mSeekBarY.getProgress())); @@ -205,14 +206,14 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // 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 0771182192..cdc6bc91bc 100644 --- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SimpleFragment.java +++ b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SimpleFragment.java @@ -38,7 +38,7 @@ protected BarData generateBarData(int dataSets, float range, int count) { } 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 @@ protected ScatterData generateScatterData(int dataSets, float range, int count) 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 @@ protected PieData generatePieData() { } 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 2661c7bd57..f88b8b7867 100644 --- a/MPChartLib/res/values/colors.xml +++ b/MPChartLib/res/values/colors.xml @@ -1,6 +1,19 @@ + + - - + + \ 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 293457db69..dfe2878cfd 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 @@ public class ColorTemplate { * 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 79c4abdaa5..91c468cd7b 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,6 @@ Features - **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)