資源: https://github.com/PhilJay/MPAndroidChart
文檔: https://javadoc.jitpack.io/com/github/PhilJay/MPAndroidChart/v3.1.0/javadoc/
A powerful Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations.
Android Project 項目中添加 MPAndroidChart
* Project 項目中的 build.gradle 添加配置
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
* App 中的 build.gradle 添加配置
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
* Maven Setup (Project 項目下的 pom.xml)
<!-- <repositories> section of pom.xml -->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<!-- <dependencies> section of pom.xml -->
<dependency>
<groupId>com.github.PhilJay</groupId>
<artifactId>MPAndroidChart</artifactId>
<version>v3.1.0</version>
</dependency>
MPAndroidChart 基本概念
LineChart // 折線表,存線集合,與xml中的控件綁定實例化
LineData // 線集合,所有折線以數組的形式存到此集合中
LineDataSet // 點集合,即一條折線
Entry // 某條折線上的一個點
XAxis // X軸
YAxis // Y軸,Y軸分左右,通過lineChart的getAxisLeft()、getAxisRight()得到
Legend // 圖例,即標識哪一條曲線,如用紅色標識電流折線,藍色標識電壓折線
LimitLine // 限制線
Description // 描述
List<Float> list = new ArrayList<>(); // 存放數據的list列表
List<Entry> entrys = new ArrayList<>(); // 存放折線需要的點的列表
LineDataSet mStepTimeDataSet = new LineDataSet(entrys, "步時間"); // LineDataSet:點集合,即一條線
本文借用 Amarao <https://blog.csdn.net/jinmie0193/article/details/90239935> 諸多內容,非常感謝~~