WebChart 柱状图源码

 

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:1627400839 -2147483648 8 0 66047 0;} @font-face {font-family:"Lucida Console"; panose-1:2 11 6 9 4 5 4 2 2 4; mso-font-charset:0; mso-generic-font-family:modern; mso-font-pitch:fixed; mso-font-signature:-2147482993 6144 0 0 31 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

 

< %@  Page Language ="C#"  % >
< %@  Register TagPrefix ="web"  Namespace ="WebChart"  Assembly ="WebChart"  % >
< %@  Import Namespace ="System.Data"  % >
< %@  Import Namespace ="System.Drawing"  % > < script  runat ="server">
 
    void  Page_Load(object  o, EventArgs e) {
        CreateChart();
    }
    
    void  CreateChart() {
        DataSet ds =  CreateDataSet();
 
        StackedColumnChart chart =  new  StackedColumnChart();
        chart.Fill.Color =  Color.FromArgb(50 , Color.Red);
        chart.Shadow.Visible =  true;
        chart.MaxColumnWidth =  15 ;
        chart.Legend =  "Pri 0" ;
 
        StackedColumnChart chart1 =  new  StackedColumnChart();
        chart1.Fill.Color =  Color.FromArgb(50 , Color.Yellow);
        chart1.Shadow.Visible =  true;
        chart1.Legend =  "Pri 1" ;
 
        StackedColumnChart chart2 =  new  StackedColumnChart();
        chart2.Fill.Color =  Color.FromArgb(50 , Color.Blue);
        chart2.Shadow.Visible =  true;
        chart2.Legend =  "Pri 2" ;
 
        StackedColumnChart chart3 =  new  StackedColumnChart();
        chart3.Fill.Color =  Color.FromArgb(50 , Color.Green);
        chart3.Shadow.Visible =  true;
        chart3.Legend =  "Pri 3" ;
 
        LineChart chart4 =  new  LineChart();
        chart4.Line.Color =  Color.Gold;
        chart4.Fill.Color =  Color.Gold;
        chart4.LineMarker =  new  TriangleLineMarker(6 , Color.Red, Color.Gold);
        chart4.Legend =  "Total" ;
 
        LineChart chart5 =  new  LineChart();
        chart5.Line.Color =  Color.Green;
        chart5.Fill.Color =  Color.Green;
        chart5.LineMarker =  new  DiamondLineMarker(8 , Color.Green, Color.Yellow);
        chart5.Legend =  "Goal" ;
 
        foreach (DataRow row in  ds.Tables[0 ].Rows) {
            chart.Data.Add(new  ChartPoint(row["date" ].ToString(), (int )row["pri0" ]));
            chart1.Data.Add(new  ChartPoint(row["date" ].ToString(), (int )row["pri1" ]));
            chart2.Data.Add(new  ChartPoint(row["date" ].ToString(), (int )row["pri2" ]));
            chart3.Data.Add(new  ChartPoint(row["date" ].ToString(), (int )row["pri3" ]));
            chart4.Data.Add(new  ChartPoint(row["date" ].ToString(), (int )row["total" ]));
            chart5.Data.Add(new  ChartPoint(row["date" ].ToString(), (int )row["goal" ]));
        }
 
        chartControl1.Charts.Add(chart);
        chartControl1.Charts.Add(chart1);
        chartControl1.Charts.Add(chart2);
        chartControl1.Charts.Add(chart3);
        chartControl1.Charts.Add(chart4);
        chartControl1.Charts.Add(chart5);
        chartControl1.RedrawChart();
    }
    /// <summary>
    /// Just generate some random data
    /// </summary>
    DataSet CreateDataSet() {
        DataSet ds =  new  DataSet();
        DataTable table =  ds.Tables.Add("Table" );
        table.Columns.Add("date" );
        table.Columns.Add("pri0"typeof (int ));
        table.Columns.Add("pri1"typeof (int ));
        table.Columns.Add("pri2"typeof (int ));
        table.Columns.Add("pri3"typeof (int ));
        table.Columns.Add("total"typeof (int ));
        table.Columns.Add("goal"typeof (int ));
        Random rnd =  new  Random();
        for  (int  i =  0 ;  i < 20 ;  i++) {
            DataRow row =  table.NewRow();
            row["date"=  DateTime.Now.AddDays(i).ToString("mm/dd" );
            int  pri0 =  rnd.Next(200 );
            int  pri1 =  rnd.Next(200 );
            int  pri2 =  rnd.Next(200 );
            int  pri3 =  rnd.Next(200 );
            int  sum =  pri0 + pri1 + pri2 + pri3;
            int  goal =  rnd.Next(sum);
 
            row["pri0"=  pri0;
            row["pri1"=  pri1;
            row["pri2"=  pri2;
            row["pri3"=  pri3;
            row["total"=  sum;
            row["goal"=  goal;
            table.Rows.Add(row);
        }
        return  ds;
    }
</ script >
< html >
< head >
    
< title > Untitled Page </ title >
</ head >
< body >
    
< form  id ="form1"  runat ="server">
        
< web:ChartControl  Runat ="server"  ID ="chartControl1"  ChartPadding ="30"  BottomChartPadding ="20"
            TopPadding
="20"  Padding ="20"  Width ="800"  Height ="450"  BorderStyle ="outset">
            
< Background  Type ="LinearGradient"  Color ="#ccccff"  EndPoint ="900,900"   />
            
< Border  Color ="#6699ff"   />
            
< ChartTitle  Text ="My Product Bugs"  Font ="Tahoma, 12pt, style=Bold"  ForeColor ="White"   />
            
< XAxisFont  StringFormat ="Near, Near, Character, DirectionVertical"   />
            
< XTitle  Text ="Date"  Font ="Tahoma, 8pt, style=Bold"  ForeColor ="White"   />
            
< YTitle  Text ="# Bugs"  Font ="Tahoma, 8pt, style=Bold"  StringFormat ="Near, Near, Character, DirectionVertical"   />
        
</ web:ChartControl >
    
</ form >
</ body >
</ html >

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值