forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPieDataSet.java
More file actions
83 lines (66 loc) · 1.99 KB
/
PieDataSet.java
File metadata and controls
83 lines (66 loc) · 1.99 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
75
76
77
78
79
80
81
82
83
package com.github.mikephil.charting.data;
import com.github.mikephil.charting.utils.Utils;
import java.util.ArrayList;
import java.util.List;
public class PieDataSet extends DataSet<Entry> {
/** the space in degrees between the chart-slices, default 0f */
private float mSliceSpace = 0f;
/** indicates the selection distance of a pie slice */
private float mShift = 18f;
public PieDataSet(List<Entry> yVals, String label) {
super(yVals, label);
// mShift = Utils.convertDpToPixel(12f);
}
@Override
public DataSet<Entry> copy() {
List<Entry> yVals = new ArrayList<Entry>();
for (int i = 0; i < mYVals.size(); i++) {
yVals.add(mYVals.get(i).copy());
}
PieDataSet copied = new PieDataSet(yVals, getLabel());
copied.mColors = mColors;
copied.mSliceSpace = mSliceSpace;
copied.mShift = mShift;
return copied;
}
/**
* sets the space that is left out between the piechart-slices, default: 0°
* --> no space, maximum 45, minimum 0 (no space)
*
* @param degrees
*/
public void setSliceSpace(float degrees) {
if (degrees > 45)
degrees = 45f;
if (degrees < 0)
degrees = 0f;
mSliceSpace = degrees;
}
/**
* returns the space that is set to be between the piechart-slices of this
* DataSet, in degrees
*
* @return
*/
public float getSliceSpace() {
return mSliceSpace;
}
/**
* sets the distance the highlighted piechart-slice of this DataSet is
* "shifted" away from the center of the chart, default 12f
*
* @param shift
*/
public void setSelectionShift(float shift) {
mShift = Utils.convertDpToPixel(shift);
}
/**
* returns the distance a highlighted piechart slice is "shifted" away from
* the chart-center
*
* @return
*/
public float getSelectionShift() {
return mShift;
}
}