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

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

 <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();
        }

[MSCHART]如何使用MSCHART实现雷达图_第1张图片

你可能感兴趣的:([MSCHART]如何使用MSCHART实现雷达图)