Android开源框架——图表MPAndroidChart
来源:互联网 发布:手机淘宝评价怎么删 编辑:程序博客网 时间:2024/05/16 11:54
开源官网:https://github.com/PhilJay/MPAndroidChart
Android开源框架——图表MPAndroidChart
- 特点
- 配置
- 图表类型
- Demo
MPAndroidChart是一个功能强大,简单易用的图表开源库,支持API8及以上版本。它能实现Android与IOS跨平台开发。
特点
- 8种不同的图表类型
- 支持缩放功能
- 支持拖动与平移
- 组合图(线性,条形,散点,k线)
- 双(单)轴
- 可自定义坐标轴(x轴,y轴)
- 突出显示值 (可定制弹出视图)
- 将图表以JPG,PNG或txt形式保存到SD卡中
- 预定义颜色模板
- 图例(自动产生,可定制)
- 构建动画效果(x轴,y轴都可以)
- 限制线(提供额外的信息)
- 完全可定制化(画笔,字体,图例,颜色,背景,手势,虚线)
- 线性表或条形表中可以缩放或者滚动达到30000条数据
- Gradle支持
- 绘制的数据可以直接来自Realm.io移动数据库中
配置
Gradle
- Add the following to your build.gradle:
repositories { maven { url "https://jitpack.io" }}dependencies { compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'}
Maven
- Add the following to your pom.xml:
<repository> <id>jitpack.io</id> <url>https://jitpack.io</url></repository><dependency> <groupId>com.github.PhilJay</groupId> <artifactId>MPAndroidChart</artifactId> <version>v2.2.5</version></dependency>
图表类型
LineChart (with legend, simple design)
LineChart (with legend, simple design)
LineChart (cubic lines)
LineChart (gradient fill)
- Combined-Chart (bar- and linechart in this case)
- BarChart (with legend, simple design)
BarChart (grouped DataSets)
Horizontal-BarChart
PieChart (with selection, …)
- ScatterChart (with squares, triangles, circles, … and more)
CandleStickChart (for financial data)
BubbleChart (area covered by bubbles indicates the value)
- RadarChart (spider web chart)
Demo
package com.android.chart;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import com.github.mikephil.charting.charts.BarChart;import com.github.mikephil.charting.data.BarData;import com.github.mikephil.charting.data.BarDataSet;import com.github.mikephil.charting.data.BarEntry;import com.github.mikephil.charting.utils.ColorTemplate;import java.util.ArrayList;import java.util.List;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); List<BarEntry> entries = new ArrayList<>(); entries.add(new BarEntry(4f,0)); entries.add(new BarEntry(8f,1)); entries.add(new BarEntry(6f,2)); entries.add(new BarEntry(12f,3)); entries.add(new BarEntry(18f,4)); entries.add(new BarEntry(9f,5)); BarDataSet dataSet = new BarDataSet(entries,"# of Calls"); dataSet.setColors(ColorTemplate.COLORFUL_COLORS); List<String> labels = new ArrayList<>(); labels.add("January"); labels.add("February"); labels.add("March"); labels.add("April"); labels.add("May"); labels.add("June"); BarData data = new BarData(labels,dataSet); BarChart barChart = new BarChart(this); barChart.setData(data); barChart.setDescription("# of times Alice called Bob"); setContentView(barChart); }}
参考:
【1】http://www.jianshu.com/p/791b7eba2dd4
【2】 http://blog.csdn.net/shineflowers/article/details/44701645
【3】http://code.tutsplus.com/tutorials/add-charts-to-your-android-app-using-mpandroidchart–cms-23335
2 1
- Android开源框架——图表MPAndroidChart
- MPAndroidChart开源图表框架—-柱状图(二)
- Android强大的图表开源——MPAndroidChart
- Android开源图表---MPAndroidChart
- android图表——MPAndroidchart
- android开源图表库MPAndroidChart
- Android开源图表库MPAndroidChart
- android开源图表库MPAndroidChart
- android开源图表库MPAndroidChart
- Android 开源图表库MPAndroidChart
- android开源图表库MPAndroidChart
- android开源图表库MPAndroidChart
- android开源图表库MPAndroidChart
- Android开源图表库MPAndroidChart
- android开源图表库MPAndroidChart
- android开源图表库MPAndroidChart
- Android图表库MPAndroidChart(七)—饼状图
- android图表框架 MPAndroidChart 学习记录
- 用Shell命令批量压缩指定目录下指定目录到目标目录中
- How to Marshal a C++ Class
- 分层
- Toolbar滑动效果实现总结
- javaweb 过滤器和监听器总结
- Android开源框架——图表MPAndroidChart
- 数列[HNOI2013][Codevs2089]
- mouseenter()和mouseleave()一对绝佳搭档
- text data bss heap stack
- 常用正则表达式
- 如何使用 sbt 下载项目的依赖包的源码
- 开始
- 第10周 C语言及程序设计提高例程-40 小小型应用系统开发指导(四)
- Eclipse新建工程没有minGW