微軟Chart控件的安裝及其使用,參考:微軟圖表控件MsChart使用初探,這篇文章寫得相當(dāng)詳細(xì),入門使用全是她的功勞~
以下,是分享的一個(gè)柱狀圖的好看的樣式, 先預(yù)覽一下:

HTML <asp:Chart ID="Chart2" runat="server" BorderlineDashStyle="Solid" BorderlineColor="Gray" Width="768px" BackGradientStyle="DiagonalLeft" BackSecondaryColor="AliceBlue" BackColor="WhiteSmoke"> <Legends> <asp:Legend Name="ExpLgd" BackColor="Transparent" Docking="Top"></asp:Legend> </Legends> <Series> <asp:Series Name="Series1" IsValueShownAsLabel="true" Color="#0066FF" CustomProperties="DrawingStyle=Cylinder, MinPixelPointWidth=20, MaxPixelPointWidth=35, PointWidth=0.3" IsXValueIndexed="False" ShadowOffset="1" Legend="ExpLgd" ChartArea="ChartArea1"> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1" BackColor="WhiteSmoke" BackSecondaryColor="Silver" BackGradientStyle="DiagonalLeft" ShadowOffset="2"> <AxisY> <MajorGrid LineColor="LightSlateGray" LineDashStyle="Dash" /> </AxisY> <AxisX> <MajorGrid Enabled="False" /> <LabelStyle Font="Microsoft Sans Serif, 8pt" /> </AxisX> </asp:ChartArea> </ChartAreas> </asp:Chart>
后臺(tái)代碼: 綁定Chart
1 private void BindScoreTrend() 2 { 3 Report1BLL reportBLL = new Report1BLL(); 4 DataTable dt = null; 5 dt = reportBLL.GetScoreTrend(testID); 6 7 Chart2.Series["Series1"].Points.DataBind(dt.DefaultView, "SWVersion", "TotalScore", "LegendText=SWVersion,YValues=TotalScore,ToolTip=TotalScore"); 8 Chart2.Series["Series1"].ChartType = SeriesChartType.Column; 9 Chart2.Series["Series1"].Name = " Total Score"; //ddlActivity.SelectedItem.Text; 10 Chart2.DataBind(); 11 }
|