一个功能强大超级好用的图表组件Dundas Chart

最近因为项目需要,需要为客户的统计数据生成图表,包括柱状图和饼图。我找来了Dundas Software的Dundas Chart,大家可以上它的网站www.dundas.com查看最新版本的信息以及下载该软件它确实是一个功能强大的组件,而且用户友好性方面很值得国产软件学习。

闲话少说,进入该软件的使用。先安装该软件,安装后它包括两个非常有用的功能,一个是做的非常类似msdn的帮助文档,相信对.net程序员非常友好,就当是msdn用吧。另外一个是它的sample,这是一个完整的.net解决方案,你可以在IIS里面配置个网站来访问它。接着你就可以开始通过sample来了解和学习Dundas Chart的强大功能了。

下面给个我学习中生成的图片。Stat.jpg

下面是程序部分源码

 

None.gif private   void  Page_Load( object  sender, System.EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
// 在此处放置用户代码以初始化页面
InBlock.gif
            if(!this.IsPostBack)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
double industry1 = 19.32;
InBlock.gif                
double industry2 = 361.38;
InBlock.gif                
double industry3 = 501.51;
InBlock.gif                
double industryfull = 1020.05;
InBlock.gif                
double fixedasserts = 216.13;
InBlock.gif                
double retailtrade = 32.06;
InBlock.gif                
double foreigntrade = 443.34;
InBlock.gif                
double foreigncapital = 3.41;
InBlock.gif                
//------------------------生产统计图表-------------------------
InBlock.gif
                Dundas.Charting.WebControl.Chart Chart1 = new Dundas.Charting.WebControl.Chart();
InBlock.gif                Chart1.BackImage 
= this.Server.MapPath("cn/images/target/back_img.gif");
InBlock.gif                Chart1.BackGradientEndColor 
= Color.White;
InBlock.gif                Chart1.BorderLineColor 
= Color.White;
InBlock.gif                Chart1.BorderLineWidth 
= 0;
InBlock.gif                Chart1.BorderSkin.FrameBackColor 
= Color.MediumTurquoise;
InBlock.gif                Chart1.BorderSkin.FrameBackGradientEndColor 
= Color.Teal;
InBlock.gif                Chart1.Palette 
= ChartColorPalette.SemiTransparent;
InBlock.gif                Chart1.Width 
= 545;
InBlock.gif                Chart1.Height 
= 215;
InBlock.gif                Chart1.ImageType 
= ChartImageType.Jpeg;
InBlock.gif                Chart1.AntiAliasing 
= AntiAliasing.All;
InBlock.gif                Chart1.Titles.Add(
"Default");
InBlock.gif                Chart1.Titles[
0].Text = "2008年12月火星经济指标";
InBlock.gif                Chart1.Titles[
0].Alignment = ContentAlignment.TopCenter;
InBlock.gif                Chart1.Titles[
0].Font = new Font("黑体"12, FontStyle.Bold);
InBlock.gif                Chart1.Titles[
0].Color = Color.FromArgb(727272);
ContractedSubBlock.gifExpandedSubBlockStart.gif                
饼图("一产", "二产", "三产")#region 饼图("一产", "二产", "三产")
InBlock.gif                
//设置图表区域样式1("一产", "二产", "三产")
InBlock.gif
                Chart1.ChartAreas.Add("Default");
InBlock.gif                ChartArea ChartArea1 
= Chart1.ChartAreas["Default"];
InBlock.gif                ChartArea1.Area3DStyle.Enable3D 
= true;
InBlock.gif                ChartArea1.Area3DStyle.Light 
= LightStyle.None;
InBlock.gif                ChartArea1.Area3DStyle.XAngle 
= 70;
InBlock.gif                ChartArea1.Area3DStyle.YAngle 
= 60;
InBlock.gif                ChartArea1.BorderWidth 
= 0;
InBlock.gif                ChartArea1.BackColor 
= Color.Transparent;
InBlock.gif                ChartArea1.Position.Auto 
= false;
InBlock.gif                ChartArea1.Position.Width 
= 50;
InBlock.gif                ChartArea1.Position.Height 
= 30;
InBlock.gif                ChartArea1.Position.X 
= 65;
InBlock.gif                ChartArea1.Position.Y 
= 10;
InBlock.gif                
//设置图例区域样式1("一产", "二产", "三产")
InBlock.gif
                Legend Legend1 = Chart1.Legends["Default"];
InBlock.gif                Legend1.Alignment 
= StringAlignment.Center;
InBlock.gif                Legend1.BorderWidth 
= 1;
InBlock.gif                Legend1.Font 
= new Font("幼圆"8, FontStyle.Bold);
InBlock.gif                Legend1.BackColor 
= Color.Transparent;
InBlock.gif                Legend1.FontColor 
= Color.Black;
InBlock.gif                Legend1.DockInsideChartArea 
= true;
InBlock.gif                Legend1.DockToChartArea 
= "Default";
InBlock.gif                
//绑定数据1("一产", "二产", "三产")
ExpandedSubBlockStart.gifContractedSubBlock.gif
                double[] yValues = dot.gif{industry1, industry2, industry3};
ExpandedSubBlockStart.gifContractedSubBlock.gif                
string[] xValues = dot.gif{"一产""二产""三产"};
InBlock.gif                Chart1.Series.Add(
"Series1");
InBlock.gif                Series Series1 
= Chart1.Series["Series1"];
InBlock.gif                Series1.Points.DataBindXY(xValues, yValues);
InBlock.gif                Series1.ChartType 
= "Pie";
InBlock.gif                Series1.BorderColor 
= Color.White;
InBlock.gif                Series1.Palette 
= ChartColorPalette.EarthTones;
InBlock.gif                Series1[
"LabelStyle"= "Disabled";
InBlock.gif                Series1.ChartArea 
= "Default";
InBlock.gif                Series1.Legend 
= "Default";
ExpandedSubBlockEnd.gif                
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif                
饼图("投资", "消费", "出口")#region 饼图("投资", "消费", "出口")
InBlock.gif                
//设置图表区域样式2("投资", "消费", "出口")
InBlock.gif
                Chart1.ChartAreas.Add("Second");
InBlock.gif                ChartArea ChartArea2 
= Chart1.ChartAreas["Second"];
InBlock.gif                ChartArea2.Area3DStyle.Enable3D 
= true;
InBlock.gif                ChartArea2.Area3DStyle.Light 
= LightStyle.None;
InBlock.gif                ChartArea2.Area3DStyle.XAngle 
= 70;
InBlock.gif                ChartArea2.Area3DStyle.YAngle 
= 60;
InBlock.gif                ChartArea2.BorderWidth 
= 0;
InBlock.gif                ChartArea2.BackColor 
= Color.Transparent;
InBlock.gif                ChartArea2.Position.Auto 
= false;
InBlock.gif                ChartArea2.Position.Width 
= 50;
InBlock.gif                ChartArea2.Position.Height 
= 30;
InBlock.gif                ChartArea2.Position.X 
= 65;
InBlock.gif                ChartArea2.Position.Y 
= 32;
InBlock.gif                
//设置图例区域样式2("投资", "消费", "出口")
InBlock.gif
                Legend Legend2 = new Legend("Second");
InBlock.gif                Chart1.Legends.Add(Legend2);
InBlock.gif                Legend2.Alignment 
= StringAlignment.Center;
InBlock.gif                Legend2.BorderWidth 
= 1;
InBlock.gif                Legend2.BackColor 
= Color.Transparent;
InBlock.gif                Legend2.Font 
= new Font("幼圆"8, FontStyle.Bold);
InBlock.gif                Legend2.FontColor 
= Color.Black;
InBlock.gif                Legend2.DockInsideChartArea 
= true;
InBlock.gif                Legend2.DockToChartArea 
= "Second";
InBlock.gif                
//绑定数据2("投资", "消费", "出口")
ExpandedSubBlockStart.gifContractedSubBlock.gif
                double[] yValues2 = dot.gif{fixedasserts, retailtrade, foreigntrade};
ExpandedSubBlockStart.gifContractedSubBlock.gif                
string[] xValues2 = dot.gif{"投资""消费""出口"};
InBlock.gif                Chart1.Series.Add(
"Series2");
InBlock.gif                Series Series2 
= Chart1.Series["Series2"];
InBlock.gif                Series2.Points.DataBindXY(xValues2, yValues2);
InBlock.gif                Series2.ChartType 
= "Pie";
InBlock.gif                Series2.BorderColor 
= Color.White;
InBlock.gif                Series2.Palette 
= ChartColorPalette.Pastel;
InBlock.gif                Series2[
"LabelStyle"= "Disabled";
InBlock.gif                Series2.ChartArea 
= "Second";
InBlock.gif                Series2.Legend 
= "Second";
ExpandedSubBlockEnd.gif                
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif                
柱状图#region 柱状图
ExpandedSubBlockStart.gifContractedSubBlock.gif                
double[] yTitle3 = dot.gif{industry1, industry2,industryfull,0, industry3, fixedasserts, retailtrade, foreigntrade, foreigncapital};
InBlock.gif                
double x = MaxValue(yTitle3)/10;
InBlock.gif                
//设置图表区域样式3
InBlock.gif
                Chart1.ChartAreas.Add("3nd");
InBlock.gif                ChartArea ChartArea3 
= Chart1.ChartAreas["3nd"];
InBlock.gif                ChartArea3.Area3DStyle.Enable3D 
= false;
InBlock.gif                ChartArea3.Area3DStyle.Light 
= LightStyle.Realistic;
InBlock.gif                ChartArea3.AxisX.LineColor 
= Color.FromArgb(64,64,64);
InBlock.gif                ChartArea3.AxisX.LabelStyle.Font 
= new Font("幼圆"8, FontStyle.Bold);
InBlock.gif                ChartArea3.AxisX.LabelStyle.FontColor 
= Color.Black;
InBlock.gif                ChartArea3.AxisX.LabelStyle.OffsetLabels 
= false;
InBlock.gif                ChartArea3.AxisX.LabelsAutoFit 
= false;
InBlock.gif                ChartArea3.AxisX.MajorGrid.Enabled 
= false;
InBlock.gif                ChartArea3.AxisX.MajorTickMark.Enabled 
= true;
InBlock.gif                ChartArea3.AxisX.MajorTickMark.LineColor 
= Color.Transparent;
InBlock.gif                ChartArea3.AxisX.MajorTickMark.Interval 
= 4;
InBlock.gif                ChartArea3.AxisY.CustomLabels.Add(
0, MaxValue(yTitle3)*2.3"亿元");
InBlock.gif                ChartArea3.AxisY.LabelStyle.Enabled 
= true;
InBlock.gif                ChartArea3.AxisY.LabelStyle.FontAngle 
= 0;
InBlock.gif                ChartArea3.AxisY.LabelStyle.Font 
= new Font("幼圆"10, FontStyle.Bold);
InBlock.gif                ChartArea3.AxisY.MajorGrid.Enabled 
= false;
InBlock.gif                ChartArea3.AxisY.MajorTickMark.Enabled 
= false;
InBlock.gif                ChartArea3.BorderWidth 
= 0;
InBlock.gif                ChartArea3.BackColor 
= Color.Transparent;
InBlock.gif                ChartArea3.Position.Auto 
= false;
InBlock.gif                ChartArea3.Position.Width 
= 80;
InBlock.gif                ChartArea3.Position.Height 
= 67;
InBlock.gif                ChartArea3.Position.X 
= 5;
InBlock.gif                ChartArea3.Position.Y 
= 28;
InBlock.gif                
//设置图例区域样式3
InBlock.gif
                Legend Legend3 = new Legend("3nd");
InBlock.gif                Chart1.Legends.Add(Legend3);
InBlock.gif                Legend3.Enabled 
= false;
InBlock.gif                Legend3.DockToChartArea 
= "3nd";
InBlock.gif                
//绑定数据3
ExpandedSubBlockStart.gifContractedSubBlock.gif
                double[] yValues3 = dot.gif{industry1+x, industry2+x,industryfull+x,0, industry3+x, fixedasserts+x, retailtrade+x, foreigntrade+x, foreigncapital+x};
ExpandedSubBlockStart.gifContractedSubBlock.gif                
string[] xValues3 = dot.gif{"第一产业""第二产业""工业总产值"" ""第三产业""固定资产投资""消费零售总额""外贸出口""实际利用外资"};
InBlock.gif                Chart1.Series.Add(
"Series3");
InBlock.gif                Series Series3 
= Chart1.Series["Series3"];
InBlock.gif                Series3.Points.DataBindXY(xValues3, yValues3);
InBlock.gif                Series3.ChartType 
= "Column";
InBlock.gif                Series3.BorderColor 
= Color.White;
InBlock.gif                Series3.BackGradientType 
= GradientType.VerticalCenter;
InBlock.gif                Series3.BackGradientEndColor 
= Color.Khaki;
InBlock.gif                Series3.Color 
= Color.FromArgb(255,128,0);
InBlock.gif                Series3[
"PointWidth"= "0.7";
InBlock.gif                Series3.ChartArea 
= "3nd";
InBlock.gif                Series3.Legend 
= "3nd";
InBlock.gif                
for(int i=0;i<Series3.Points.Count;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if(yTitle3[i]!=0) Series3.Points[i].Label = yTitle3[i].ToString();
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif                
#endregion

InBlock.gif                Chart1.Save(
this.Server.MapPath("Stat.jpg"), ChartImageFormat.Jpeg);
InBlock.gif
ExpandedSubBlockEnd.gif            }

ExpandedBlockEnd.gif        }

None.gif
None.gif
private   double  MaxValue( double [] yValue)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
double maxvalue = 0;
InBlock.gif            
for(int i=0;i<yValue.Length;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(yValue[i] > maxvalue) maxvalue = yValue[i];
ExpandedSubBlockEnd.gif            }

InBlock.gif            
return maxvalue;
ExpandedBlockEnd.gif        }

转载于:https://www.cnblogs.com/jimmyhsu/archive/2004/11/26/69043.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值