简要说明
交叠范围条形图 是由 OverlappedRangeBarSeriesView 对象来表示的,此对象属于 范围条形系列视图。 这种视图沿 Y 轴 (取值轴) 显示垂直条形或水平条形 。 每个条形表示一个数据 (每个参数值对应两个取值) 范围。 这种图表类型是有用的,例如,当需要从上至下逐个显示不同系列的行为条、以精确比较它们的持续期间时。
在下面的插图中显示了一个交叠范围条形图。 注意,这种图表类型基于 XYDiagram,因此可以被旋转,从而垂直地或水平地显示图表。
图表类型特征
下表列出了这种图表类型的主要特征。
特征 |
取值 |
---|---|
系列视图类型 | OverlappedRangeBarSeriesView |
图象类型 | 2D- XYDiagram |
每个数据点的参数个数 | 1 |
每个数据点的取值个数 | 2 |
注意 |
---|
要获得关于哪些图表类型可以与 交叠范围条形图 组合使用的信息,请参阅 组合使用不同的系列视图 文档。 |
示例
下面的示例演示了在运行时刻如何创建 ChartControl (拥有两个 OverlappedRangeBarSeriesView 类型的系列),并把图表添加到窗体中。 在继续本示例之前,首先要在 Visual Studio 中创建一个 Windows 窗体应用程序,并把所有 必需的程序集 包含到项目的“引用”列表中。
然后,把下列代码添加到 Form.Load 事件处理程序。
C# | 复制代码 |
---|---|
using System; using System.Windows.Forms; using DevExpress.XtraCharts; // ... private void Form1_Load(object sender, EventArgs e) { // Create a new chart. ChartControl rangeBarChart = new ChartControl(); // Create two range bar series. Series series1 = new Series("Series 1", ViewType.RangeBar); Series series2 = new Series("Series 2", ViewType.RangeBar); // Add points to them. series1.Points.Add(new SeriesPoint("A", 9, 15)); series1.Points.Add(new SeriesPoint("B", 4, 10)); series1.Points.Add(new SeriesPoint("C", 3, 13)); series1.Points.Add(new SeriesPoint("D", 2, 11)); series1.Points.Add(new SeriesPoint("E", 1, 10)); series2.Points.Add(new SeriesPoint("A", 10, 13)); series2.Points.Add(new SeriesPoint("B", 5, 7)); series2.Points.Add(new SeriesPoint("C", 6, 9)); series2.Points.Add(new SeriesPoint("D", 3, 7)); series2.Points.Add(new SeriesPoint("E", 2, 8)); // Add both series to the chart. rangeBarChart.Series.AddRange(new Series[] { series1, series2 }); // Hide labels of both series. series1.Label.Visible = false; series2.Label.Visible = false; // Access the view-type-specific options of the series. RangeBarSeriesView myView1 = (RangeBarSeriesView)series1.View; myView1.MaxValueMarker.Visible = true; myView1.MinValueMarker.Visible = true; myView1.MinValueMarker.Kind = MarkerKind.Circle; myView1.MinValueMarker.Kind = MarkerKind.Circle; myView1.MaxValueMarker.Kind = MarkerKind.Star; myView1.MaxValueMarker.StarPointCount = 5; ((RangeBarSeriesView)series2.View).BarWidth = 0.4; // Access the type-specific options of the diagram. ((XYDiagram)rangeBarChart.Diagram).EnableAxisXZooming = true; // Hide the legend (if necessary). rangeBarChart.Legend.Visible = false; // Add a title to the chart (if necessary). rangeBarChart.Titles.Add(new ChartTitle()); rangeBarChart.Titles[0].Text = "An Overlapped Range Bar Chart"; rangeBarChart.Titles[0].WordWrap = true; // Add the chart to the form. rangeBarChart.Dock = DockStyle.Fill; this.Controls.Add(rangeBarChart); } |
Visual Basic | 复制代码 |
---|---|
Imports System Imports System.Windows.Forms Imports DevExpress.XtraCharts ' ... Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _ Handles MyBase.Load ' Create a new chart. Dim rangeBarChart As New ChartControl() ' Create two range bar series. Dim series1 As New Series("Series 1", ViewType.RangeBar) Dim series2 As New Series("Series 2", ViewType.RangeBar) ' Add points to them. series1.Points.Add(New SeriesPoint("A", 9, 15)) series1.Points.Add(New SeriesPoint("B", 4, 10)) series1.Points.Add(New SeriesPoint("C", 3, 13)) series1.Points.Add(New SeriesPoint("D", 2, 11)) series1.Points.Add(New SeriesPoint("E", 1, 10)) series2.Points.Add(New SeriesPoint("A", 10, 13)) series2.Points.Add(New SeriesPoint("B", 5, 7)) series2.Points.Add(New SeriesPoint("C", 6, 9)) series2.Points.Add(New SeriesPoint("D", 3, 7)) series2.Points.Add(New SeriesPoint("E", 2, 8)) ' Add both series to the chart. rangeBarChart.Series.AddRange(New Series() { series1, series2 }) ' Hide labels of both series. series1.Label.Visible = False series2.Label.Visible = False ' Access the view-type-specific options of the series. Dim myView1 As RangeBarSeriesView = CType(series1.View, RangeBarSeriesView) myView1.MaxValueMarker.Visible = True myView1.MinValueMarker.Visible = True myView1.MinValueMarker.Kind = MarkerKind.Circle myView1.MinValueMarker.Kind = MarkerKind.Circle myView1.MaxValueMarker.Kind = MarkerKind.Star myView1.MaxValueMarker.StarPointCount = 5 CType(series2.View, RangeBarSeriesView).BarWidth = 0.4 ' Access the type-specific options of the diagram. CType(rangeBarChart.Diagram, XYDiagram).EnableAxisXZooming = True ' Hide the legend (if necessary). rangeBarChart.Legend.Visible = False ' Add a title to the chart (if necessary). rangeBarChart.Titles.Add(New ChartTitle()) rangeBarChart.Titles(0).Text = "An Overlapped Range Bar Chart" rangeBarChart.Titles(0).WordWrap = True ' Add the chart to the form. rangeBarChart.Dock = DockStyle.Fill Me.Controls.Add(rangeBarChart) End Sub |
Show Me |
---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E1219。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |