Code Behind Page Page /Reports/StackedChart.aspx.cs (C#)
Used by Page /Reports/stackedchart.aspx (C#)
1: using System;  
2: using System.Collections;  
3: using System.ComponentModel;  
4: using System.Data;  
5: using System.Drawing;  
6: using System.Web;  
7: using System.Web.SessionState;  
8: using System.Web.UI;  
9: using System.Web.UI.WebControls;  
10: using System.Web.UI.HtmlControls;  
11: using System.Web.UI.DataVisualization.Charting;  
12:   
13: namespace System.Web.UI.DataVisualization.Charting.Samples  
14: {  
15:     /// <summary>  
16:     /// Summary description for WebForm1.  
17:     /// </summary>  
18:     public partial class StackedChart : System.Web.UI.Page  
19:     {  
20:         protected System.Web.UI.WebControls.Label Label1;  
21:   
22:   
23:       
24:         protected void Page_Load(object sender, System.EventArgs e)  
25:         {  
26:             // Populate series data  
27:             Random    random = new Random();  
28:             for(int pointIndex = 0; pointIndex < 10; pointIndex++)  
29:             {  
30:                 Chart1.Series["Series1"].Points.AddY(Math.Round((double)random.Next(45, 95),0));  
31:                 Chart1.Series["Series2"].Points.AddY(Math.Round((double)random.Next(5, 75),0));  
32:                 Chart1.Series["Series3"].Points.AddY(Math.Round((double)random.Next(5, 95),0));  
33:                 Chart1.Series["Series4"].Points.AddY(Math.Round((double)random.Next(35, 95),0));  
34:             }              
35:   
36:             // Set chart type  
37:             string    chartTypeName;  
38:             chartTypeName = "StackedColumn100";  
39:   
40:   
41:             Chart1.Series["Series1"].ChartType = (SeriesChartType) Enum.Parse( typeof(SeriesChartType), chartTypeName, true );  
42:             Chart1.Series["Series2"].ChartType = (SeriesChartType) Enum.Parse( typeof(SeriesChartType), chartTypeName, true );  
43:             Chart1.Series["Series3"].ChartType = (SeriesChartType) Enum.Parse( typeof(SeriesChartType), chartTypeName, true );  
44:             Chart1.Series["Series4"].ChartType = (SeriesChartType) Enum.Parse( typeof(SeriesChartType), chartTypeName, true );  
45:   
46:                 Chart1.Series["Series1"].IsValueShownAsLabel = true;  
47:                 Chart1.Series["Series2"].IsValueShownAsLabel = true;  
48:                 Chart1.Series["Series3"].IsValueShownAsLabel = true;  
49:                 Chart1.Series["Series4"].IsValueShownAsLabel = true;  
50:               
51:             // Set X axis margin for the area chart  
52:             Chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true;  
53:             Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;  
54:                 Chart1.ResetAutoValues();  
55:         }  
56:   
57:         #region Web Form Designer generated code  
58:         override protected void OnInit(EventArgs e)  
59:         {  
60:             InitializeComponent();  
61:             base.OnInit(e);  
62:         }  
63:           
64:         /// <summary>  
65:         /// Required method for Designer support - do not modify  
66:         /// the contents of this method with the code editor.  
67:         /// </summary>  
68:         private void InitializeComponent()  
69:         {      
70:   
71:         }  
72:         #endregion  
73:   
74:     }  
75: }  

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.