我在ASP.Net中使用MS饼图控件。这是ASPX中我的图表控件的标记 -
<asp:Chart runat="server" ID="chartX" CssClass="chart" Width="420px" Height="500px" ImageType="Jpeg">
<Series></Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Docking="Bottom" Alignment="Center" Font="Calibri"></asp:Legend>
</Legends>
</asp:Chart>
以下是在ASPX.vb中填充图表控件的代码 -
Dim table As DataTable = PopulateData()
Dim dv As DataView = New DataView(table, "Count > 0", "", DataViewRowState.OriginalRows)
Dim series As String = r("Name").ToString()
chartX.Series.Add(series)
chartX.Series(series).ChartType = DataVisualization.Charting.SeriesChartType.Pie
chartX.Series(series).XValueMember = "Name"
chartX.Series(series).YValueMembers = "Count"
chartX.ChartAreas(0).Area3DStyle.Enable3D = True
chartX.Series(series).Label = "#VALX" & Environment.NewLine & "(#PERCENT)"
chartX.Series(series)("PieLabelStyle") = "Disabled"
chartX.DataSource = dv
chartX.DataBind()
上面的代码工作正常。我有一个特定的情况,我想显示一个额外的图例项目作为饼图上所有项目的总和。
任何帮助都会很棒。提前谢谢。