MPAndroidChartAndroid开发技术交流

15. Modifying the Viewport(MPAnd

2017-11-08  本文已影响19人  xiaobug

目录

第8节.Setting Colors(MPAndroidChart中文翻译)
第9节.Formatting Data Values (ValueFormatter)(MPAndroidChart中文翻译)
第10节-Formatting Axis Values (AxisValueFormatter)(MPAndroidChart中文翻译)
第11节.General Settings & Styling(MPAndroidChart中文翻译)
第12节.Specific Settings & Styling(MPAndroidChart中文翻译)
第13节.Legend(MPAndroidChart中文翻译)
第14节.Dynamic & Realtime Data(MPAndroidChart中文翻译)
第15节. Modifying the Viewport(MPAndroidChart中文翻译)
第16节.Animations(MPAndroidChart中文翻译)
第17节. MarkerView (Popup View)(MPAndroidChart中文翻译)
第18节. The ChartData class(MPAndroidChart中文翻译)
第19节. ChartData subclasses(MPAndroidChart中文翻译)
第20节. The DataSet class (general DataSet styling)(MPAndroidChart中文翻译)
第21节. DataSet subclasses (specific DataSet styling)(MPAndroidChart中文翻译)
第22节. The ViewPortHandler(MPAndroidChart中文翻译)
第23节. Customizing the Fill-Line-Position (FillFormatter)(MPAndroidChart中文翻译)
第24节. Proguard(MPAndroidChart中文翻译)
第25节. Realm.io mobile database(MPAndroidChart中文翻译)
第26节. Creating your own (custom) DataSets(MPAndroidChart中文翻译)
第27节. Miscellaneous (more useful stuff)(MPAndroidChart中文翻译)

本依赖库提供了很多修改视图的方法(图表的可见性,图表的动画).注意这些方法只对LInChart,BarChart,ScatterChart和CandleStickChart起作用.

下面提到这些方法都是有Chart类提供.其他修改视图的方法是直接通过ViewPortHandler类(没有图表提供中间安全性).这只适用于熟悉API的高级用户.

注意:在设置数据之后,需要调用图表上所有修改视图的方法.

Restraining what's visible(设置可见内容)

Moving the view(where it is amied) (在有动画的地方移动视图)

Moving the view with animations(用动画移动视图)

(v2.2.3正式版开始出现)

提醒: 所有的moveViewTo(...)方法都是自动调用刷新图表的方法,无需额外调用invalidate()方法.

Zooming(programmatically) 缩放

Zooming with animations 动画缩放

(v2.2.3正式版本开始可用)

For example 举个栗子

chart.setData(...); // first set data

// now modify viewport
chart.setVisibleXRangeMaximum(20); // allow 20 values to be displayed at once on the x-axis, not more
chart.moveViewToX(10); // set the left edge of the chart to x-index 10
// moveViewToX(...) also calls invalidate()
上一篇下一篇

猜你喜欢

热点阅读