使用Dundas Chart 组件开发如上图,以下代码是在VS2003开发环境中运行的。在页面中加一个Dundas Chart 组件,并在Page_Load中调用SetChart1()函数即可(参数在0-10之间赋值)。
调用代码:
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
SetChart1(1.5,2.5,3,8);
SetChart2(1.5,8,3);
SetChart3(4.2,3.8,7,9,9.9);
SetChart4(10,6.3,2);
}
}
各函数:
///
/// 计划管理技能
/// ///
时间管理
///
规划安排
///
目标设置
///
战略制定
private void SetChart1(double par1,double par2,double par3,double par4)
{
//图的类型、颜 {MOD}、粗细
Chart1.Height = Unit.Parse("368px");
Chart1.Height = Unit.Parse("450px");
Chart1.Series["Series1"].Type = SeriesChartType.Line;
Chart1.Series["Series1"].BorderColor = Color.DarkOrange;
Chart1.Series["Series1"].Color= Color.DarkOrange;
Chart1.Series["Series1"].BorderWidth = 3;
Chart1.Series["Series1"].BorderStyle = ChartDashStyle.Solid;
//出图类型
Chart1.ImageType = ChartImageType.Jpeg;
Chart1.Series["Series1"].MarkerStyle = MarkerStyle.Circle;
Chart1.Series["Series1"].MarkerSize = 8;
//邦定数据
Chart1.Series["Series1"].Points.AddXY(par1,5);
Chart1.Series["Series1"].Points.AddXY(par2,25);
Chart1.Series["Series1"].Points.AddXY(par3,45);
Chart1.Series["Series1"].Points.AddXY(par4,65);
//设置Y1值
Font myFont2 = new Font("楷体",10);
Chart1.ChartAreas["Default"].AxisY.LabelStyle.Font = myFont2;
int elementY = Chart1.ChartAreas["Default"].AxisY.CustomLabels.Add(1,10,"时间管理");
elementY = Chart1.ChartAreas["Default"].AxisY.CustomLabels.Add(20,30,"规划安排");
elementY = Chart1.ChartAreas["Default"].AxisY.CustomLabels.Add(40,50,"目标设置");
elementY = Chart1.ChartAreas["Default"].AxisY.CustomLabels.Add(60,70,"战略制定");
//
Chart1.ChartAreas["Default"].BackColor = Color.Green;
Chart1.ChartAreas["Default"].AxisX.MinorGrid.Enabled = false;
Chart1.ChartAreas["Default"].AxisX.Minimum = 1;
Chart1.ChartAreas["Default"].AxisX.Maximum = 10;
Chart1.ChartAreas["Default"].AxisX.Interval = 1;
// Set Grid lines and tick marks interval 设置虚线及其样式的代码
Chart1.ChartAreas["Default"].AxisX.MajorGrid.Interval = 3;
Chart1.ChartAreas["Default"].AxisX.MajorGrid.LineColor = Color.White;
Chart1.ChartAreas["Default"].AxisX.MajorGrid.LineWidth = 2;
// Set Line Style
Chart1.ChartAreas["Default"].AxisX.MajorGrid.LineStyle = ChartDashStyle.Dot;
Chart1.ChartAreas["Default"].AxisX.LineColor = Color.Black;
Chart1.ChartAreas["Default"].AxisX.LineWidth = 3;
Chart1.ChartAreas["Default"].AxisX2.LabelsAutoFit = false;
Chart1.ChartAreas["Default"].AxisX2.Minimum = 1;
Chart1.ChartAreas["Default"].AxisX2.Maximum = 10;
Chart1.ChartAreas["Default"].AxisX2.MajorGrid.LineStyle = ChartDashStyle.NotSet; //取消X2的竖线
Font myFont1 = new Font("楷体",10);
Chart1.ChartAreas["Default"].AxisX2.LabelStyle.Font = myFont1;
Chart1.ChartAreas["Default"].AxisX2.CustomLabels.Add(2,3,"较低");
Chart1.ChartAreas["Default"].AxisX2.CustomLabels.Add(5,6,"中等");
Chart1.ChartAreas["Default"].AxisX2.CustomLabels.Add(8,9,"较高");
Chart1.ChartAreas["Default"].AxisX2.Enabled = AxisEnabled.True;
Chart1.ChartAreas["Default"].AxisX2.LineColor = Color.Black;
Chart1.ChartAreas["Default"].AxisX2.LineWidth = 3;
Chart1.ChartAreas["Default"].AxisY.MajorGrid.LineStyle = ChartDashStyle.NotSet;
Chart1.ChartAreas["Default"].AxisY.LineColor = Color.Black;
Chart1.ChartAreas["Default"].AxisY.LineWidth = 3;
//显示Y2
Chart1.ChartAreas["Default"].AxisY2.Enabled = AxisEnabled.True;
//去掉Y2的值
Chart1.ChartAreas["Default"].AxisY2.Minimum = 0;
Chart1.ChartAreas["Default"].AxisY2.Maximum = 100;
Chart1.ChartAreas["Default"].AxisY2.CustomLabels.Add(0,100,"");
//取消Y2的竖线
Chart1.ChartAreas["Default"].AxisY2.MajorGrid.LineStyle = ChartDashStyle.NotSet;
Chart1.ChartAreas["Default"].AxisY2.LineColor = Color.Black;
Chart1.ChartAreas["Default"].AxisY2.LineWidth = 4;
//设置Legends
// Chart1.Legends["Default"].Docking = LegendDocking.Top;
Chart1.Legends["Default"].Enabled = false;
//设置标题
Font myFont = new Font("楷体",10);
Title title = new Title();
title.Text = "能力水平";
title.Font = myFont;
title.Docking = Docking.Bottom;
title.Color = Color.FromArgb(26, 59, 105);
title.BackImageAlign = ChartImageAlign.Bottom;
Chart1.Titles.Add(title);
//取消四个边框的毛线
Chart1.ChartAreas["Default"].AxisX.MajorTickMark.Enabled = false;
Chart1.ChartAreas["Default"].AxisX2.MajorTickMark.Enabled = false;
Chart1.ChartAreas["Default"].AxisY.MajorTickMark.Enabled = false;
Chart1.ChartAreas["Default"].AxisY2.MajorTickMark.Enabled = false;
}
///
/// 组织管理技能
/// ///
任务分配
///
授权协调
///
团队管理
private void SetChart2(double par1,double par2,double par3)
{
//图的类型、颜 {MOD}、粗细
Chart2.Series["Series1"].Type = SeriesChartType.Line;
Chart2.Series["Series1"].BorderColor = Color.DarkOrange;
Chart2.Series["Series1"].Color= Color.DarkOrange;
Chart2.Series["Series1"].BorderWidth = 3;
Chart2.Series["Series1"].BorderStyle = ChartDashStyle.Solid;
Chart2.Series["Series1"].MarkerStyle = MarkerStyle.Circle;
Chart2.Series["Series1"].MarkerSize = 8;
//邦定数据
Chart2.Series["Series1"].Points.AddXY(par1,45);
Chart2.Series["Series1"].Points.AddXY(par2,25);
Chart2.Series["Series1"].Points.AddXY(par3,5);
//设置Y1值
Font myFont2 = new Font("楷体",10);
Chart2.ChartAreas["Default"].AxisY.LabelStyle.Font = myFont2;
int elementY = Chart2.ChartAreas["Default"].AxisY.CustomLabels.Add(1,10,"团队管理");
elementY = Chart2.ChartAreas["Default"].AxisY.CustomLabels.Add(20,30,"授权协调");
elementY = Chart2.ChartAreas["Default"].AxisY.CustomLabels.Add(40,50,"任务分配");
//
Chart2.ChartAreas["Default"].BackColor = Color.Green;
Chart2.ChartAreas["Default"].AxisX.MinorGrid.Enabled = false;
Chart2.ChartAreas["Default"].AxisX.Minimum = 1;
Chart2.ChartAreas["Default"].AxisX.Maximum = 10;
Chart2.ChartAreas["Default"].AxisX.Interval = 1;
// Set Grid lines and tick marks interval 设置虚线及其样式的代码
Chart2.ChartAreas["Default"].AxisX.MajorGrid.Interval = 3;
Chart2.ChartAreas["Default"].AxisX.MajorGrid.LineColor = Color.White;
Chart2.ChartAreas["Default"].AxisX.MajorGrid.LineWidth = 2;
// Set Line Style
Chart2.ChartAreas["Default"].AxisX.MajorGrid.LineStyle = ChartDashStyle.Dot;
Chart2.ChartAreas["Default"].AxisX.LineColor = Color.Black;
Chart2.ChartAreas["Default"].AxisX.LineWidth = 3;
Chart2.ChartAreas["Default"].AxisX2.LabelsAutoFit = false;
Chart2.ChartAreas["Default"].AxisX2.Minimum = 1;
Chart2.ChartAreas["Default"].AxisX2.Maximum = 10;
Chart2.ChartAreas["Default"].AxisX2.MajorGrid.LineStyle = ChartDashStyle.NotSet; //取消X2的竖线
Font myFont1 = new Font("楷体",10);
Chart2.ChartAreas["Default"].AxisX2.LabelStyle.Font = myFont1;
Chart2.ChartAreas["Default"].AxisX2.CustomLabels.Add(2,3,"较低");
Chart2.ChartAreas["Default"].AxisX2.CustomLabels.Add(5,6,"中等");
Chart2.ChartAreas["Default"].AxisX2.CustomLabels.Add(8,9,"较高");
Chart2.ChartAreas["Default"].AxisX2.Enabled = AxisEnabled.True;
Chart2.ChartAreas["Default"].AxisX2.LineColor = Color.Black;
Chart2.ChartAreas["Default"].AxisX2.LineWidth = 3;
Chart2.ChartAreas["Default"].AxisY.MajorGrid.LineStyle = ChartDashStyle.NotSet;
Chart2.ChartAreas["Default"].AxisY.LineColor = Color.Black;
Chart2.ChartAreas["Default"].AxisY.LineWidth = 3;
//显示Y2
Chart2.ChartAreas["Default"].AxisY2.Enabled = AxisEnabled.True;
//去掉Y2的值
Chart2.ChartAreas["Default"].AxisY2.Minimum = 0;
Chart2.ChartAreas["Default"].AxisY2.Maximum = 100;
Chart2.ChartAreas["Default"].AxisY2.CustomLabels.Add(0,100,"");
//取消Y2的竖线
Chart2.ChartAreas["Default"].AxisY2.MajorGrid.LineStyle = ChartDashStyle.NotSet;
Chart2.ChartAreas["Default"].AxisY2.LineColor = Color.Black;
Chart2.ChartAreas["Default"].AxisY2.LineWidth = 4;
//设置Legends
// Chart2.Legends["Default"].Docking = LegendDocking.Top;
Chart2.Legends["Default"].Enabled = false;
//设置标题
Font myFont = new Font("楷体",10);
Title title = new Title();
title.Text = "能力水平";
title.Font = myFont;
title.Docking = Docking.Bottom;
title.Color = Color.FromArgb(26, 59, 105);
title.BackImageAlign = ChartImageAlign.Bottom;
Chart2.Titles.Add(title);
//取消四个边框的毛线
Chart2.ChartAreas["Default"].AxisX.MajorTickMark.Enabled = false;
Chart2.ChartAreas["Default"].AxisX2.MajorTickMark.Enabled = false;
Chart2.ChartAreas["Default"].AxisY.MajorTickMark.Enabled = false;
Chart2.ChartAreas["Default"].AxisY2.MajorTickMark.Enabled = false;
}
///
/// 设置第三个图:领导管理技能
/// ///
人际关系
///
沟通协调
///
培养下属
///
激励推动
///
决策判断
private void SetChart3(double par1,double par2,double par3,double par4,double par5)
{
//图的类型、颜 {MOD}、粗细
Chart3.Series["Series1"].Type = SeriesChartType.Line;
Chart3.Series["Series1"].BorderColor = Color.DarkOrange;
Chart3.Series["Series1"].Color= Color.DarkOrange;
Chart3.Series["Series1"].BorderWidth = 3;
Chart3.Series["Series1"].BorderStyle = ChartDashStyle.Solid;
Chart3.Series["Series1"].MarkerStyle = MarkerStyle.Circle;
Chart3.Series["Series1"].MarkerSize = 8;
//邦定数据
Chart3.Series["Series1"].Points.AddXY(par1,10);
Chart3.Series["Series1"].Points.AddXY(par2,30);
Chart3.Series["Series1"].Points.AddXY(par3,50);
Chart3.Series["Series1"].Points.AddXY(par4,70);
Chart3.Series["Series1"].Points.AddXY(par5,90);
//设置Y1值
Font myFont2 = new Font("楷体",10);
Chart3.ChartAreas["Default"].AxisY.LabelStyle.Font = myFont2;
int elementY = Chart3.ChartAreas["Default"].AxisY.CustomLabels.Add(1,10,"人际关系");
elementY = Chart3.ChartAreas["Default"].AxisY.CustomLabels.Add(20,30,"沟通协调");
elementY = Chart3.ChartAreas["Default"].AxisY.CustomLabels.Add(40,50,"培养下属");
elementY = Chart3.ChartAreas["Default"].AxisY.CustomLabels.Add(60,70,"激励推动");
elementY = Chart3.ChartAreas["Default"].AxisY.CustomLabels.Add(80,90,"决策判断");
//
Chart3.ChartAreas["Default"].BackColor = Color.Green;
Chart3.ChartAreas["Default"].AxisX.MinorGrid.Enabled = false;
Chart3.ChartAreas["Default"].AxisX.Minimum = 1;
Chart3.ChartAreas["Default"].AxisX.Maximum = 10;
Chart3.ChartAreas["Default"].AxisX.Interval = 1;
// Set Grid lines and tick marks interval 设置虚线及其样式的代码
Chart3.ChartAreas["Default"].AxisX.MajorGrid.Interval = 3;
Chart3.ChartAreas["Default"].AxisX.MajorGrid.LineColor = Color.White;
Chart3.ChartAreas["Default"].AxisX.MajorGrid.LineWidth = 2;
// Set Line Style
Chart3.ChartAreas["Default"].AxisX.MajorGrid.LineStyle = ChartDashStyle.Dot;
Chart3.ChartAreas["Default"].AxisX.LineColor = Color.Black;
Chart3.ChartAreas["Default"].AxisX.LineWidth = 3;
Chart3.ChartAreas["Default"].AxisX2.LabelsAutoFit = false;
Chart3.ChartAreas["Default"].AxisX2.Minimum = 1;
Chart3.ChartAreas["Default"].AxisX2.Maximum = 10;
Chart3.ChartAreas["Default"].AxisX2.MajorGrid.LineStyle = ChartDashStyle.NotSet; //取消X2的竖线
Font myFont1 = new Font("楷体",10);
Chart3.ChartAreas["Default"].AxisX2.LabelStyle.Font = myFont1;
Chart3.ChartAreas["Default"].AxisX2.CustomLabels.Add(2,3,"较低");
Chart3.ChartAreas["Default"].AxisX2.CustomLabels.Add(5,6,"中等");
Chart3.ChartAreas["Default"].AxisX2.CustomLabels.Add(8,9,"较高");
Chart3.ChartAreas["Default"].AxisX2.Enabled = AxisEnabled.True;
Chart3.ChartAreas["Default"].AxisX2.LineColor = Color.Black;
Chart3.ChartAreas["Default"].AxisX2.LineWidth = 3;
Chart3.ChartAreas["Default"].AxisY.MajorGrid.LineStyle = ChartDashStyle.NotSet;
Chart3.ChartAreas["Default"].AxisY.LineColor = Color.Black;
Chart3.ChartAreas["Default"].AxisY.LineWidth = 3;
//显示Y2
Chart3.ChartAreas["Default"].AxisY2.Enabled = AxisEnabled.True;
//去掉Y2的值
Chart3.ChartAreas["Default"].AxisY2.Minimum = 0;
Chart3.ChartAreas["Default"].AxisY2.Maximum = 100;
Chart3.ChartAreas["Default"].AxisY2.CustomLabels.Add(0,100,"");
//取消Y2的竖线
Chart3.ChartAreas["Default"].AxisY2.MajorGrid.LineStyle = ChartDashStyle.NotSet;
Chart3.ChartAreas["Default"].AxisY2.LineColor = Color.Black;
Chart3.ChartAreas["Default"].AxisY2.LineWidth = 4;
//设置Legends
// Chart3.Legends["Default"].Docking = LegendDocking.Top;
Chart3.Legends["Default"].Enabled = false;
//设置标题
Font myFont = new Font("楷体",10);
Title title = new Title();
title.Text = "能力水平";
title.Font = myFont;
title.Docking = Docking.Bottom;
title.Color = Color.FromArgb(26, 59, 105);
title.BackImageAlign = ChartImageAlign.Bottom;
Chart3.Titles.Add(title);
//取消四个边框的毛线
Chart3.ChartAreas["Default"].AxisX.MajorTickMark.Enabled = false;
Chart3.ChartAreas["Default"].AxisX2.MajorTickMark.Enabled = false;
Chart3.ChartAreas["Default"].AxisY.MajorTickMark.Enabled = false;
Chart3.ChartAreas["Default"].AxisY2.MajorTickMark.Enabled = false;
}
///
/// 控制管理技能
/// ///
监查反馈
///
应变调控
///
绩效管理
private void SetChart4(double par1,double par2,double par3)
{
//图的类型、颜 {MOD}、粗细
Chart4.Series["Series1"].Type = SeriesChartType.Line;
Chart4.Series["Series1"].BorderColor = Color.DarkOrange;
Chart4.Series["Series1"].Color= Color.DarkOrange;
Chart4.Series["Series1"].BorderWidth = 3;
Chart4.Series["Series1"].BorderStyle = ChartDashStyle.Solid;
Chart4.Series["Series1"].MarkerStyle = MarkerStyle.Circle;
Chart4.Series["Series1"].MarkerSize = 8;
//邦定数据
Chart4.Series["Series1"].Points.AddXY(par1,45);
Chart4.Series["Series1"].Points.AddXY(par2,25);
Chart4.Series["Series1"].Points.AddXY(par3,5);
//设置Y1值
Font myFont2 = new Font("楷体",10);
Chart4.ChartAreas["Default"].AxisY.LabelStyle.Font = myFont2;
int elementY = Chart4.ChartAreas["Default"].AxisY.CustomLabels.Add(1,10,"绩效管理");
elementY = Chart4.ChartAreas["Default"].AxisY.CustomLabels.Add(20,30,"应变调控");
elementY = Chart4.ChartAreas["Default"].AxisY.CustomLabels.Add(40,50,"监查反馈");
//
Chart4.ChartAreas["Default"].BackColor = Color.Green;
Chart4.ChartAreas["Default"].AxisX.MinorGrid.Enabled = false;
Chart4.ChartAreas["Default"].AxisX.Minimum = 1;
Chart4.ChartAreas["Default"].AxisX.Maximum = 10;
Chart4.ChartAreas["Default"].AxisX.Interval = 1;
// Set Grid lines and tick marks interval 设置虚线及其样式的代码
Chart4.ChartAreas["Default"].AxisX.MajorGrid.Interval = 3;
Chart4.ChartAreas["Default"].AxisX.MajorGrid.LineColor = Color.White;
Chart4.ChartAreas["Default"].AxisX.MajorGrid.LineWidth = 2;
// Set Line Style
Chart4.ChartAreas["Default"].AxisX.MajorGrid.LineStyle = ChartDashStyle.Dot;
Chart4.ChartAreas["Default"].AxisX.LineColor = Color.Black;
Chart4.ChartAreas["Default"].AxisX.LineWidth = 3;
Chart4.ChartAreas["Default"].AxisX2.LabelsAutoFit = false;
Chart4.ChartAreas["Default"].AxisX2.Minimum = 1;
Chart4.ChartAreas["Default"].AxisX2.Maximum = 10;
Chart4.ChartAreas["Default"].AxisX2.MajorGrid.LineStyle = ChartDashStyle.NotSet; //取消X2的竖线
Font myFont1 = new Font("楷体",10);
Chart4.ChartAreas["Default"].AxisX2.LabelStyle.Font = myFont1;
Chart4.ChartAreas["Default"].AxisX2.CustomLabels.Add(2,3,"较低");
Chart4.ChartAreas["Default"].AxisX2.CustomLabels.Add(5,6,"中等");
Chart4.ChartAreas["Default"].AxisX2.CustomLabels.Add(8,9,"较高");
Chart4.ChartAreas["Default"].AxisX2.Enabled = AxisEnabled.True;
Chart4.ChartAreas["Default"].AxisX2.LineColor = Color.Black;
Chart4.ChartAreas["Default"].AxisX2.LineWidth = 3;
Chart4.ChartAreas["Default"].AxisY.MajorGrid.LineStyle = ChartDashStyle.NotSet;
Chart4.ChartAreas["Default"].AxisY.LineColor = Color.Black;
Chart4.ChartAreas["Default"].AxisY.LineWidth = 3;
//显示Y2
Chart4.ChartAreas["Default"].AxisY2.Enabled = AxisEnabled.True;
//去掉Y2的值
Chart4.ChartAreas["Default"].AxisY2.Minimum = 0;
Chart4.ChartAreas["Default"].AxisY2.Maximum = 100;
Chart4.ChartAreas["Default"].AxisY2.CustomLabels.Add(0,100,"");
//取消Y2的竖线
Chart4.ChartAreas["Default"].AxisY2.MajorGrid.LineStyle = ChartDashStyle.NotSet;
Chart4.ChartAreas["Default"].AxisY2.LineColor = Color.Black;
Chart4.ChartAreas["Default"].AxisY2.LineWidth = 4;
//设置Legends
// Chart4.Legends["Default"].Docking = LegendDocking.Top;
Chart4.Legends["Default"].Enabled = false;
//设置标题
Font myFont = new Font("楷体",10);
Title title = new Title();
title.Text = "能力水平";
title.Font = myFont;
title.Docking = Docking.Bottom;
title.Color = Color.FromArgb(26, 59, 105);
title.BackImageAlign = ChartImageAlign.Bottom;
Chart4.Titles.Add(title);
//取消四个边框的毛线
Chart4.ChartAreas["Default"].AxisX.MajorTickMark.Enabled = false;
Chart4.ChartAreas["Default"].AxisX2.MajorTickMark.Enabled = false;
Chart4.ChartAreas["Default"].AxisY.MajorTickMark.Enabled = false;
Chart4.ChartAreas["Default"].AxisY2.MajorTickMark.Enabled = false;
}