Features

  • 折线图、曲线图(可填充)、柱状图、扇形图、雷达图,共5种图表类型。
  • 组合图表类型,可任意组合折线图、曲线图、柱状图。
  • 折线图、曲线图(可填充)、柱状图、扇形图都拥有绘制动画。
  • 扇形图提供了触控交互效果。

Usage

Gradle

  • Step 1. Add the JitPack repository to your build file
1
2
3
4
5
6
   allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
  • Step 2. Add SmallChart
1
2
3
   dependencies {
compile 'com.github.Idtk:SmallChart:v0.1.1'
}

Maven

  • Step 1. Add the JitPack repository to your build file
1
2
3
4
5
6
   <repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
  • Step 2. Add SmallChart
1
2
3
4
5
   <dependency>
<groupId>com.github.Idtk</groupId>
<artifactId>SmallChart</artifactId>
<version>v0.1.1</version>
</dependency>

demo

Activity

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
/*CombineChart*/
private CurveData mCurveData = new CurveData();
private ArrayList<PointF> mPointArrayList1 = new ArrayList<>();

private LineData mLineData = new LineData();
private ArrayList<PointF> mPointArrayList2 = new ArrayList<>();

private BarData mBarData = new BarData();
private ArrayList<PointF> mPointArrayList3 = new ArrayList<>();

private ArrayList<IBarLineCurveData> mDataList = new ArrayList<>();

/*PieChart*/
private ArrayList<IPieData> mPieDataList = new ArrayList<>();

/**/
private RadarData mRadarData = new RadarData();
private RadarData mRadarData2 = new RadarData();
private ArrayList<IRadarData> radarDataList = new ArrayList<>();
private ArrayList<Float> radarValue = new ArrayList<>();
private ArrayList<Float> radarValue2 = new ArrayList<>();

protected float[][] points = new float[][]{{1,10}, {2,47}, {3,11}, {4,38}, {5,9},{6,52}, {7,14}, {8,37}, {9,29}, {10,31}};
protected float[][] points2 = new float[][]{{1,52}, {2,13}, {3,51}, {4,20}, {5,19},{6,20}, {7,54}, {8,7}, {9,19}, {10,41}};
protected int[] mColors = {0xFFCCFF00, 0xFF6495ED, 0xFFE32636, 0xFF800000, 0xFF808000, 0xFFFF8C69, 0xFF808080,
0xFFE6B800, 0xFF7CFC00};

protected float pxTodp(float value){
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
float valueDP= TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,value,metrics);
return valueDP;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

initData();

/*CombineChart*/
CombineChart combineChart = (CombineChart)findViewById(R.id.combineChart);
combineChart.isAnimated = false;
combineChart.setDataList(mDataList);

/*PieChart*/
PieChart pieChart = (PieChart) findViewById(R.id.pieChart);
pieChart.setDataList(mPieDataList);
pieChart.setAxisColor(Color.WHITE);
pieChart.setAxisTextSize(pxTodp(20));

RadarChart radarChart = (RadarChart) findViewById(R.id.radarChart);
radarChart.setDataList(radarDataList);
radarChart.setTypes(new String[]{"Party A", "Party B", "Party C", "Party D", "Party E", "Party F", "Party G", "Party H"});

}

private void initData() {
/*CombineChart*/
for (int i = 0; i < 8; i++) {
mPointArrayList3.add(new PointF(points[i][0], points[i][1]));
mPointArrayList2.add(new PointF(points[i][0], points[i][1]-5));
mPointArrayList1.add(new PointF(points[i][0], points[i][1]+10));
}
mBarData.setValue(mPointArrayList3);
mBarData.setColor(Color.CYAN);
mBarData.setPaintWidth(pxTodp(5));
mBarData.setTextSize(pxTodp(10));
mDataList.add(mBarData);

mLineData.setValue(mPointArrayList2);
mLineData.setColor(Color.MAGENTA);
mLineData.setPaintWidth(pxTodp(3));
mLineData.setTextSize(pxTodp(10));
mDataList.add(mLineData);

mCurveData.setValue(mPointArrayList1);
mCurveData.setColor(Color.YELLOW);
mCurveData.setPaintWidth(pxTodp(3));
mCurveData.setTextSize(pxTodp(10));
mDataList.add(mCurveData);

/*PieChart*/
for (int i=0; i<9; i++){
PieData pieData = new PieData();
pieData.setName("区域"+i);
pieData.setValue((float)i+1);
pieData.setColor(mColors[i]);
mPieDataList.add(pieData);
}

/**/
for (int i = 0; i < 8; i++) {
radarValue.add(points[i][1]);
radarValue2.add(points2[i][1]);
}
mRadarData.setValue(radarValue);
mRadarData.setColor(Color.MAGENTA);
mRadarData.setPaintWidth(pxTodp(3));
mRadarData2.setValue(radarValue2);
mRadarData2.setColor(Color.CYAN);
mRadarData2.setPaintWidth(pxTodp(3));
radarDataList.add(mRadarData);
radarDataList.add(mRadarData2);

}

XML

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
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="kreedx.org.chartsee.MainActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.idtk.smallchart.chart.CombineChart
android:id="@+id/combineChart"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<com.idtk.smallchart.chart.PieChart
android:id="@+id/pieChart"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<com.idtk.smallchart.chart.RadarChart
android:id="@+id/radarChart"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>


</ScrollView>


SmallChart

ChartSee.apk