目錄
第8節(jié).Setting Colors(MPAndroidChart中文翻譯)
第9節(jié).Formatting Data Values (ValueFormatter)(MPAndroidChart中文翻譯)
第10節(jié)-Formatting Axis Values (AxisValueFormatter)(MPAndroidChart中文翻譯)
第11節(jié).General Settings & Styling(MPAndroidChart中文翻譯)
第12節(jié).Specific Settings & Styling(MPAndroidChart中文翻譯)
第13節(jié).Legend(MPAndroidChart中文翻譯)
第14節(jié).Dynamic & Realtime Data(MPAndroidChart中文翻譯)
第15節(jié). Modifying the Viewport(MPAndroidChart中文翻譯)
第16節(jié).Animations(MPAndroidChart中文翻譯)
第17節(jié). MarkerView (Popup View)(MPAndroidChart中文翻譯)
第18節(jié). The ChartData class(MPAndroidChart中文翻譯)
第19節(jié). ChartData subclasses(MPAndroidChart中文翻譯)
第20節(jié). The DataSet class (general DataSet styling)(MPAndroidChart中文翻譯)
第21節(jié). DataSet subclasses (specific DataSet styling)(MPAndroidChart中文翻譯)
第22節(jié). The ViewPortHandler(MPAndroidChart中文翻譯)
第23節(jié). Customizing the Fill-Line-Position (FillFormatter)(MPAndroidChart中文翻譯)
第24節(jié). Proguard(MPAndroidChart中文翻譯)
第25節(jié). Realm.io mobile database(MPAndroidChart中文翻譯)
第26節(jié). Creating your own (custom) DataSets(MPAndroidChart中文翻譯)
第27節(jié). Miscellaneous (more useful stuff)(MPAndroidChart中文翻譯)
本依賴庫(kù)提供了很多修改視圖的方法(圖表的可見(jiàn)性,圖表的動(dòng)畫(huà)).注意這些方法只對(duì)LInChart,BarChart,ScatterChart和CandleStickChart起作用.
下面提到這些方法都是有Chart類提供.其他修改視圖的方法是直接通過(guò)ViewPortHandler類(沒(méi)有圖表提供中間安全性).這只適用于熟悉API的高級(jí)用戶.
注意:在設(shè)置數(shù)據(jù)之后,需要調(diào)用圖表上所有修改視圖的方法.
Restraining what's visible(設(shè)置可見(jiàn)內(nèi)容)
- setVisibleXRangeMaximum(float maxXRange): 設(shè)置首次可見(jiàn)區(qū)域(x軸)的最大值.舉個(gè)栗子:如果設(shè)置值為10,在首次展示時(shí),除非滾動(dòng),否則x軸上超過(guò)10個(gè)將不會(huì)顯示.
- setVisibleXRangeMinimum(float minXRange): 設(shè)置首次可見(jiàn)區(qū)域(x軸)的最小值.舉個(gè)栗子:如果設(shè)置值為10,在首次展示時(shí),當(dāng)x軸上有10個(gè)值時(shí)想繼續(xù)放大是不可能的.
- setVisibleYRangeMaximum(float maxYRange, AxisDependency axis): 設(shè)置首次可見(jiàn)區(qū)域(y軸)的最大值.同時(shí)你需要設(shè)置你想應(yīng)用的是左,右哪個(gè)y軸.
- setViewPortOffsets(float left, float top, float right, float bottom): 為當(dāng)前視圖設(shè)置自定義偏移量(與實(shí)際圖表窗口的偏移量).設(shè)置這將組織圖表自動(dòng)計(jì)算偏移量.調(diào)用 resetViewPortOffsets() 方法取消其設(shè)置.
只有在你知道你在做什么的時(shí)候才使用它
. - resetViewPortOffsets(): 重置通過(guò)setViewPortOffsets(...)方法設(shè)置的所有自定義偏移量.允許圖表再次自動(dòng)計(jì)算所有偏移量.
- setExtraOffsets(float left, float top, float right, float bottom): 為自動(dòng)計(jì)算完畢后的偏移量增加額外的偏移量(圖表視圖周圍).這個(gè)不會(huì)改變自動(dòng)計(jì)算的偏移量,只會(huì)在原有基礎(chǔ)上增加空間.
Moving the view(where it is amied) (在有動(dòng)畫(huà)的地方移動(dòng)視圖)
- fitScreen(): 重置所有縮放和拖拽,使圖表完全合適邊框(完全縮小).
- moveViewToX(float xValue): 將當(dāng)前窗口的左側(cè)移動(dòng)到指定的x軸位置
- moveViewToY(float yValue, AxisDependency axis): 將窗口居中所提供的y軸(左側(cè)還是右側(cè))上的指定y軸值.
- moveViewTo(float xValue, float yValue, AxisDependency axis):該方法將會(huì)將窗口的左側(cè)移動(dòng)到指定x軸位置,居中于指定y軸的指定y軸值.(結(jié)合setVisibleXRange(...)和setVisibleYRange(...)方法才有意義)
- centerViewTo(float xValue, float yValue, AxisDependency axis): 該方法將會(huì)將窗口居中在x軸和y軸的指定坐標(biāo)位置.(結(jié)合 setVisibleXRange(...) 和setVisibleYRange(...)方法才有意義)
Moving the view with animations(用動(dòng)畫(huà)移動(dòng)視圖)
(v2.2.3正式版開(kāi)始出現(xiàn))
- moveViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration): 該方法將窗口左側(cè)移動(dòng)到x軸指定位置,居中于指定y軸的指定y軸值位置,并且伴隨著動(dòng)畫(huà)形式.
- centerViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration): 該方法將窗口居中于x軸和y軸的指定位置,并伴隨動(dòng)畫(huà).
提醒: 所有的moveViewTo(...)方法都是自動(dòng)調(diào)用刷新圖表的方法,無(wú)需額外調(diào)用invalidate()方法.
Zooming(programmatically) 縮放
- zoomIn(): 以圖表中心為縮放中心,放大1.4倍.
- zoomOut(): 以圖表中心為縮放中心,縮小0.7倍.
- zoom(float scaleX, float scaleY, float x, float y): 以x,y表示的坐標(biāo)點(diǎn)(單位px)為縮放中心,以scaleX和xcaleY為縮放因子進(jìn)行縮放.記住縮放值為1時(shí)表示不縮放.
- zoom(float scaleX, float scaleY, float xValue, float yValue, AxisDependency axis):以x,y表示的實(shí)際數(shù)據(jù)點(diǎn)(非坐標(biāo)軸)為縮放中心,以scaleX和xcaleY為縮放因子進(jìn)行縮放.記住縮放值為1時(shí)表示不縮放.
Zooming with animations 動(dòng)畫(huà)縮放
(v2.2.3正式版本開(kāi)始可用)
- zoomAndCenterAnimated(float scaleX, float scaleY, float xValue, float yValue, AxisDependency axis, long duration): 以指定的縮放因子進(jìn)行縮放,并以動(dòng)畫(huà)的方式將窗口居中于指定軸上的指定位置.
For example 舉個(gè)栗子
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()