使用DevExpress的WebChartControl控件绘制图表(柱状图、折线图、饼图) 下载本文

内容发布更新时间 : 2024/5/1 17:11:20星期一 下面是文章的全部内容请认真阅读。

使用DevExpress的WebChartControl控件绘制图表(柱状图、折线图、饼图)

WebChartControl是DevExpress控件群下的一个Web图表控件,它使用非常的方便,生成的图表也相当的漂亮。

先贴出几张WebChartControl生成的图表:

Web页面代码WebChartControl.aspx: View Code

1 <%@ Page Language=\ AutoEventWireup=\ CodeBehind=\ Inherits=\ %> 2

3 <%@ Register Assembly=\Version=11.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a\

4 Namespace=\ TagPrefix=\ %> 5

6 <%@ Register assembly=\Version=11.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a\ namespace=\ tagprefix=\ %> 7

8

9

10 13 14

15

17

Width=\ Height=\

18 19

20

21

22

23

24

25 26

27 28 29

Web页面后台代码WebChartControl.aspx.cs View Code

1 using System;

2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI;

6 using System.Web.UI.WebControls; 7 using System.Data;

8 using DevExpress.XtraCharts; 9 using System.Drawing; 10

11 namespace DevDemo 12 {

13 public partial class WebChartControl : System.Web.UI.Page 14 {

15 protected void Page_Load(object sender, EventArgs e)

runat=\

runat=\

runat=\

16 {

17 this.DrawBar(); 18 this.DrawLine(); 19 this.DrawPie();

20 this.DrawBarAndLine(); 21 } 22

23 ///

24 /// 绘制柱状图 25 ///

26 private void DrawBar() 27 { 28

29 ChartServices.SetChartTitle(this.WebChartControl1, true, \年12月第1周收入情况\, true, 2, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font(\宋体\, 12, FontStyle.Bold), Color.Red, 10); //如不需显示图表标题可不用调用本段代码,下同

30 ChartServices.DrawChart(this.WebChartControl1, \收益\, ViewType.Bar, ServiceData.GetWeekMoneyAndCost(), \, \);

31 ChartServices.DrawChart(this.WebChartControl1, \成本\, ViewType.Bar, ServiceData.GetWeekMoneyAndCost(), \, \);

32 ChartServices.SetAxisX(this.WebChartControl1, true, StringAlignment.Center, \星期\, Color.Red, true, new Font(\宋体\, 12, FontStyle.Bold)); //如不需显示X轴标题,可不调用该行代码,下同

33 ChartServices.SetAxisY(this.WebChartControl1, true, StringAlignment.Center, \金额\, Color.Red, true, new Font(\宋体\, 12, FontStyle.Bold)); //如不需显示Y轴标题,可不调用该行代码,下同 34 } 35

36 ///

37 /// 绘制折线图 38 ///

39 private void DrawLine() 40 {

41 ChartServices.SetChartTitle(this.WebChartControl3,true,\年12月第1周收入情况\, true, 2, StringAlignment.Center, ChartTitleDockStyle.Top, true, new Font(\宋体\, 12, FontStyle.Bold), Color.Red, 10);

42 ChartServices.DrawChart(this.WebChartControl3, \收益\, ViewType.Line, ServiceData.GetWeekMoneyAndCost(), \, \);

43 ChartServices.DrawChart(this.WebChartControl3, \成本\, ViewType.Line, ServiceData.GetWeekMoneyAndCost(), \, \);

44 ChartServices.SetAxisX(this.WebChartControl3, true, StringAlignment.Center, \星期\, Color.Red, true, new Font(\宋体\, 12, FontStyle.Bold));

45 ChartServices.SetAxisY(this.WebChartControl3, true, StringAlignment.Center, \金额\, Color.Red, true, new Font(\宋体\, 12, FontStyle.Bold));

Word文档下载:使用DevExpress的WebChartControl控件.doc
搜索更多:使用DevExpress的WebChartControl控件


最新浏览