简要说明
Manhattan 条形图 是由 ManhattanBarSeriesView 对象来表示的,此对象属于 条形和柱状系列视图。 这种视图用于显示个别条形的系列,并按类别分组。 每个条形的高度取决于系列的取值。 另外,三维外观使旋转图表变得可能,从而以一种吸引眼球且易于理解的方式来放置条形。
在下面的插图中显示了一个 Manhattan 条形图。
图表类型特征
下表列出了这种图表类型的主要特征。
特征 |
取值 |
---|---|
系列视图类型 | ManhattanBarSeriesView |
图象类型 | XYDiagram3D |
每个数据点的参数个数 | 1 |
每个数据点的取值个数 | 1 |
注意 |
---|
要获得关于哪些图表类型可以与 Manhattan 条形图 组合使用的信息,请参阅 组合使用不同的系列视图 文档。 |
示例
下面的示例演示了在运行时刻如何创建 ChartControl (拥有两个 ManhattanBarSeriesView 类型的系列),设置它的常规属性,并把图表添加到窗体中。 在继续本示例之前,首先要在 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 ManhattanBarChart = new ChartControl(); // Add a bar series to it. Series series1 = new Series("Series 1", ViewType.ManhattanBar); Series series2 = new Series("Series 2", ViewType.ManhattanBar); // Add points to the series. series1.Points.Add(new SeriesPoint("A", 10)); series1.Points.Add(new SeriesPoint("B", 12)); series1.Points.Add(new SeriesPoint("C", 14)); series1.Points.Add(new SeriesPoint("D", 17)); series2.Points.Add(new SeriesPoint("A", 5)); series2.Points.Add(new SeriesPoint("B", 4)); series2.Points.Add(new SeriesPoint("C", 10)); series2.Points.Add(new SeriesPoint("D", 12)); // Add both series to the chart. ManhattanBarChart.Series.AddRange(new Series[] { series1, series2 }); // Access labels of the first series. ((BarSeriesLabel)series1.Label).Visible = true; ((BarSeriesLabel)series1.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default; // Access the series options. series1.PointOptions.PointView = PointView.ArgumentAndValues; // Customize the view-type-specific properties of the series. Bar3DSeriesView myView = (Bar3DSeriesView)series2.View; myView.BarDepthAuto = false; myView.BarDepth = 1; myView.Transparency = 80; myView.ShowFacet = false; myView.Model = Bar3DModel.Cylinder; // Access the diagram's options. ((XYDiagram3D)ManhattanBarChart.Diagram).ZoomPercent = 110; // Add a title to the chart and hide the legend. ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Text = "Manhattan Bar Chart"; ManhattanBarChart.Titles.Add(chartTitle1); ManhattanBarChart.Legend.Visible = false; // Add the chart to the form. ManhattanBarChart.Dock = DockStyle.Fill; this.Controls.Add(ManhattanBarChart); } |
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 ManhattanBarChart As New ChartControl() ' Add a bar series to it. Dim series1 As New Series("Series 1", ViewType.ManhattanBar) Dim series2 As New Series("Series 2", ViewType.ManhattanBar) ' Add points to the series. series1.Points.Add(New SeriesPoint("A", 10)) series1.Points.Add(New SeriesPoint("B", 12)) series1.Points.Add(New SeriesPoint("C", 14)) series1.Points.Add(New SeriesPoint("D", 17)) series2.Points.Add(New SeriesPoint("A", 5)) series2.Points.Add(New SeriesPoint("B", 4)) series2.Points.Add(New SeriesPoint("C", 10)) series2.Points.Add(New SeriesPoint("D", 12)) ' Add both series to the chart. ManhattanBarChart.Series.AddRange(New Series() { series1, series2 }) ' Access labels of the first series. CType(series1.Label, BarSeriesLabel).Visible = True CType(series1.Label, BarSeriesLabel).ResolveOverlappingMode = ResolveOverlappingMode.Default ' Access the series options. series1.PointOptions.PointView = PointView.ArgumentAndValues ' Customize the view-type-specific properties of the series. Dim myView As Bar3DSeriesView = CType(series2.View, Bar3DSeriesView) myView.BarDepthAuto = False myView.BarDepth = 1 myView.Transparency = 80 myView.ShowFacet = False myView.Model = Bar3DModel.Cylinder ' Access the diagram's options. CType(ManhattanBarChart.Diagram, XYDiagram3D).ZoomPercent = 110 ' Add a title to the chart and hide the legend. Dim chartTitle1 As New ChartTitle() chartTitle1.Text = "Manhattan Bar Chart" ManhattanBarChart.Titles.Add(chartTitle1) ManhattanBarChart.Legend.Visible = False ' Add the chart to the form. ManhattanBarChart.Dock = DockStyle.Fill Me.Controls.Add(ManhattanBarChart) End Sub |
Show Me |
---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E1027。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |