DevExpress控件使用交流,DevExpress中国社区 售前咨询
当前位置: 首页 > 开发资源 » 示例代码 » DevExpress XtraCharts示例二:向Web应用程序中添加图表

DevExpress XtraCharts示例二:向Web应用程序中添加图表

作者:zhuhm   来源:本站原创   浏览:Loading...次   发布时间:2012-09-17   评论:0条

本示例主要介绍如何在设计时和运行时添加WebChartControl到web页面。

设计时

默认情况下, WebChartControl项目被添加到VS IDE下的DX.12.1: Data 工具箱选项卡。因此,若要Web Chart图表控件添加到您的项目中,你只需要拖动相应的工具箱项目,然后将其放置到窗体上。

DevExpress,XtraCharts,示例,ChartControl控件,图表,web页面

接下来,你可以在图表中添加2D和3D系列,并且用数据填充。

运行时

1、建一个新的ASP.NET Web应用程序(Visual Studio 2008或2010),或打开一个现有的ASP.NET Web应用程序。

2、切换到Default.aspx 页面的Design视图,将ASPxButton控件从DX.12.1: Common Controls工具箱选项卡中,拖动到页面。接下来,我们将处理Click事件,从而生成web图表。

DevExpress,XtraCharts,示例,ChartControl控件,图表,web页面

3、将所需的程序集添加到项目中。

4、双击ASPxButton1,处理Click事件。将如下的代码添加到事件处理器中。

C#
using System;
using DevExpress.XtraCharts;
using DevExpress.XtraCharts.Web;
// ... 
protected void ASPxButton1_Click(object sender, EventArgs e) {
// Create a WebChartControl instance. 
WebChartControl WebChartControl1 = new WebChartControl();
// Add the chart to the form. 
// Note that a chart isn't initialized until it's added to the form's collection of controls. 
this.form1.Controls.Add(WebChartControl1);
// Create a line series and add points to it. 
Series series1 = new Series("My Series", ViewType.Line);
series1.Points.Add(new SeriesPoint("A", new double[] { 2 }));
series1.Points.Add(new SeriesPoint("B", new double[] { 7 }));
series1.Points.Add(new SeriesPoint("C", new double[] { 5 }));
series1.Points.Add(new SeriesPoint("D", new double[] { 9 }));
// Add the series to the chart. 
WebChartControl1.Series.Add(series1);
}


VB
Imports System
Imports DevExpress.XtraCharts
Imports DevExpress.XtraCharts.Web
' ... Protected Sub ASPxButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
' Create a WebChartControl instance. 
Dim WebChartControl1 As New WebChartControl()' Add the chart to the form. 
' Note that a chart isn't initialized until it's added to the form's collection of controls. 
Me.form1.Controls.Add(WebChartControl1)
' Create a line series and add points to it. 
Dim series1 As New Series("My Series", ViewType.Line)
series1.Points.Add(New SeriesPoint("A", New Double() { 2 }))
series1.Points.Add(New SeriesPoint("B", New Double() { 7 }))
series1.Points.Add(New SeriesPoint("C", New Double() { 5 }))
series1.Points.Add(New SeriesPoint("D", New Double() { 9 })) ' Add the series to the chart. 
WebChartControl1.Series.Add(series1)
End Sub 

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/DevExpress-Resources/Demo-244.html

关键字: XtraCharts 

相关产品: DXperience ASP.NET Subscription

评论列表

暂无评论

请谈谈你的看法 请使用IE或者Firefox浏览器,暂不支持Chrome!

昵称 不填则默认为游客评论

DevExpress DXperience DXv2 v12

DevExpress DXperience 下载 download

DevExpress购买、价格、授权

慧都控件网为DevExpress界面控件的中国地区唯一正式授权经销商,正版控件销售公司,授权代理商,经销商及合作伙伴。

电话:400-700-1020
        023-66090381

邮箱:sales@evget.com

>>如何选择正规控件购买渠道