翻譯|使用教程|編輯:王香|2018-09-19 14:40:46.000|閱讀 406 次
概述:本文詳細介紹了在TeeChart for Java使用代碼和鼠標來實現縮放和滾動功能。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
【下載TeeChart for Java最新版本】
要放大圖表,請在要放大的區域的左上角按鼠標右鍵,并按住鼠標按鈕,將矩形拖動到縮放區域的右下角。釋放鼠標按鈕將強制圖表重繪所選區域。 要撤消縮放,請在“Chart”區域的任意位置按鼠標左鍵,然后按住鼠標按鈕向上和向左拖動。釋放按鈕將強制圖表重繪為最初定義的圖表區域。
要滾動圖表,按下鼠標左鍵,并保持按下,拖動鼠標在你想滾動圖表的方向。釋放鼠標按鈕時,圖表將保留在新位置。 要撤消滾動,請在“Chart”區域的任意位置按鼠標左鍵,然后按住鼠標按鈕向上和向左拖動。釋放按鈕,圖表將重繪為最初定義的圖表區域。
默認情況下,啟用縮放。使用Zoom.getAllow方法禁用縮放。要定義縮放的矩形區域,請使用ZoomRect方法,例:
tChart1.getZoom().zoomRect(new com.steema.teechart.Rectangle(100,100,120,120));
ZoomRect坐標以屏幕像素定義,其中0,0是圖表面板的左上角。以下代碼將放大第2和第5個x軸點之間的區域,將y軸設置為整個圖表的最大和最小點的比例:
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”縮小:
tChart1.getZoom().undo();
動畫縮放提供步進縮放。您可以將AnimatedZoom設置為啟用并定義縮放的交錯步驟,而不是一步跳過“縮小”到“放大”。啟用AnimatedZoom后,您可以使用鼠標或代碼手動縮放,例:
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);
手動或通過代碼放大將觸發TChart.Zoomed事件,縮小將觸發TChart.UndoneZoom事件。
默認情況下,滾動在所有方向上啟用。使用Scroll.Allow屬性禁用Scroll或將Scroll限制為一個方向。 按代碼滾動的最簡單方法是使用Axis Scroll方法:
tChart2.getAxes().getBottom().scroll(3, false);
該值是偏移量。'False'指的是TeeChart是否允許滾動超出系列值限制。 控制滾動的另一種方法是定義Axis maximum和minumum以按代碼滾動:
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()); }
購買TeeChart for Java正版授權,請點擊“”喲!
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn