这个真是一个好东西可惜我不太会总结,摘录一篇,希望有用:
原文地址如下:http://www.cnblogs.com/wrz923/archive/2008/07/05/1236348.html
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Dundas.Charting.WebControl;
using System.Drawing;
public partial class TestChart : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
databindXY();
ControlSet();
//databindXY();
}
private void ControlSet()
{
//设置Chart1的相关属性
Chart1.BackGradientEndColor = Color.White;
Chart1.BorderLineColor = Color.White;
Chart1.BorderLineWidth = 0;
Chart1.BorderSkin.FrameBackColor = Color.MediumTurquoise;
Chart1.BorderSkin.FrameBackGradientEndColor = Color.Teal;
Chart1.Palette = ChartColorPalette.SemiTransparent;
Chart1.Width = 545;
Chart1.Height = 215;
Chart1.ImageType = ChartImageType.Jpeg;
Chart1.AntiAliasing = AntiAliasing.All;
Chart1.Titles.Add("Default");
Chart1.Titles[0].Text = "Dundas Chart Demo演示";
Chart1.Titles[0].Alignment = ContentAlignment.TopCenter;
Chart1.Titles[0].Font = new Font("黑体", 12, FontStyle.Bold);
Chart1.Titles[0].Color = Color.FromArgb(72, 72, 72);
//设置相应Series属性
Chart1.Series["Default"].Type = SeriesChartType.Line;//设置为折现风格
Chart1.Series["Default"].BorderColor = Color.White;
Chart1.Series["Default"].BackGradientType = GradientType.VerticalCenter;
Chart1.Series["Default"].BackGradientEndColor = Color.Khaki;
Chart1.Series["Default"].Color = Color.FromArgb(255, 128, 0);//设置折现的颜色
Chart1.Series["Default"]["PointWidth"] = "0.7";
Chart1.Series["Default"].BorderStyle = ChartDashStyle.Dash;
for(int i =0;i<Chart1.Series["Default"].Points.Count;i++)
{
Chart1.Series["Default"].Points[i].MarkerStyle = MarkerStyle.Diamond;//设置折点的风格
Chart1.Series["Default"].Points[i].MarkerColor = Color.Red;//设置seires中折点的颜色
}
//设置相应的Legend
Chart1.Legends[0].Enabled = true; //设置Legends的为可见
Chart1.Legends[0].Alignment = StringAlignment.Near ;//设置在上方
Chart1.Legends[0].Docking = LegendDocking.Right;//设置Legends的位置在右
Chart1.Legends[0].AutoFitText = true;//自动适应名称的长度,不然会出现..的情况
//设置X轴
Chart1.ChartAreas["Default"].AxisX.Title = "时间";
Chart1.ChartAreas["Default"].AxisX.TitleAlignment = StringAlignment.Far;//设置X轴标题的名称所在位置位远
Chart1.ChartAreas["Default"].AxisX.Interval = 1;//设置X轴显示间隔为2 ,对于X轴数据比较多的时候比较有用
Chart1.ChartAreas["Default"].AxisX.Arrows = ArrowsType.Lines;//设置X轴前面家箭头
//设置Y轴
Chart1.ChartAreas["Default"].AxisY.Title = "常量";
Chart1.ChartAreas["Default"].AxisY.TitleAlignment = StringAlignment.Far;//设置Y轴标题的名称所在位置位远
Chart1.ChartAreas["Default"].AxisY.Arrows = ArrowsType.SharpTriangle;//设置Y轴前面加粗箭头
}
private void databindXY()
{
string[] xValues = new string[7] { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" };
double[] yValues = new double[7] { 50,70,40,30,20,80,10};
Chart1.Series["Default"].Points.DataBindXY(xValues,yValues);
}
}