简单的DevExpress中chart 控件例子
DevExpress中有非常多的很好的,易用的控件资源,对于可视化工作室很好的支持(其实Matlab也很不错的)。
研究了一下图表(chart)控件,针对文档当中给出的小例子,作一个简单的小结工作。
一.数据添加方式:
1.手动方式
直接对于Series添加变量名称和值,适合变量数值不太多的情况下
2.自动方式(从数据库)
对于Series对象而言,使用argument 和 value data member来表示数据
完整的代码例子,包括创建数据库,读取和绘制柱状图
E How to bind individual chart series to data Tags: .NET, XtraCharts Suite 0 The following example demonstrates how to bind a chart to data at runtime via binding its individual series to a particular datasource. Show all comments Leave a Comment You must log in or register to leave comments Form1.cs Form1.cs Form1.csC# VB.NET C# C#VB.NETv2013 vol 1.4 - v2013 vol 2.2 v2008 vol 1.1 - v2012 vol 2.15 v2013 vol 1.4 - v2013 vol 2.2 v2013 vol 1.4 - v2013 vol 2.2v2008 vol 1.1 - v2012 vol 2.15Open in popup window using System; using System.Data; using System.Windows.Forms; using DevExpress.XtraCharts; // ... namespace BindIndividualSeriesRuntimeCS { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private DataTable CreateChartData(int rowCount) { // Create an empty table. DataTable table = new DataTable("Table1"); // Add two columns to the table. table.Columns.Add("Argument", typeof(Int32)); table.Columns.Add("Value", typeof(Int32)); // Add data rows to the table. Random rnd = new Random(); DataRow row = null; for (int i = 0; i < rowCount; i++) { row = table.NewRow(); row["Argument"] = i; row["Value"] = rnd.Next(100); table.Rows.Add(row); } return table; } private void Form1_Load(object sender, EventArgs e) { // Create a chart. ChartControl chart = new ChartControl(); // Create an empty Bar series and add it to the chart. Series series = new Series("Series1", ViewType.Bar); chart.Series.Add(series); // Generate a data table and bind the series to it. series.DataSource = CreateChartData(50); // Specify data members to bind the series. series.ArgumentScaleType = ScaleType.Numerical; series.ArgumentDataMember = "Argument"; series.ValueScaleType = ScaleType.Numerical; series.ValueDataMembers.AddRange(new string[] { "Value" }); // Set some properties to get a nice-looking chart. ((SideBySideBarSeriesView)series.View).ColorEach = true; ((XYDiagram)chart.Diagram).AxisY.Visible = false; chart.Legend.Visible = false; // Dock the chart into its parent and add it to the current form. chart.Dock = DockStyle.Fill; this.Controls.Add(chart); } } }
windows form下的方式