• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.xxmassdeveloper.mpchartexample.fragments;
2 import android.graphics.Typeface;
3 import android.os.Bundle;
4 import androidx.annotation.NonNull;
5 import androidx.fragment.app.Fragment;
6 import android.view.LayoutInflater;
7 import android.view.View;
8 import android.view.ViewGroup;
9 
10 import com.github.mikephil.charting.charts.LineChart;
11 import com.github.mikephil.charting.components.Legend;
12 import com.github.mikephil.charting.components.XAxis;
13 import com.github.mikephil.charting.components.YAxis;
14 import com.xxmassdeveloper.mpchartexample.R;
15 
16 
17 public class ComplexityFragment extends SimpleFragment {
18 
19     @NonNull
newInstance()20     public static Fragment newInstance() {
21         return new ComplexityFragment();
22     }
23 
24     @SuppressWarnings("FieldCanBeLocal")
25     private LineChart chart;
26 
27     @Override
onCreateView(@onNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)28     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
29         View v = inflater.inflate(R.layout.frag_simple_line, container, false);
30 
31         chart = v.findViewById(R.id.lineChart1);
32 
33         chart.getDescription().setEnabled(false);
34 
35         chart.setDrawGridBackground(false);
36 
37         chart.setData(getComplexity());
38         chart.animateX(3000);
39 
40         Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
41 
42         Legend l = chart.getLegend();
43         l.setTypeface(tf);
44 
45         YAxis leftAxis = chart.getAxisLeft();
46         leftAxis.setTypeface(tf);
47 
48         chart.getAxisRight().setEnabled(false);
49 
50         XAxis xAxis = chart.getXAxis();
51         xAxis.setEnabled(false);
52 
53         return v;
54     }
55 }
56