原創(chuàng)|使用教程|編輯:王香|2018-08-10 09:53:28.000|閱讀 1484 次
概述:本文詳細(xì)介紹了如何在TeeChart中應(yīng)用滾動和縮放
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
【下載TeeChart.Net最新版本】
要放大圖表,請?jiān)谝糯蟮膮^(qū)域的左上角按住鼠標(biāo)左鍵并按住鼠標(biāo)按鈕,將矩形拖動到縮放區(qū)域的右下角。釋放鼠標(biāo)按鈕,圖表將重繪所選區(qū)域。要撤消縮放,請?jiān)?ldquo;Chart圖表”區(qū)域的任意位置按鼠標(biāo)左鍵,然后按住鼠標(biāo)按鈕向上和向左拖動,釋放按鈕,圖表將重繪為最初定義的圖表區(qū)域。
要滾動圖表,按右鼠標(biāo)按鈕并按住鼠標(biāo)按鈕,將鼠標(biāo)拖動到您想要滾動圖表的方向。釋放鼠標(biāo)按鈕時,圖表將保留在新位置。要撤消滾動,請?jiān)?ldquo;Chart圖表”區(qū)域的任意位置按鼠標(biāo)左鍵,然后按住鼠標(biāo)按鈕向上和向左拖動。釋放按鈕,圖表將重繪為最初定義的圖表區(qū)域。
默認(rèn)情況下啟用縮放,使用Zoom.Allow屬性禁用縮放。有關(guān)與縮放關(guān)聯(lián)的屬性和方法的完整列表,請參見縮放類。要定義縮放的矩形區(qū)域,請使用ZoomRect方法。 示例
[C#.Net]
tChart1.Zoom.ZoomRect(new Rectangle(100,100,120,120));
[VB.Net]
TChart1.Zoom.ZoomRect(New Rectangle(100, 100, 120, 120))
ZoomRect坐標(biāo)以屏幕像素定義,其中0,0是圖表面板的左上角。以下代碼將放大第2和第5個x軸點(diǎn)之間的區(qū)域,將y軸設(shè)置為整個圖表的最大和最小點(diǎn)的比例:
[C#.Net]
int x = points1.CalcXPos(2); int y = tChart1.Axes.Left.CalcYPosValue(tChart1.Axes.Left.MaxYValue); int height = tChart1.Axes.Left.CalcYPosValue(tChart1.Axes.Left.MinYValue) - tChart1.Axes.Left.CalcYPosValue(tChart1.Axes.Left.MaxYValue); int width = points1.CalcXPos(5) - x; Rectangle r = new Rectangle(x,y,width,height); tChart1.Zoom.ZoomRect(r);
[VB.Net]
Dim X As Integer = Points1.CalcXPos(2) Dim Y As Integer = TChart1.Axes.Left.CalcYPosValue(TChart1.Axes.Left.MaxYValue) Dim Height As Integer = TChart1.Axes.Left.CalcYPosValue(TChart1.Axes.Left.MinYValue) - TChart1.Axes.Left.CalcYPosValue(TChart1.Axes.Left.MaxYValue) Dim Width As Integer = Points1.CalcXPos(5) - X Dim R As New Rectangle(X, Y, Width, Height) TChart1.Zoom.ZoomRect(R) TChart1.Zoom.Undo
動畫縮放提供步進(jìn)縮放。您可以將Animated設(shè)置為啟用并為縮放定義交錯步驟,而不是一步跳過“縮小”到“放大”。啟用動畫后,您可以使用鼠標(biāo)或代碼手動縮放。 例
[C#.Net]
int x = points1.CalcXPos(2); int y = tChart1.Axes.Left.CalcYPosValue(tChart1.Axes.Left.MaxYValue); int height = tChart1.Axes.Left.CalcYPosValue(tChart1.Axes.Left.MinYValue) - tChart1.Axes.Left.CalcYPosValue(tChart1.Axes.Left.MaxYValue); int width = points1.CalcXPos(5) - x; Rectangle r = new Rectangle(x,y,width,height); tChart1.Zoom.Animated = true; tChart1.Zoom.AnimatedSteps = 100; tChart1.Zoom.ZoomRect(r);
[VB.Net]
Dim X As Integer = Points1.CalcXPos(2) Dim Y As Integer = TChart1.Axes.Left.CalcYPosValue(TChart1.Axes.Left.MaxYValue) Dim Height As Integer = TChart1.Axes.Left.CalcYPosValue(TChart1.Axes.Left.MinYValue) - TChart1.Axes.Left.CalcYPosValue(TChart1.Axes.Left.MaxYValue) Dim Width As Integer = Points1.CalcXPos(5) - X Dim R As New Rectangle(X, Y, Width, Height) TChart1.Zoom.Animated = True TChart1.Zoom.AnimatedSteps = 100 TChart1.Zoom.ZoomRect(R)
手動縮放或通過代碼縮放將觸發(fā)TChart.Zoomed事件,默認(rèn)情況下,縮小將觸發(fā)TChart.UndoneZoom事件。
滾動在所有方向上啟用,使用Scroll.Allow屬性禁用Scroll或?qū)croll限制為一個方向,按代碼滾動的最簡單方法是使用Axis Scroll方法:
[C#.Net]
tChart1.Axes.Bottom.Scroll(3, false);
[VB.Net]
TChart1.Axes.Bottom.Scroll(3, False)
該值是偏移量,'False'指的是TeeChart是否允許滾動超出系列值限制。控制滾動的另一種方法是定義Axis maximum和minumum以按代碼滾動:
[C#.Net]
private void Form1_Load(object sender, System.EventArgs e) { 
        int range = Convert.ToInt32(bar1.XValues.Maximum - bar1.XValues.Minimum / 2); 
        bar1.FillSampleValues(20); 
        tChart1.Panning.Allow = ScrollModes.None; 
        hScrollBar1.Value = range; 
        hScrollBar1.Minimum = range - 50; 
        hScrollBar1.Maximum = range + 50; 
} 
     
private void hScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) { 
        tChart1.Axes.Bottom.Automatic = false; 
        tChart1.Axes.Bottom.Minimum = e.NewValue; 
        tChart1.Axes.Bottom.Maximum = e.NewValue + bar1.Count; 
}
[VB.Net]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
            Dim Range As Integer = Bar1.XValues.Maximum - Bar1.XValues.Minimum / 2 
            Bar1.FillSampleValues(20) 
            TChart1.Panning.Allow = Steema.TeeChart.ScrollModes.None 
            HScrollBar1.Value = Range 
            HScrollBar1.Minimum = Range - 50 
            HScrollBar1.Maximum = Range + 50 
End Sub 
 
Private Sub HScrollBar1_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll 
            TChart1.Axes.Bottom.Automatic = False 
            TChart1.Axes.Bottom.Minimum = e.NewValue 
            TChart1.Axes.Bottom.Maximum = e.NewValue + Bar1.Count 
End Sub
					本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@ke049m.cn