• <menu id="w2i4a"></menu>
  • logo TeeChart .NET教程2018
    文檔首頁(yè)>>TeeChart .NET教程2018>>【TeeChart .NET教程】(十一)滾動(dòng)和縮放

    【TeeChart .NET教程】(十一)滾動(dòng)和縮放


    【下載TeeChart.Net最新版本】

    (一)如何使用鼠標(biāo)進(jìn)行縮放和滾動(dòng)

    1.1 縮放

    要放大圖表,請(qǐng)?jiān)谝糯蟮膮^(qū)域的左上角按住鼠標(biāo)左鍵并按住鼠標(biāo)按鈕,將矩形拖動(dòng)到縮放區(qū)域的右下角。釋放鼠標(biāo)按鈕,圖表將重繪所選區(qū)域。要撤消縮放,請(qǐng)?jiān)?ldquo;Chart圖表”區(qū)域的任意位置按鼠標(biāo)左鍵,然后按住鼠標(biāo)按鈕向上和向左拖動(dòng),釋放按鈕,圖表將重繪為最初定義的圖表區(qū)域。

    1.2 滾動(dòng)

    要滾動(dòng)圖表,按右鼠標(biāo)按鈕并按住鼠標(biāo)按鈕,將鼠標(biāo)拖動(dòng)到您想要滾動(dòng)圖表的方向。釋放鼠標(biāo)按鈕時(shí),圖表將保留在新位置。要撤消滾動(dòng),請(qǐng)?jiān)?ldquo;Chart圖表”區(qū)域的任意位置按鼠標(biāo)左鍵,然后按住鼠標(biāo)按鈕向上和向左拖動(dòng)。釋放按鈕,圖表將重繪為最初定義的圖表區(qū)域。

    (二)如何通過代碼縮放和滾動(dòng)

    2.1 縮放

    默認(rèn)情況下啟用縮放,使用Zoom.Allow屬性禁用縮放。有關(guān)與縮放關(guān)聯(lián)的屬性和方法的完整列表,請(qǐng)參見縮放類。要定義縮放的矩形區(qū)域,請(qǐng)使用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個(gè)x軸點(diǎn)之間的區(qū)域,將y軸設(shè)置為整個(gè)圖表的最大和最小點(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
    
    2.2 動(dòng)畫縮放

    動(dòng)畫縮放提供步進(jìn)縮放。您可以將Animated設(shè)置為啟用并為縮放定義交錯(cuò)步驟,而不是一步跳過“縮小”到“放大”。啟用動(dòng)畫后,您可以使用鼠標(biāo)或代碼手動(dòng)縮放。 例

    [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) 
    
    2.3 縮放事件

    手動(dòng)縮放或通過代碼縮放將觸發(fā)TChart.Zoomed事件,默認(rèn)情況下,縮小將觸發(fā)TChart.UndoneZoom事件。

    2.4 滾動(dòng)

    滾動(dòng)在所有方向上啟用,使用Scroll.Allow屬性禁用Scroll或?qū)croll限制為一個(gè)方向,按代碼滾動(dòng)的最簡(jiǎn)單方法是使用Axis Scroll方法:

    [C#.Net]

    tChart1.Axes.Bottom.Scroll(3, false); 
    

    [VB.Net]

    TChart1.Axes.Bottom.Scroll(3, False) 
    

    該值是偏移量,'False'指的是TeeChart是否允許滾動(dòng)超出系列值限制??刂茲L動(dòng)的另一種方法是定義Axis maximum和minumum以按代碼滾動(dòng):

    [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
    
    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();