日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > Android >内容正文

Android

Android开源框架——图表MPAndroidChart

發(fā)布時(shí)間:2025/3/21 Android 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android开源框架——图表MPAndroidChart 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

開(kāi)源官網(wǎng):https://github.com/PhilJay/MPAndroidChart

Android開(kāi)源框架——圖表MPAndroidChart

  • 特點(diǎn)
  • 配置
  • 圖表類型
  • Demo

MPAndroidChart是一個(gè)功能強(qiáng)大,簡(jiǎn)單易用的圖表開(kāi)源庫(kù),支持API8及以上版本。它能實(shí)現(xiàn)Android與IOS跨平臺(tái)開(kāi)發(fā)。


特點(diǎn)

  • 8種不同的圖表類型
  • 支持縮放功能
  • 支持拖動(dòng)與平移
  • 組合圖(線性,條形,散點(diǎn),k線)
  • 雙(單)軸
  • 可自定義坐標(biāo)軸(x軸,y軸)
  • 突出顯示值 (可定制彈出視圖)
  • 將圖表以JPG,PNG或txt形式保存到SD卡中
  • 預(yù)定義顏色模板
  • 圖例(自動(dòng)產(chǎn)生,可定制)
  • 構(gòu)建動(dòng)畫效果(x軸,y軸都可以)
  • 限制線(提供額外的信息)
  • 完全可定制化(畫筆,字體,圖例,顏色,背景,手勢(shì),虛線)
  • 線性表或條形表中可以縮放或者滾動(dòng)達(dá)到30000條數(shù)據(jù)
  • Gradle支持
  • 繪制的數(shù)據(jù)可以直接來(lái)自Realm.io移動(dòng)數(shù)據(jù)庫(kù)中


配置

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 {@Overrideprotected 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

    《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

    總結(jié)

    以上是生活随笔為你收集整理的Android开源框架——图表MPAndroidChart的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。