前台:
<dcwc:Chart ID="chart1" runat="server" Width="500" Height="360px" ImageType="png">
<Series>
<dcwc:Series Color="red" Name="one">
</dcwc:Series>
<dcwc:Series Color="green" Name="two">
</dcwc:Series>
</Series>
<Titles>
<dcwc:Title Font="Trebuchet MS, 10.25pt, style=Bold" Text="测试图表" Alignment="TopCenter">
</dcwc:Title>
</Titles>
<Legend Enabled="true"></Legend>
<ChartAreas>
<dcwc:ChartArea BackGradientType="leftright" Name="one" BackGradientEndColor="navajowhite"
ShadowColor="darkgray" ShadowOffset="3" BackColor="FloralWhite" >
<area3dstyle yangle="10" perspective="1" enable3d="True" xangle="20" rightangleaxes="False" wallwidth="0" clustered="false"></area3dstyle>
<axisy linecolor="64, 64, 64, 64" LabelsAutoFit="True">
<labelstyle font="Trebuchet MS, 8.25pt, style=Bold"></labelstyle>
<majorgrid linecolor="64, 64, 64, 64"></majorgrid>
</axisy>
<axisx linecolor="64, 64, 64, 64" LabelsAutoFit="True">
<labelstyle font="Trebuchet MS, 8.25pt, style=Bold"></labelstyle>
<majorgrid linecolor="64, 64, 64, 64"></majorgrid>
</axisx>
</dcwc:ChartArea>
</ChartAreas>
</dcwc:Chart>
后台:
DataTable dt = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString, CommandType.Text, "select a.uid,count(b.id) as nums from users a left join videos b on a.uid=b.uid group by a.uid").Tables[0];
DataTable dt2 = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString, CommandType.Text, "select a.uid,b.ds from users a left join (SELECT Uid, isnull(COUNT(Id),0) AS ds FROM downs GROUP BY Uid) b on a.uid=b.uid where b.ds<>0").Tables[0];
chart1.Series[0].Type = Dundas.Charting.WebControl.SeriesChartType.Column;
chart1.Series[0].XValueType = Dundas.Charting.WebControl.ChartValueTypes.Int;
chart1.Series[0].Points.DataBindXY(dt.DefaultView, "uid", dt.DefaultView, "nums");
chart1.Series[0].Name = "上传数"; chart1.Series[0].ChartArea = "one";
chart1.Series[0].ShowLabelAsValue = true;
chart1.Series[1].Type = Dundas.Charting.WebControl.SeriesChartType.Column;
chart1.Series[1].XValueType = Dundas.Charting.WebControl.ChartValueTypes.Int;
chart1.Series[1].Points.DataBindXY(dt2.DefaultView, "uid", dt2.DefaultView, "ds");
chart1.Series[1].Name = "下载数"; chart1.Series[1].ChartArea = "one";
chart1.Series[1].ShowLabelAsValue = true; //chart1.Series[1].ToolTip = chart1.Series[1].Name;
chart1.ChartAreas["one"].AxisX.Title = "用户ID";
chart1.ChartAreas["one"].AxisX.LabelsAutoFit = false;//auto样式关
chart1.ChartAreas["one"].AxisX.LabelStyle.OffsetLabels = false;//一行显示横轴坐标,非上下交错
chart1.ChartAreas["one"].AxisX.Interval = 1.0; chart1.ChartAreas["one"].AxisY.Interval = 1.0;
<dcwc:Chart ID="chart1" runat="server" Width="500" Height="360px" ImageType="png">
<Series>
<dcwc:Series Color="red" Name="one">
</dcwc:Series>
<dcwc:Series Color="green" Name="two">
</dcwc:Series>
</Series>
<Titles>
<dcwc:Title Font="Trebuchet MS, 10.25pt, style=Bold" Text="测试图表" Alignment="TopCenter">
</dcwc:Title>
</Titles>
<Legend Enabled="true"></Legend>
<ChartAreas>
<dcwc:ChartArea BackGradientType="leftright" Name="one" BackGradientEndColor="navajowhite"
ShadowColor="darkgray" ShadowOffset="3" BackColor="FloralWhite" >
<area3dstyle yangle="10" perspective="1" enable3d="True" xangle="20" rightangleaxes="False" wallwidth="0" clustered="false"></area3dstyle>
<axisy linecolor="64, 64, 64, 64" LabelsAutoFit="True">
<labelstyle font="Trebuchet MS, 8.25pt, style=Bold"></labelstyle>
<majorgrid linecolor="64, 64, 64, 64"></majorgrid>
</axisy>
<axisx linecolor="64, 64, 64, 64" LabelsAutoFit="True">
<labelstyle font="Trebuchet MS, 8.25pt, style=Bold"></labelstyle>
<majorgrid linecolor="64, 64, 64, 64"></majorgrid>
</axisx>
</dcwc:ChartArea>
</ChartAreas>
</dcwc:Chart>
后台:
DataTable dt2 = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString, CommandType.Text, "select a.uid,b.ds from users a left join (SELECT Uid, isnull(COUNT(Id),0) AS ds FROM downs GROUP BY Uid) b on a.uid=b.uid where b.ds<>0").Tables[0];
chart1.Series[0].Type = Dundas.Charting.WebControl.SeriesChartType.Column;
chart1.Series[0].XValueType = Dundas.Charting.WebControl.ChartValueTypes.Int;
chart1.Series[0].Points.DataBindXY(dt.DefaultView, "uid", dt.DefaultView, "nums");
chart1.Series[0].Name = "上传数"; chart1.Series[0].ChartArea = "one";
chart1.Series[0].ShowLabelAsValue = true;
chart1.Series[1].Type = Dundas.Charting.WebControl.SeriesChartType.Column;
chart1.Series[1].XValueType = Dundas.Charting.WebControl.ChartValueTypes.Int;
chart1.Series[1].Points.DataBindXY(dt2.DefaultView, "uid", dt2.DefaultView, "ds");
chart1.Series[1].Name = "下载数"; chart1.Series[1].ChartArea = "one";
chart1.Series[1].ShowLabelAsValue = true; //chart1.Series[1].ToolTip = chart1.Series[1].Name;
chart1.ChartAreas["one"].AxisX.Title = "用户ID";
chart1.ChartAreas["one"].AxisX.LabelsAutoFit = false;//auto样式关
chart1.ChartAreas["one"].AxisX.LabelStyle.OffsetLabels = false;//一行显示横轴坐标,非上下交错
chart1.ChartAreas["one"].AxisX.Interval = 1.0; chart1.ChartAreas["one"].AxisY.Interval = 1.0;
浙公网安备 33010602011771号