LineRadarDataSet.java
3.13 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package com.github.mikephil.charting.data;
import android.annotation.TargetApi;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import com.github.mikephil.charting.interfaces.datasets.ILineRadarDataSet;
import com.github.mikephil.charting.utils.Utils;
import java.util.List;
/**
* Base dataset for line and radar DataSets.
*
* @author Philipp Jahoda
*/
public abstract class LineRadarDataSet<T extends Entry> extends LineScatterCandleRadarDataSet<T> implements ILineRadarDataSet<T> {
/**
* the color that is used for filling the line surface
*/
private int mFillColor = Color.rgb(140, 234, 255);
/**
* the drawable to be used for filling the line surface
*/
protected Drawable mFillDrawable;
/**
* transparency used for filling line surface
*/
private int mFillAlpha = 85;
/**
* the width of the drawn data lines
*/
private float mLineWidth = 2.5f;
/**
* if true, the data will also be drawn filled
*/
private boolean mDrawFilled = false;
public LineRadarDataSet(List<T> yVals, String label) {
super(yVals, label);
}
@Override
public int getFillColor() {
return mFillColor;
}
/**
* Sets the color that is used for filling the area below the line.
* Resets an eventually set "fillDrawable".
*
* @param color
*/
public void setFillColor(int color) {
mFillColor = color;
mFillDrawable = null;
}
@Override
public Drawable getFillDrawable() {
return mFillDrawable;
}
/**
* Sets the drawable to be used to fill the area below the line.
*
* @param drawable
*/
@TargetApi(18)
public void setFillDrawable(Drawable drawable) {
this.mFillDrawable = drawable;
}
@Override
public int getFillAlpha() {
return mFillAlpha;
}
/**
* sets the alpha value (transparency) that is used for filling the line
* surface (0-255), default: 85
*
* @param alpha
*/
public void setFillAlpha(int alpha) {
mFillAlpha = alpha;
}
/**
* set the line width of the chart (min = 0.2f, max = 10f); default 1f NOTE:
* thinner line == better performance, thicker line == worse performance
*
* @param width
*/
public void setLineWidth(float width) {
if (width < 0.0f)
width = 0.0f;
if (width > 10.0f)
width = 10.0f;
mLineWidth = Utils.convertDpToPixel(width);
}
@Override
public float getLineWidth() {
return mLineWidth;
}
@Override
public void setDrawFilled(boolean filled) {
mDrawFilled = filled;
}
@Override
public boolean isDrawFilledEnabled() {
return mDrawFilled;
}
protected void copy(LineRadarDataSet lineRadarDataSet) {
super.copy(lineRadarDataSet);
lineRadarDataSet.mDrawFilled = mDrawFilled;
lineRadarDataSet.mFillAlpha = mFillAlpha;
lineRadarDataSet.mFillColor = mFillColor;
lineRadarDataSet.mFillDrawable = mFillDrawable;
lineRadarDataSet.mLineWidth = mLineWidth;
}
}