本示例展示了如何沿所需的轴分别调整轴的滚动。 使用有两个 窗格 的图表来演示此功能。

C#CopyCode image复制代码
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraCharts;
// ...

private void Form1_Load(object sender, EventArgs e) {
    // Cast the chart's diagram to the XYDiagram type, to access its axes.
    XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
    
    // Define the visible range for the axes. 
    diagram.AxisY.Range.Auto = false;
    diagram.AxisY.Range.SetInternalMinMaxValues(2, 6);
    diagram.AxisX.Range.Auto = false;
    diagram.AxisX.Range.SetInternalMinMaxValues(2, 4);
    diagram.SecondaryAxesX[0].Range.Auto = false;
    diagram.SecondaryAxesX[0].Range.SetInternalMinMaxValues(2, 4);

    // Specify the axes scrolling at the diagram's level.
    diagram.EnableAxisXScrolling = true;
    diagram.EnableAxisYScrolling = false;

    // Individually specify the axes scrolling for the panes.
    diagram.DefaultPane.EnableAxisXScrolling = DefaultBoolean.Default;
    diagram.Panes[0].EnableAxisXScrolling = DefaultBoolean.False;

    // Adjust how the scrolling can be performed.
    diagram.ScrollingOptions.UseKeyboard = false;
    diagram.ScrollingOptions.UseMouse = false;
    diagram.ScrollingOptions.UseScrollBars = true;
}
Visual BasicCopyCode image复制代码
Imports System.Windows.Forms
Imports DevExpress.Utils
Imports DevExpress.XtraCharts
' ...

Private Sub Form1_Load(ByVal sender As Object, _ 
ByVal e As EventArgs) Handles MyBase.Load
    ' Cast the chart's diagram to the XYDiagram type, to access its axes.
    Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)

    ' Define the visible range for the axes. 
    diagram.AxisY.Range.Auto = False
    diagram.AxisY.Range.SetInternalMinMaxValues(2, 6)
    diagram.AxisX.Range.Auto = False
    diagram.AxisX.Range.SetInternalMinMaxValues(2, 4)
    diagram.SecondaryAxesX(0).Range.Auto = False
    diagram.SecondaryAxesX(0).Range.SetInternalMinMaxValues(2, 4)

    ' Specify the axes scrolling at the diagram's level.
    diagram.EnableAxisXScrolling = True
    diagram.EnableAxisYScrolling = False

    ' Individually specify the axes scrolling for the panes.
    diagram.DefaultPane.EnableAxisXScrolling = DefaultBoolean.Default
    diagram.Panes(0).EnableAxisXScrolling = DefaultBoolean.False

    ' Adjust how the scrolling can be performed.
    diagram.ScrollingOptions.UseKeyboard = False
    diagram.ScrollingOptions.UseMouse = False
    diagram.ScrollingOptions.UseScrollBars = True
End Sub

在下面的插图中显示了结果。

Expand image参阅