forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPieChartFrag.java
More file actions
53 lines (39 loc) · 1.79 KB
/
PieChartFrag.java
File metadata and controls
53 lines (39 loc) · 1.79 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
package com.xxmassdeveloper.mpchartexample.fragments;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.utils.Legend;
import com.github.mikephil.charting.utils.Legend.LegendPosition;
import com.xxmassdeveloper.mpchartexample.R;
public class PieChartFrag extends SimpleFragment {
public static Fragment newInstance() {
return new PieChartFrag();
}
private PieChart mChart;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_pie, container, false);
mChart = (PieChart) v.findViewById(R.id.pieChart1);
mChart.setDescription("");
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Regular.ttf");
mChart.setValueTypeface(tf);
mChart.setCenterTextTypeface(Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf"));
mChart.setUsePercentValues(true);
mChart.setCenterText("Quarterly\nRevenue");
mChart.setCenterTextSize(22f);
// radius of the center hole in percent of maximum radius
mChart.setHoleRadius(45f);
mChart.setTransparentCircleRadius(50f);
// enable / disable drawing of x- and y-values
// mChart.setDrawYValues(false);
// mChart.setDrawXValues(false);
mChart.setData(generatePieData());
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
return v;
}
}