菜鸟学习笔记-MPChart简单的折线图LineChart

#简单就完事了

Xml

    <com.github.mikephil.charting.charts.LineChart
        android:id="@+id/Linechart"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >com.github.mikephil.charting.charts.LineChart>

xml的文件名直接复制就可以了
菜鸟学习笔记-MPChart简单的折线图LineChart_第1张图片
Java

public class SimpleLinechart extends Activity {
     
	LineChart lineChart;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
     
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_simple_linechart);
		lineChart=(LineChart) findViewById(R.id.Linechart);
		
		ArrayList<String>xValues=new ArrayList<String>();
		for (int i = 0; i < 5; i++) 
		{
     
			xValues.add(""+i);
		}
		ArrayList<Entry>yValues=new ArrayList<Entry>();
		yValues.add(new Entry(1,1));
		yValues.add(new Entry(2,2));
		yValues.add(new Entry(3,3));
		yValues.add(new Entry(4,4));
		yValues.add(new Entry(5,5));
		
		LineDataSet line1=new LineDataSet(yValues, "简单的折线图");
		
		LineData lineData=new LineData(xValues,line1);
		lineChart.setData(lineData);
	}
}

了解更多Linechart属性可以看
https://blog.csdn.net/hanmoliuxuan/article/details/82148723

你可能感兴趣的:(MPChart,MPchart,Android,简单)