Android: MPAndroidChart 图表框架使用笔记

资源: https://github.com/PhilJay/MPAndroidChart

文档: https://javadoc.jitpack.io/com/github/PhilJay/MPAndroidChart/v3.1.0/javadoc/

A powerful rocket 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> 诸多内容,非常感谢~~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章