原创

[MSCHART]如何使用MSCHART实现雷达图

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://david.blog.csdn.net/article/details/49584775

抓取数据:这里写图片描述

 <asp:Chart ID="Chart1" runat="server" BackColor="LightSteelBlue" BackGradientStyle="TopBottom" BackSecondaryColor="AliceBlue" EnableTheming="False" EnableViewState="True" >
                                                      <Series>
                                                         <%-- <asp:Series Name="Series1" ChartType="Radar">
                                                          </asp:Series>--%>
                                                      </Series>
                                                      <ChartAreas>
                                                          <%--<asp:ChartArea Name="ChartArea1">
                                                          </asp:ChartArea>--%>
                                                      </ChartAreas>
                                                  </asp:Chart>
/// <summary>
        /// 销售额比较
        /// </summary>
        private void RadarBind() 
        {
            DataTable rd_dt = new DataTable();
            rd_dt = SqlHelper.ExecuteDataset(SqlHelper.conn, CommandType.StoredProcedure, "UP_RadarSale").Tables[0];
            Chart1.Height = 250;
            Chart1.Width = 360;
            Chart1.DataSource = rd_dt;
            // Add title 
            //Chart1.Titles.Add("当年销售额 VS 上年销售额");
            // Add a legend 
            Legend lgnd = new Legend();
            lgnd.Enabled = true;
            Chart1.Legends.Add(lgnd);



            Chart1.Legends[0].BackColor = System.Drawing.Color.Transparent;
            Chart1.Legends[0].Docking = System.Web.UI.DataVisualization.Charting.Docking.Top;
            Chart1.Legends[0].Alignment = System.Drawing.StringAlignment.Center;

            ChartArea ca = new ChartArea("myChartArea");
            Chart1.ChartAreas.Add(ca);


            string sale = String.Empty;
            for (int i = 1; i < rd_dt.Columns.Count; i++)
            {
                sale = rd_dt.Columns[i].ColumnName;

                Chart1.Series.Add(sale);//Name of the series :当年销售额 and 上年销售额
                Chart1.Series[sale].YValueMembers = sale;//Either 当年销售额 or 上年销售额
                Chart1.Series[sale].XValueMember = rd_dt.Columns[0].ColumnName;//Criteria
                //Define here: what kind of Chart you want
                Chart1.Series[sale].ChartType = SeriesChartType.Radar;

            }
            //背景色设置
            this.Chart1.ChartAreas["myChartArea"].ShadowColor = Color.Transparent;
            this.Chart1.ChartAreas["myChartArea"].BackColor = Color.FromArgb(209, 237, 254);         //该处设置为了由天蓝到白色的逐渐变化
            this.Chart1.ChartAreas["myChartArea"].BackGradientStyle = GradientStyle.TopBottom;
            this.Chart1.ChartAreas["myChartArea"].BackSecondaryColor = Color.White;
            //中间X,Y线条的颜色设置
            this.Chart1.ChartAreas["myChartArea"].AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
            this.Chart1.ChartAreas["myChartArea"].AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);

            // Show as 3D
            Chart1.ChartAreas["myChartArea"].Area3DStyle.Enable3D = true;
            //binding data
            Chart1.DataBind();
        }

这里写图片描述

文章最后发布于: 2015-11-02 11:58:25
展开阅读全文
0 个人打赏
私信求帮助

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 鲸 设计师: meimeiellie

分享到微信朋友圈

×

扫一扫,手机浏览