Skip to content

Commit 1901fd8

Browse files
committed
Update README.md
1 parent 370604b commit 1901fd8

1 file changed

Lines changed: 0 additions & 42 deletions

File tree

‎README.md‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -166,48 +166,6 @@ For a **detailed documentation**, please refer the [**Wiki**](https://github.com
166166
- <code>centerViewPort(int xIndex, float val)</code>: This method makes it possible to aim the center of the view (what you can see from the chart) to a specific position inside the chart, described by the index on the x-axis and the value on the y-axis. This also works very well in combination with the `setScaleMinima(...)` method.
167167
- <code>fitScreen()</code>: Resets all zooming and dragging and makes the chart fit exactly it's bounds.
168168

169-
**Setting colors:**
170-
171-
Since release [v1.4.0](https://github.com/PhilJay/MPAndroidChart/releases/tag/v1.4.0), the `ColorTemplate` object that was responsible for setting colors in previous releases is no longer needed. Nevertheless, it still holds all predefined color arrays (e.g. `ColorTemplate.VORDIPLOM_COLORS` and provides convenience methods for transforming colors from the resources (resource integers) into "real" colors.
172-
173-
Instead of the `ColorTemplate`, colors can now be specified directly via `DataSet` object, which allows separate styling for each `DataSet`.
174-
175-
In this short example, we have our two different `LineDataSet` objects representing the quarterly revenues of two companies (previously mentioned in the **Adding data** tutorial), for which we now want to set different colors.
176-
177-
What we want:
178-
179-
- the values of "Company 1" should be represented by four different variations of the color "red"
180-
- the values of "Company 2" should be represented by four different variations of the color "green"
181-
182-
This is what the code looks like:
183-
184-
```java
185-
LineDataSet setComp1 = new LineDataSet(valsComp1, "Company 1");
186-
187-
// sets colors for the dataset, resolution of the resource name to a "real" color is done internally
188-
setComp1.setColors(new int[] { R.color.red1, R.color.red2, R.color.red3, R.color.red4 }, Context);
189-
190-
LineDataSet setComp2 = new LineDataSet(valsComp2, "Company 2");
191-
setComp2.setColors(new int[] { R.color.green1, R.color.green2, R.color.green3, R.color.green4 }, Context);
192-
```
193-
194-
Besides that, there are many other ways for setting colors for a `DataSet`. Here is the full documentation:
195-
196-
- `setColors(int [] colors, Context c)`: Sets the colors that should be used fore this DataSet. Colors are reused as soon as the number of Entries the DataSet represents is higher than the size of the colors array. You can use "new int[] { R.color.red, R.color.green, ... }" to provide colors for this method. Internally, the colors are resolved using getResources().getColor(...).
197-
- `setColors(int [] colors)`: Sets the colors that should be used fore this DataSet. Colors are reused as soon as the number of Entries the DataSet represents is higher than the size of the colors array. Make sure that the colors are already prepared (by calling getResources().getColor(...)) before adding them to the DataSet.
198-
- `setColors(ArrayList<Integer> colors)`: Sets the colors that should be used fore this DataSet. Colors are reused as soon as the number of Entries the DataSet represents is higher than the size of the colors array. Make sure that the colors are already prepared (by calling getResources().getColor(...)) before adding them to the DataSet.
199-
- `setColor(int color)`: Sets the one and ONLY color that should be used for this DataSet. Internally, this recreates the colors array and adds the specified color.
200-
201-
`ColorTemplate` example:
202-
203-
```java
204-
LineDataSet set = new LineDataSet(...);
205-
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
206-
```
207-
208-
If no colors are set for a `DataSet`, default colors are used.
209-
210-
211169
**Displaying / styling legends:**
212170

213171
By default, all chart types support legends and will automatically generate and draw a legend after setting data for the chart. If a legend should be drawn or not can be enabled/disabled using the

0 commit comments

Comments
 (0)