Skip to content

Commit ff01a15

Browse files
committed
Started implementing examples for simple straight forward charts.
1 parent ccf06e7 commit ff01a15

20 files changed

Lines changed: 396 additions & 45 deletions

MPChartExample/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<activity android:name="BarChartActivityMultiDataset"></activity>
3232
<activity android:name="DrawChartActivity"></activity>
3333
<activity android:name="ScatterChartActivity"></activity>
34+
<activity android:name=".simple.SimpleChartDemo"></activity>
3435
</application>
3536

3637
</manifest>

MPChartExample/res/layout/activity_main.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
<ScrollView
77
android:id="@+id/scrollView1"
88
android:layout_width="match_parent"
9-
android:layout_height="match_parent"
10-
android:layout_alignParentLeft="true"
11-
android:layout_alignParentTop="true" >
9+
android:layout_height="match_parent" >
1210

1311
<LinearLayout
1412
android:layout_width="match_parent"
1513
android:layout_height="wrap_content"
16-
android:layout_gravity="center"
1714
android:orientation="vertical"
1815
android:padding="10dp" >
1916

@@ -66,6 +63,13 @@
6663
android:layout_margin="4dp"
6764
android:text="Draw Chart" />
6865

66+
<Button
67+
android:id="@+id/button8"
68+
android:layout_width="match_parent"
69+
android:layout_height="wrap_content"
70+
android:layout_margin="4dp"
71+
android:text="Simple Design" />
72+
6973
</LinearLayout>
7074
</ScrollView>
7175

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical" >
6+
7+
<com.github.mikephil.charting.charts.BarChart
8+
android:id="@+id/barChart1"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content" />
11+
12+
</LinearLayout>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical" >
6+
7+
<com.github.mikephil.charting.charts.LineChart
8+
android:id="@+id/lineChart1"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content" />
11+
12+
</LinearLayout>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical" >
6+
7+
<com.github.mikephil.charting.charts.PieChart
8+
android:id="@+id/pieChart1"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content" />
11+
12+
</LinearLayout>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical" >
6+
7+
<com.github.mikephil.charting.charts.ScatterChart
8+
android:id="@+id/scatterChart1"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content" />
11+
12+
</LinearLayout>

MPChartExample/src/com/example/mpchartexample/LineChartActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ protected void onCreate(Bundle savedInstanceState) {
139139
// l.setPosition(LegendPosition.LEFT_OF_CHART);
140140
l.setForm(LegendForm.LINE);
141141

142+
mChart.setOffsets(100, 100, 200, 200);
143+
142144
// dont forget to refresh the drawing
143145
mChart.invalidate();
144146
}

MPChartExample/src/com/example/mpchartexample/MainActivity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import android.view.WindowManager;
99
import android.widget.Button;
1010

11+
import com.example.mpchartexample.simple.SimpleChartDemo;
12+
1113
public class MainActivity extends Activity implements OnClickListener {
1214

1315
@Override
@@ -23,13 +25,15 @@ protected void onCreate(Bundle savedInstanceState) {
2325
Button btn5 = (Button) findViewById(R.id.button5);
2426
Button btn6 = (Button) findViewById(R.id.button6);
2527
Button btn7 = (Button) findViewById(R.id.button7);
28+
Button btn8 = (Button) findViewById(R.id.button8);
2629
btn1.setOnClickListener(this);
2730
btn2.setOnClickListener(this);
2831
btn3.setOnClickListener(this);
2932
btn4.setOnClickListener(this);
3033
btn5.setOnClickListener(this);
3134
btn6.setOnClickListener(this);
3235
btn7.setOnClickListener(this);
36+
btn8.setOnClickListener(this);
3337
}
3438

3539
@Override
@@ -66,6 +70,10 @@ public void onClick(View v) {
6670
i = new Intent(this, DrawChartActivity.class);
6771
startActivity(i);
6872
break;
73+
case R.id.button8:
74+
i = new Intent(this, SimpleChartDemo.class);
75+
startActivity(i);
76+
break;
6977
}
7078
}
7179
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.example.mpchartexample.simple;
2+
import android.os.Bundle;
3+
import android.support.v4.app.Fragment;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
8+
import com.example.mpchartexample.R;
9+
import com.github.mikephil.charting.charts.BarChart;
10+
11+
12+
public class BarChartFrag extends SimpleFragment {
13+
14+
public static Fragment newInstance() {
15+
return new BarChartFrag();
16+
}
17+
18+
private BarChart mChart;
19+
20+
@Override
21+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
22+
View v = inflater.inflate(R.layout.frag_simple_bar, container, false);
23+
24+
mChart = (BarChart) v.findViewById(R.id.barChart1);
25+
26+
mChart.setData(generateData());
27+
28+
return v;
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.example.mpchartexample.simple;
2+
import android.os.Bundle;
3+
import android.support.v4.app.Fragment;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
8+
import com.example.mpchartexample.R;
9+
import com.github.mikephil.charting.charts.LineChart;
10+
11+
12+
public class LineChartFrag extends SimpleFragment {
13+
14+
public static Fragment newInstance() {
15+
return new LineChartFrag();
16+
}
17+
18+
private LineChart mChart;
19+
20+
@Override
21+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
22+
View v = inflater.inflate(R.layout.frag_simple_line, container, false);
23+
24+
mChart = (LineChart) v.findViewById(R.id.lineChart1);
25+
26+
mChart.setData(generateData());
27+
28+
return v;
29+
}
30+
}

0 commit comments

Comments
 (0)