<system.web> <httpHandlers> <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" /> </httpHandlers> <pages validateRequest="false"> <controls> <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </controls> </pages> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true" /> <handlers> <remove name="ChartImageHandler" /> <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </handlers> </system.webServer>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChartFirst.aspx.cs" Inherits="ChartFirst" %> <%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>雷達圖</title> </head> <body> <form id="form1" runat="server"> <table> <tr> <td> <asp:Chart ID="Chart1" runat="server" Width="600px" Height="600px" Visible="false" BackColor="#e7f6ff"> <Titles> <asp:Title Text="雷達圖"> <Position Y="95" X="50"></Position> </asp:Title> </Titles> <Series> <asp:Series Name="Series1" Color="Red" ChartArea="ChartArea1" ChartType="Radar" IsValueShownAsLabel="false" BorderWidth="2"> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1" AlignmentOrientation="Vertical"> <AxisY LineColor="64, 64, 64, 64"> <LabelStyle Font="宋體, 8.25pt" /> <MajorGrid LineColor="silver" /> <MajorTickMark Size="0" /> </AxisY> <AxisX LineColor="64, 64, 64, 64"> <LabelStyle Font="宋體, 8.25pt" /> </AxisX> <Position Y="0" Height="100" Width="100" X="0"></Position> </asp:ChartArea> </ChartAreas> </asp:Chart> </td> </tr> </table> <input id="hidSrc" name="hidSrc" type="hidden" runat="server" /> </form> </body> </html>
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GetCharData(); } } /// <summary> /// 綁定雷達圖 /// </summary> private void GetCharData() { DataTable dt = 獲取數據; List<實體類> list = DataTableToList<實體類>.ConvertToList(dt); Chart1.Visible = true; Chart1.Series["Series1"].Points.DataBind(list, "綁定的字段", "TempScore", "Tooltip=TempScore,Url=LinkUrl"); Chart1.Series["Series1"]["AreaDrawingStyle"] = "Polygon"; Chart1.Series["Series1"]["RadarDrawingStyle"] = "Line"; if (point != 0) { Chart1.ChartAreas["ChartArea1"].AxisY.Interval = point / 5; Chart1.ChartAreas["ChartArea1"].AxisY.Maximum = point; Chart1.ChartAreas["ChartArea1"].AxisY.Minimum = 0; } } }