前言:在android开发过程中,图表是使用比较频繁的功能,目前开源的框架也比较多,如大名鼎鼎的mpChart,WilliamChart等。
不过在使用过程中,各有各的好处,如mpChart在我使用lineChart的时候效果总是不太如意,而WilliamChart的使用在studio环境中表现不错,但是在eclipse环境中总是报错。无法集成。所以网上搜索了其他的开源框架,找到了hellochart开源项目。
http://download.csdn.net/detail/xygy8860/9375426
1.首先是折线图
布局很简单
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#32CD32"
>
然后在activity中findViewById即可。
下面的变量是对lineChart的配置,可以显示多行,我都写上了注释。
/******************* hellochart ******************/
@Bind(R.id.chart) lecho.lib.hellocharts.view.LineChartView chart;
private boolean hasAxes = true;
private boolean hasAxesNames = true; // 横竖行的名字
private boolean hasLines = true;
private boolean hasPoints = true;
private ValueShape shape = ValueShape.CIRCLE;
private boolean isFilled = false;
private boolean hasLabels = false; // 是否显示点的数据
private boolean isCubic = false;
private boolean hasLabelForSelected = false;
private boolean pointsHaveDifferentColor;
private LineChartData data;