学习devexpresschartControl控件

时间:2021-12-09 10:09:33

devexpress官网chart:https://documentation.devexpress.com/WindowsForms/8117/Controls-and-Libraries/Chart-Control

https://documentation.devexpress.com/WindowsForms/5778/Controls-and-Libraries/Chart-Control/Fundamentals/Chart-Elements/Diagram


层级关系:https://documentation.devexpress.com/WindowsForms/5808/Controls-and-Libraries/Chart-Control/Fundamentals/Chart-Elements

学习devexpresschartControl控件

学习devexpresschartControl控件

学习devexpresschartControl控件

学习devexpresschartControl控件

学习devexpresschartControl控件


学习devexpresschartControl控件

 XYDiagram diagram = chart.Diagram as XYDiagram;
if (diagram != null) {
// Access diagram properties, for example, rotate the diagram.
diagram.Rotated = true;
// Access properties of objects that belong to the diagram,
// for example, axes and panes.
diagram.AxisY.Title.Text = "Population mid-year, millions";
diagram.DefaultPane.Weight = ;
}

给坐标轴加标题


pans:https://documentation.devexpress.com/WindowsForms/5879/Controls-and-Libraries/Chart-Control/Fundamentals/Chart-Elements/Diagram/Panes

 using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ... private void Form1_Load(object sender, EventArgs e) {
// Create a new chart.
ChartControl chartControl1 = new ChartControl(); // Create two series.
Series series1 = new Series("Series 1", ViewType.Bar);
Series series2 = new Series("Series 2", ViewType.Line); // Add points to them, with their arguments different.
series1.Points.Add(new SeriesPoint("A", ));
series1.Points.Add(new SeriesPoint("B", ));
series1.Points.Add(new SeriesPoint("C", ));
series1.Points.Add(new SeriesPoint("D", ));
series2.Points.Add(new SeriesPoint("I", ));
series2.Points.Add(new SeriesPoint("II", ));
series2.Points.Add(new SeriesPoint("III", ));
series2.Points.Add(new SeriesPoint("IV", )); // Add both series to the chart.
chartControl1.Series.AddRange(new Series[] { series1, series2 }); // Hide the legend (optional).
chartControl1.Legend.Visible = false; // Cast the chart's diagram to the XYDiagram type,
// to access its axes and panes.
XYDiagram diagram = (XYDiagram)chartControl1.Diagram; // Add secondary axes to the diagram, and adjust their options.
diagram.SecondaryAxesX.Add(new SecondaryAxisX("My Axis X"));
diagram.SecondaryAxesY.Add(new SecondaryAxisY("My Axis Y"));
diagram.SecondaryAxesX[].Alignment = AxisAlignment.Near;
diagram.SecondaryAxesY[].Alignment = AxisAlignment.Near; // Add a new additional pane to the diagram.
diagram.Panes.Add(new XYDiagramPane("My Pane")); // Assign both the additional pane and, if required,
// the secondary axes to the second series.
LineSeriesView myView = (LineSeriesView)series2.View;
myView.AxisX = diagram.SecondaryAxesX[];
myView.AxisY = diagram.SecondaryAxesY[];
// Note that the created pane has the zero index in the collection,
// because the existing Default pane is a separate entity.
myView.Pane = diagram.Panes[]; // Customize the layout of the diagram's panes.
diagram.PaneDistance = ;
diagram.PaneLayoutDirection = PaneLayoutDirection.Horizontal;
diagram.DefaultPane.SizeMode = PaneSizeMode.UseWeight;
diagram.DefaultPane.Weight = 1.2; // Add the chart to the form.
chartControl1.Dock = DockStyle.Fill;
this.Controls.Add(chartControl1);
}

add pans

学习devexpresschartControl控件

Adding Panes:https://documentation.devexpress.com/WindowsForms/5880/Controls-and-Libraries/Chart-Control/Fundamentals/Chart-Elements/Diagram/Panes/Adding-Panes#Examples

https://documentation.devexpress.com/WindowsForms/6180/Controls-and-Libraries/Chart-Control/Examples/Chart-Elements/How-to-Display-a-Series-in-an-Additional-Pane-Runtime-Sample

 using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ... private void Form1_Load(object sender, EventArgs e) {
// Create a new chart.
ChartControl chartControl1 = new ChartControl(); // Create two series.
Series series1 = new Series("Series 1", ViewType.Bar);
Series series2 = new Series("Series 2", ViewType.Line); // Add points to them, with their arguments different.
series1.Points.Add(new SeriesPoint("A", ));
series1.Points.Add(new SeriesPoint("B", ));
series1.Points.Add(new SeriesPoint("C", ));
series1.Points.Add(new SeriesPoint("D", ));
series2.Points.Add(new SeriesPoint("I", ));
series2.Points.Add(new SeriesPoint("II", ));
series2.Points.Add(new SeriesPoint("III", ));
series2.Points.Add(new SeriesPoint("IV", )); // Add both series to the chart.
chartControl1.Series.AddRange(new Series[] { series1, series2 }); // Hide the legend (optional).
chartControl1.Legend.Visible = false; // Cast the chart's diagram to the XYDiagram type,
// to access its axes and panes.
XYDiagram diagram = (XYDiagram)chartControl1.Diagram; // Add secondary axes to the diagram, and adjust their options.
diagram.SecondaryAxesX.Add(new SecondaryAxisX("My Axis X"));
diagram.SecondaryAxesY.Add(new SecondaryAxisY("My Axis Y"));
diagram.SecondaryAxesX[].Alignment = AxisAlignment.Near;
diagram.SecondaryAxesY[].Alignment = AxisAlignment.Near; // Add a new additional pane to the diagram.
diagram.Panes.Add(new XYDiagramPane("My Pane")); // Assign both the additional pane and, if required,
// the secondary axes to the second series.
LineSeriesView myView = (LineSeriesView)series2.View;
myView.AxisX = diagram.SecondaryAxesX[];
myView.AxisY = diagram.SecondaryAxesY[];
// Note that the created pane has the zero index in the collection,
// because the existing Default pane is a separate entity.
myView.Pane = diagram.Panes[]; // Customize the layout of the diagram's panes.
diagram.PaneDistance = ;
diagram.PaneLayoutDirection = PaneLayoutDirection.Horizontal;
diagram.DefaultPane.SizeMode = PaneSizeMode.UseWeight;
diagram.DefaultPane.Weight = 1.2; // Add the chart to the form.
chartControl1.Dock = DockStyle.Fill;
this.Controls.Add(chartControl1);
}

How to: Display a Series in an Additional Pane (Runtime Sample)

学习devexpresschartControl控件