微软Chart控件的安装及其使用,参考:微软图表控件MsChart使用初探,这篇文章写得相当详细,入门使用全是她的功劳~
以下,是分享的一个柱状图的好看的样式, 先预览一下:
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>
后台代码: 绑定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 }
联系客服