[MSCHART]柱状图

标签: alignmentasp产品server微软
3776人阅读 评论(3) 收藏 举报
分类:

后台代码:

    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>


图:


1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2334897次
    • 积分:34594
    • 等级:
    • 排名:第144名
    • 原创:897篇
    • 转载:489篇
    • 译文:6篇
    • 评论:272条
    联系方式
    • ERP群:68148773
    • C#群: 254167627
    • SQL群:446802573
    • 会计群:426046886
    • 安卓群:604859607
    • ext群: 556270614
    • Tea群: 126748158
    • 德仔工作室
    • 德仔淘宝店
    鼎捷易飞精英群
    博客专栏
    最新评论
    文章存档