翻譯|使用教程|編輯:王香|2018-09-19 14:40:46.000|閱讀 406 次
概述:本文詳細(xì)介紹了在TeeChart for Java使用代碼和鼠標(biāo)來(lái)實(shí)現(xiàn)縮放和滾動(dòng)功能。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
【下載TeeChart for Java最新版本】
要放大圖表,請(qǐng)?jiān)谝糯蟮膮^(qū)域的左上角按鼠標(biāo)右鍵,并按住鼠標(biāo)按鈕,將矩形拖動(dòng)到縮放區(qū)域的右下角。釋放鼠標(biāo)按鈕將強(qiáng)制圖表重繪所選區(qū)域。 要撤消縮放,請(qǐng)?jiān)?ldquo;Chart”區(qū)域的任意位置按鼠標(biāo)左鍵,然后按住鼠標(biāo)按鈕向上和向左拖動(dòng)。釋放按鈕將強(qiáng)制圖表重繪為最初定義的圖表區(qū)域。
要滾動(dòng)圖表,按下鼠標(biāo)左鍵,并保持按下,拖動(dòng)鼠標(biāo)在你想滾動(dòng)圖表的方向。釋放鼠標(biāo)按鈕時(shí),圖表將保留在新位置。 要撤消滾動(dòng),請(qǐng)?jiān)?ldquo;Chart”區(qū)域的任意位置按鼠標(biāo)左鍵,然后按住鼠標(biāo)按鈕向上和向左拖動(dòng)。釋放按鈕,圖表將重繪為最初定義的圖表區(qū)域。
默認(rèn)情況下,啟用縮放。使用Zoom.getAllow方法禁用縮放。要定義縮放的矩形區(qū)域,請(qǐng)使用ZoomRect方法,例:
tChart1.getZoom().zoomRect(new com.steema.teechart.Rectangle(100,100,120,120));
ZoomRect坐標(biāo)以屏幕像素定義,其中0,0是圖表面板的左上角。以下代碼將放大第2和第5個(gè)x軸點(diǎn)之間的區(qū)域,將y軸設(shè)置為整個(gè)圖表的最大和最小點(diǎn)的比例:
int x = points1.calcXPos(2); int y = tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMaxYValue()); int height = tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMinYValue()) - tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMaxYValue()); int width = points1.calcXPos(5) - x; com.steema.teechart.Rectangle r = new com.steema.teechart.Rectangle(x,y,width,height); tChart1.getZoom().zoomRect(r);
使用“Undo”縮?。?/p>
tChart1.getZoom().undo();
動(dòng)畫縮放提供步進(jìn)縮放。您可以將AnimatedZoom設(shè)置為啟用并定義縮放的交錯(cuò)步驟,而不是一步跳過(guò)“縮小”到“放大”。啟用AnimatedZoom后,您可以使用鼠標(biāo)或代碼手動(dòng)縮放,例:
int x = points1.calcXPos(2); int y = tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMaxYValue()); int height = tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMinYValue()) - tChart1.getAxes().getLeft().calcYPosValue(tChart1.getAxes().getLeft().getMaxYValue()); int width = points1.calcXPos(5) - x; com.steema.teechart.Rectangle r = new com.steema.teechart.Rectangle(x,y,width,height); tChart1.getZoom().setAnimated(true); tChart1.getZoom().setAnimatedSteps(100); tChart1.getZoom().zoomRect(r);
手動(dòng)或通過(guò)代碼放大將觸發(fā)TChart.Zoomed事件,縮小將觸發(fā)TChart.UndoneZoom事件。
默認(rèn)情況下,滾動(dòng)在所有方向上啟用。使用Scroll.Allow屬性禁用Scroll或?qū)croll限制為一個(gè)方向。 按代碼滾動(dòng)的最簡(jiǎn)單方法是使用Axis Scroll方法:
tChart2.getAxes().getBottom().scroll(3, false);
該值是偏移量。'False'指的是TeeChart是否允許滾動(dòng)超出系列值限制。 控制滾動(dòng)的另一種方法是定義Axis maximum和minumum以按代碼滾動(dòng):
private void Load() { int range = com.steema.teechart.Utils.Round((bar1.getXValues().getMaximum() - bar1.getXValues().getMinimum() / 2)); bar1.fillSampleValues(20); tChart1.getPanning().setAllow(ScrollModes.NONE); jScrollBar1.setValue(range); jScrollBar1.setMinimum(range - 50); jScrollBar1.setMaximum(range + 50); } public void jScrollBar1_propertyChange(PropertyChangeEvent evt) { tChart1.getAxes().getBottom().setAutomatic(false); tChart1.getAxes().getBottom().setMinimum(jScrollBar1.getValue()); tChart1.getAxes().getBottom().setMaximum(jScrollBar1.getValue() + bar1.getCount()); }
購(gòu)買TeeChart for Java正版授權(quán),請(qǐng)點(diǎn)擊“”喲!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn