线性图,ChartType=“Line”是折线,ChartType="Spline"是平滑曲线
HTML教程
1 <asp:Chart ID="Chart1" runat="server" Width="930px" Height="500" BackColor="Azure" BackSecondaryColor="White" BackGradientStyle="TopBottom">
2 <Legends>
3 <%-- <asp:Legend Alignment="Center" Docking="Right" Name="Legend1" Title="Test Value">
4 </asp:Legend>--%>
5 </Legends>
6 <Titles>
7 <asp:Title Font="微软雅黑, 16pt" Name="Title1" Text="">
8 </asp:Title>
9 </Titles>
10 <Series>
11 <asp:Series Name="Software" IsValueShownAsLabel="true" ChartType="Spline" XValueType="String" YValueMembers="TestValue" BorderColor="AliceBlue" BorderWidth="2">
12 </asp:Series>
13 </Series>
14 <ChartAreas>
15 <asp:ChartArea Name="ChartArea1" BackColor="Azure" BackSecondaryColor="White" BackGradientStyle="TopBottom">
16 <AxisX LineColor="Blue" LineWidth="2" TitleForeColor="Red" TextOrientation="Horizontal" ToolTip="Software">
17 <MinorGrid Interval="1" LineColor="Blue" />
18 </AxisX>
19 <AxisY LineColor="Blue" LineWidth="2" Title="TestValue(Unit:mAh)" TitleForeColor="Red" TitleAlignment="Far">
20 <MinorGrid Interval="1" LineColor="Blue" />
21 </AxisY>
22 </asp:ChartArea>
23 </ChartAreas>
24 </asp:Chart>
后台:
View Code
1 Chart1.Titles["Title1"].Text = ddlCase.SelectedItem.Text;//整个图表的标题
2 Chart1.Series["Software"].ChartType = SeriesChartType.Spline;
3 Chart1.Series["Software"].Points.DataBind(dtLine.DefaultView, "Show", "TestValue", "");
4
5 //设置Chart的外观
6 Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1.0;
7 Chart1.ChartAreas["ChartArea1"].AxisX.IntervalOffset = 1;
8 Chart1.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit = true;
9 Chart1.ChartAreas["ChartArea1"].AxisX.LineColor = Color.Blue;
10 Chart1.ChartAreas["ChartArea1"].AxisX.TextOrientation = TextOrientation.Rotated270;
11 Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.Wheat;
12 Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.Gray;
13 Chart1.DataBind();