在Android开发中,我们不免会遇到图表展示的需求,以下是本人之前star的悬浮窗的开源项目,供大家参考:
1. WilliamChart:创建图表的Android库
2. HelloCharts:兼容到API8的Android图表库
3. MPAndroidChart :一个强大的Android图表视图/图形库
一、WilliamChart
项目地址:https://github.com/diogobernardino/WilliamChart
Williamchart是一个Android库,用于帮助在Android应用程序中实现图表。对于那些想要贡献的人,我的想法不仅仅是实现传统的图表功能,而是在表示和可视化数据时可以愉快和直观的东西。我宁愿保持图表简洁,而不是过度使用。
目前它提供:
-
LineChartView
-
BarChartView
-
HorizontalBarChartView
-
StackBarChartView
-
HorizontalStackBarChartView
使用方式:
compile 'com.diogobernardino:williamchart:2.5.0'
效果图:
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL2kTO2EjMwIjNtkTOwITMwUTOwMTMwEDOxAjMtYTM2IDO28CXwEDOxAjMvwlNxYjM4YzLcd2bsJ2Lc12bj5ycn9Gbi52YugTMwIzZtl2Lc9CX6MHc0RHaiojIsJye.png)
二、HelloCharts
项目地址:https://github.com/lecho/hellocharts-android
适用于Android的图表库兼容API 8+(Android 2.2)。在硬件加速可用时效果最佳,因此建议使用API 14+(Android 4.0)。
特征:
- 折线图(立方线,实线,散点)
- 柱形图(分组,堆叠,负值)
- 饼形图
- 气泡图
- 组合图表(列/行)
- 预览图表(用于柱形图和折线图)
- 缩放(捏合缩放,双击缩放),滚动和闪烁
- 自定义和自动生成的轴(顶部,底部,左侧,右侧,内侧)
- 动画
使用方式:
Android Studio/Gradle
- Maven Central/jCenter, add dependency to your
:build.gradle
dependencies{
compile 'com.github.lecho:hellocharts-library:[email protected]'
}
- JitPack.io, add
repositiory and dependency to yourjitpack.io
:build.gradle
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.lecho:hellocharts-android:v1.5.8'
}
效果图:
三、MPAndroidChart
项目地址:https://github.com/PhilJay/MPAndroidChart
一个强大的Android图表视图/图表视图库,支持线条 - 饼图 - 雷达 - 气泡和烛台图表以及缩放,拖动和动画。
使用方式:
Gradle
- Project level
build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
- App level
build.gradle
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
}
Maven
<!-- <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.0.3</version>
</dependency>