forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPieData.java
More file actions
74 lines (61 loc) · 1.91 KB
/
PieData.java
File metadata and controls
74 lines (61 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.github.mikephil.charting.data;
import java.util.ArrayList;
import java.util.List;
/**
* A PieData object can only represent one DataSet. Unlike all other charts, the
* legend labels of the PieChart are created from the x-values array, and not
* from the DataSet labels. Each PieData object can only represent one
* PieDataSet (multiple PieDataSets inside a single PieChart are not possible).
*
* @author Philipp Jahoda
*/
public class PieData extends ChartData<PieDataSet> {
public PieData() {
super();
}
public PieData(List<String> xVals) {
super(xVals);
}
public PieData(String[] xVals) {
super(xVals);
}
public PieData(List<String> xVals, PieDataSet dataSet) {
super(xVals, toList(dataSet));
}
public PieData(String[] xVals, PieDataSet dataSet) {
super(xVals, toList(dataSet));
}
private static List<PieDataSet> toList(PieDataSet dataSet) {
List<PieDataSet> sets = new ArrayList<PieDataSet>();
sets.add(dataSet);
return sets;
}
/**
* Sets the PieDataSet this data object should represent.
*
* @param dataSet
*/
public void setDataSet(PieDataSet dataSet) {
mDataSets.clear();
mDataSets.add(dataSet);
init();
}
/**
* Returns the DataSet this PieData object represents. A PieData object can
* only contain one DataSet.
*
* @return
*/
public PieDataSet getDataSet() {
return mDataSets.get(0);
}
@Override
public PieDataSet getDataSetByIndex(int index) {
return index == 0 ? getDataSet() : null;
}
@Override
public PieDataSet getDataSetByLabel(String label, boolean ignorecase) {
return ignorecase ? label.equalsIgnoreCase(mDataSets.get(0).getLabel()) ? mDataSets.get(0)
: null : label.equals(mDataSets.get(0).getLabel()) ? mDataSets.get(0) : null;
}
}