hellocharts-android开源图表库(效果非常好)
http://jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/1107/1930.html
之前我們介紹了一個非常優(yōu)秀開源圖表庫?MPAndroidChart??,但是我們今天介紹的將是一個更為優(yōu)秀的圖表庫,比MPAndroidChart性能更好,功能更完善,UI風(fēng)格更美觀,坐標軸更精細。
他就是github上出現(xiàn)的新項目HelloCharts。
HelloCharts支持以下chart類型:
-
Line chart(cubic lines, filled lines, scattered points)
-
Column chart(grouped, stacked, negative values)
-
Pie chart
-
Bubble chart
-
Combo chart(columns/lines)
-
Preview charts(for column chart and line chart)
此外還具有以下特點:
-
支持縮放、滑動以及平移。Zoom(pinch to zoom, double tap zoom), scroll and fling
-
支持自定義坐標軸(比如坐標軸位置:上下左右內(nèi)部),支持自動生成坐標軸。Custom and auto-generated axes(top, bottom, left, right, inside)
-
動畫(Animations)
-
支持預(yù)覽,即在chart下面會有一個坐標密度更細的附屬chart,當選中附屬chart的某一區(qū)域,附屬chart上面的chart會顯示選中區(qū)域的更詳細情況。
-
下面是一些效果截圖:
我能用妙趣橫生來形容嗎、、
編譯以及使用方法
每一種chart都可以在xml中定義:
| 1 2 3 4 | <lecho.lib.hellocharts.view.LineChartView ????android:id="@+id/chart" ????android:layout_width="match_parent" ????android:layout_height="match_parent"?/> |
當然也可以在java代碼中直接創(chuàng)建:
| 1 2 | LineChartView?chart?=?new?LineChartView(context); layout.addView(chart); |
可以通過一些公共方法設(shè)置其行為屬性,下面是一些例子:
| 1 2 3 | Chart.setInteractive(boolean?isInteractive); Chart.setZoomType(ZoomType?zoomType); Chart.setContainerScrollEnabled(boolean?isEnabled,?ContainerScrollType?type); |
或者是用數(shù)據(jù)模型定義一些顯示的方式:
| 1 2 3 | ChartData.setAxisXBottom(Axis?axisX); ColumnChartData.setStacked(boolean?isStacked); Line.setStrokeWidth(int?strokeWidthDp); |
每一種chart都有自己的數(shù)據(jù)模型以及設(shè)置數(shù)據(jù)的方法,下面以LineChart為例:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | List<PointValue>?values?=?new?ArrayList<PointValue>(); values.add(new?PointValue(0,?2)); values.add(new?PointValue(1,?4)); values.add(new?PointValue(2,?3)); values.add(new?PointValue(3,?4)); //In?most?cased?you?can?call?data?model?methods?in?builder-pattern-like?manner. Line?line?=?new?Line(values).setColor(Color.Blue).setCubic(true); List<Line>?lines?=?new?ArrayList<Line>(); lines.add(line); LineChartData?data?=?new?LineChartData(); data.setLines(lines); LineChartView?chart?=?new?LineChartView(context); chart.setLineChartData(data); |
代碼下載地址
http://jcodecraeer.com/a/opensource/2014/1107/1931.html
總結(jié)
以上是生活随笔為你收集整理的hellocharts-android开源图表库(效果非常好)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用动画实现android app启动界面
- 下一篇: 欲了解Android Studio,必先