ScatterChart.java
2.08 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
package com.github.mikephil.charting.charts;
import android.content.Context;
import android.util.AttributeSet;
import com.github.mikephil.charting.data.ScatterData;
import com.github.mikephil.charting.interfaces.dataprovider.ScatterDataProvider;
import com.github.mikephil.charting.renderer.ScatterChartRenderer;
/**
* The ScatterChart. Draws dots, triangles, squares and custom shapes into the
* Chart-View. CIRCLE and SCQUARE offer the best performance, TRIANGLE has the
* worst performance.
*
* @author Philipp Jahoda
*/
public class ScatterChart extends BarLineChartBase<ScatterData> implements ScatterDataProvider {
public ScatterChart(Context context) {
super(context);
}
public ScatterChart(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScatterChart(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void init() {
super.init();
mRenderer = new ScatterChartRenderer(this, mAnimator, mViewPortHandler);
getXAxis().setSpaceMin(0.5f);
getXAxis().setSpaceMax(0.5f);
}
@Override
public ScatterData getScatterData() {
return mData;
}
/**
* Predefined ScatterShapes that allow the specification of a shape a ScatterDataSet should be drawn with.
* If a ScatterShape is specified for a ScatterDataSet, the required renderer is set.
*/
public enum ScatterShape {
SQUARE("SQUARE"),
CIRCLE("CIRCLE"),
TRIANGLE("TRIANGLE"),
CROSS("CROSS"),
X("X"),
CHEVRON_UP("CHEVRON_UP"),
CHEVRON_DOWN("CHEVRON_DOWN");
private final String shapeIdentifier;
ScatterShape(final String shapeIdentifier) {
this.shapeIdentifier = shapeIdentifier;
}
@Override
public String toString() {
return shapeIdentifier;
}
public static ScatterShape[] getAllDefaultShapes() {
return new ScatterShape[]{SQUARE, CIRCLE, TRIANGLE, CROSS, X, CHEVRON_UP, CHEVRON_DOWN};
}
}
}