快捷搜索:  as  test  1111  test aNd 8=8  test++aNd+8=8  as++aNd+8=8  as aNd 8=8

巴黎人登录下载:用dotnetCHARTING 制作柱形图折线图和圆饼图



近情因为项目必要,要做几个统计图. 网上找了找发清楚明了ZedGraph控件和dotnetCHARTIN控件.

ZedGraph: 支持winform和webform。支持可视化设计,并且最主要他是开源的.

dotnetCHARTIN:必要到网上找破解版的 下载地址:http://files.cnblogs.com/xiaogangqq123/dotnetcharting.rar

网上说dotnetCHARTIN这个控件对照消费机能.并且支持二维和三维.ZedGraph控件开源.扩展性强,然则只支持二维图形.机能较好.

因为项目必要三维的 以是选择了dotnetCHARTIN这个.经由过程几回反复测试.感到dotnetCHARTIN机能还行.当然是在抱负环境下.

因为网上dotnetCHARTIN资料较少.看了下赞助文档..自己做了个Demo分手对10条线一万条数据和10条10万条数据做了个初步测试.

1万条:天生图片速率大年夜概在2秒到5秒;

10万条:速率预计在5秒-10秒之间 ,

大年夜体是这个样子.贴出代码:

C#代码

public class Charting

{

#region 共有变量

///

/// 图片寄放路径

///

public string PhaysicalImagePath { get; set; }

///

/// 标题

///

public string Title { get; set; }

///

/// X轴名称

///

public string XName { get; set; }

///

/// Y轴名称

///

public string YName { get; set; }

///

/// 图例名称

///

public string SeriseName { get; set; }

///

/// 宽度

///

public int SeriseWidth { get; set; }

///

/// 高度

///

public int SeriseHeight { get; set; }

///

/// 数据源

///

public DataTable DataSoure { get; set; }

public bool IsUse3D { get; set; }

public CharType type { get; set; }

#endregion

public Charting() { }

///

/// 柱形图

///

///

public void CreateCombo(dotnetCHARTING.Chart Chart1)

{

Chart1.Title = Title;

Chart1.XAxis.Label.Text = XName;

Chart1.YAxis.Label.Text = this.YName;

Chart1.TempDirectory = this.PhaysicalImagePath;

Chart1.Width = this.SeriseWidth;

Chart1.Height = this.SeriseHeight;

Chart1.Type巴黎人登录下载 = ChartType.Combo;

Chart1.Series.Type = SeriesType.Cylinder;

Chart1.Series.Name = t巴黎人登录下载his.SeriseName;

Chart1.Series.Data = this.DataSoure;

Chart1.SeriesCollection.Add();

Chart1.DefaultSeries.DefaultElement.ShowValue = true;

Chart1.ShadingEffect = true;

Chart1.Use3D = IsUse3D;

Chart1.Series.DefaultElement.ShowValue = true;

}

///

/// 饼图

///

///

public void Create巴黎人登录下载Pie(dotnetCHARTING.Chart Chart1)

{

Chart1.Title = Title;

Chart1.XAxis.Label.Text = XName;

Chart1.YAxis.Label.Text = this.YName;

Chart1.TempDirectory = this.PhaysicalImagePath;

Chart1.Width = this.SeriseWidth;

Chart1.Height = this.Serise巴黎人登录下载Height;

Chart1.Type = ChartType.Pie;

Chart1.Series.Type = SeriesType.Cylinder;

Chart1.Series.Name = this.SeriseName;

Chart1.ShadingEffect = true;

Chart1.Use3D = IsUse3D;

Chart1.DefaultSeries.DefaultElement.Transparency = 20;

Chart1.DefaultSeries.DefaultElement.ShowValue = true;

Chart1.PieLabelMode = PieLabelMode.Outside;

Chart1.SeriesCollection.Add(getArrayData());

Chart1.Series.DefaultElement.ShowValue = true;

}

private SeriesCollection getArrayData()

{

SeriesCollection SC = new SeriesCollection();

DataTable dt = this.DataSoure;

for (int i = 0; idt.Rows.Count; i)

{

Series s = new Series();

s.Name = dt.Rows[i][0].ToString();

Element e = new Element();

// 每元素的名称

e.Name = dt.Rows[i][0].ToString();

// 每元素的大年夜小数值

e.YValue = Convert.ToDouble(dt.Rows[i][1].ToString());

s.Elements.Add(e);

SC.Add(s);

}

return SC;

}

///

/// 曲线图

///

///

public void CreateLine(dotnetCHARTING.Chart Chart1)

{

Chart1.Title = Title;

Chart1.XAxis.Label.Text = XName;

Chart1.YAxis.Label.Text = this.YName;

Chart1.TempDirectory = this.PhaysicalImagePath;

Chart1.Width = this.SeriseWidth;

Chart1.Height = this.SeriseHeight;

Chart1.Type = ChartType.Combo;

//此处必然要用DefaultSeries.Type = SeriesType.Line 否则没效果

Chart1.DefaultSeries.Type = SeriesType.Line;

Chart1.Series.Name = this.SeriseName;

Chart1.Series.Data = this.DataSoure;

Chart1.SeriesCollection.Add();

Chart1.DefaultSeries.DefaultElement.ShowValue = true;

Chart巴黎人登录下载1.ShadingEffect = false;

Chart1.Use3D = IsUse3D;

Chart1.Series.DefaultElement.ShowValue = true;

}

}

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

您可能还会对下面的文章感兴趣: