[MSCHART]柱状图

后台代码:

private void DataBind() { ProductByYear py = new ProductByYear(); for (int i = 0; i < RadioButtonList1.Items.Count; i++) { if (RadioButtonList1.Items[i].Selected) { py.Company = RadioButtonList1.Items[i].Value.Trim(); } } //py.Company = "ZE"; ProductByYearManager pymgr = new ProductByYearManager(); this.Store1.DataSource = pymgr.ProductByYearList(py); this.Store1.DataBind(); this.ChartYear.Width = 600; this.ChartYear.Height = 400; this.ChartYear.DataSource = pymgr.ProductByYearChart(py); this.ChartYear .DataBind (); this.ChartYear.Series["last year"].ChartType = SeriesChartType.Column; this.ChartYear.Series["year"].ChartType = SeriesChartType.Column; this.ChartYear.Series["year"].XValueMember = "产品类别"; this.ChartYear.Series["year"].YValueMembers = "本年度金额"; this.ChartYear.Series["last year"].XValueMember = "产品类别"; this.ChartYear.Series["last year"].YValueMembers = "上一年度金额"; //显示数据 ChartYear.Series["year"].IsValueShownAsLabel = true; ChartYear.Series["last year"].IsValueShownAsLabel = true; this.ChartYear.Legends[0].Enabled = true; //this.ChartYear.ChartAreas["ChartArea1"].AxisX.Title = "产品类型"; this.ChartYear.ChartAreas["ChartArea1"].AxisY.Title = "销售金额"; //背景色设置 this.ChartYear.ChartAreas["ChartArea1"].ShadowColor = Color.Transparent; this.ChartYear.ChartAreas["ChartArea1"].BackColor = Color.FromArgb(209, 237, 254); //该处设置为了由天蓝到白色的逐渐变化 this.ChartYear.ChartAreas["ChartArea1"].BackGradientStyle = GradientStyle.TopBottom; this.ChartYear.ChartAreas["ChartArea1"].BackSecondaryColor = Color.White; //中间X,Y线条的颜色设置 this.ChartYear.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64); this.ChartYear.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64); //X.Y轴数据显示间隔 this.ChartYear.DataBind(); }

前台代码:

<asp:Chart ID="ChartYear" runat="server" BackColor="LightSteelBlue" BackGradientStyle="TopBottom" BackSecondaryColor="AliceBlue" EnableTheming="False" EnableViewState="True"> <Titles> <asp:Title Font="微软雅黑, 16pt" Text="本年度VS上一年度销售额(单位:10万)" Alignment="TopCenter"></asp:Title> <asp:Title Docking="Bottom" Font="Trebuchet MS, 8.25pt" Text="Zettlercn Corporation" Alignment="MiddleRight"></asp:Title> </Titles> <legends> <asp:Legend BackColor="Transparent" Alignment="Center" Docking="Bottom" Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="False" Name="Default" LegendStyle="Row"></asp:Legend> </legends> <Series> <asp:Series Name="year" > </asp:Series> <asp:Series Name="last year" > </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1"> </asp:ChartArea> </ChartAreas> </asp:Chart>


图:


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值