代码如下
程序代码:using System;
using System.Collections.Generic;
using using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraCharts;
namespace WindowsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private DataTable CreateChartData()
{
// Create an empty table.
DataTable table = new DataTable("Table1");
// Add three columns to the table.
table.Columns.Add("Language", typeof(String));
table.Columns.Add("Section", typeof(String));
table.Columns.Add("Value", typeof(Decimal));
// Add data rows to the table.
table.Rows.Add(new object[] { "C#", "Section1", 10.123 });
table.Rows.Add(new object[] { "JAVA", "Section2", 20 });
table.Rows.Add(new object[] { "C++", "Section3", 20 });
table.Rows.Add(new object[] { "F#", "Section4", 30 });
table.Rows.Add(new object[] { "JAVASCRIPT", "Section5", 15 });
table.Rows.Add(new object[] { "VB", "Section6", 25 });
table.Rows.Add(new object[] { "", "Section7", 10.123 });
table.Rows.Add(new object[] { "C", "Section8", 20 });
table.Rows.Add(new object[] { "PHP", "Section9", 20 });
table.Rows.Add(new object[] { "PB", "Section10", 30 });
table.Rows.Add(new object[] { "VF", "Section11", 15 });
return table;
}
private void Form1_Load(object sender, EventArgs e)
{
// Generate a data table and bind the chart to it.
chartControl1.DataSource = CreateChartData();
// Specify data members to bind the chart's series template.
chartControl1.SeriesDataMember = "LANGUAGE";
chartControl1.SeriesTemplate.ArgumentDataMember = "Section";
chartControl1.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Value" });
// Specify the template's series view
chartControl1.SeriesTemplate.View = new StackedBarSeriesView();
// Specify the template's name prefix.
chartControl1.SeriesNameTemplate.BeginText = "LANGUAGE: ";
// Dock the chart into its parent, and add it to the current form.
chartControl1.Dock = DockStyle.Fill;
}
}
}









