【发布时间】:2012-02-22 12:36:35
【问题描述】:
我正在开发 asp.net Web 应用程序,我需要在其中以饼图的形式显示数据。图表应同时显示 X 值和 Y 值。在下图中,您可以看到我只能在一年内显示 cmets 的总数,但我还想在每种颜色旁边显示年份。我尝试了不同的东西,但到目前为止我没有成功。
我也是图相关的post code
<asp:Chart ID="crtYearWise" runat="server" Height="260px" Width="460px">
<Titles>
<asp:Title Name="Title1" Text="Year Wise"
Alignment="TopCenter" Font="Verdana, 12pt">
</asp:Title>
</Titles>
<Series>
<asp:Series Name="Series1" CustomProperties="DrawingStyle=Pie,
PieDrawingStyle=Concave, MaxPixelPointWidth=20" ShadowOffset="1"
ChartType="Pie" IsValueShownAsLabel="True" >
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="True" AlignmentOrientation="All">
<Area3DStyle Enable3D="true" />
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
代码背后
String strSql2 = "SELECT Count(comPostDate) AS 'comTOTAL', DATEPART(yyyy, comPostDate) AS 'whichYear' ";
strSql2 += " FROM Comments Group by DATEPART(yyyy, comPostDate), DATEPART(yyyy, comPostDate) ";
DataSet ds2 = DataProvider.Connect_Select(strSql2);
DataTable dt2 = ds2.Tables[0];
crtYearWise.DataSource = dt2;
crtYearWise.Series["Series1"].XValueMember = "whichYear";
crtYearWise.Series["Series1"].YValueMembers = "comTOTAL";
//crtYearWise.Series["Series1"]["PieLabelStyle"] = "Outside";
crtYearWise.DataBind();
如果有人可以指导我,我将不胜感激。
答案:Finally Managed 得到了它
crtYearWise.Series["Series1"].Label = "年份 : #VALX , #VALY";
【问题讨论】: