在现有的应用程序中(Web表单,但底层的Microsoft Charting堆栈对于winforms / webforms / razor图表基本相同)我有Pie Charts,每个切片都有以下业务数据:
答案 0 :(得分:1)
创建两个系列和两个图表区域并叠加它们:
<强> ASPX:强>
<asp:Chart ID="Chart1" runat="server">
<series>
<asp:Series ChartType="Pie"
Name="Series1"
CustomProperties="PieLabelStyle=Inside, PieStartAngle=270"
BorderColor="White"
ChartArea="ChartArea1">
</asp:Series>
<asp:Series ChartType="Pie"
Name="Series2"
CustomProperties="PieLabelStyle=Outside, PieStartAngle=270"
ChartArea="ChartArea2">
</asp:Series>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1" >
<InnerPlotPosition Height="95" Width="45.98404" X="27.00798" Y="2.50000072" />
</asp:ChartArea>
<asp:ChartArea Name="ChartArea2"
AlignWithChartArea="ChartArea1"
AlignmentOrientation="All"
BackColor="Transparent">
<InnerPlotPosition Height="95" Width="45.98404" X="27.00798" Y="2.50000072" />
</asp:ChartArea>
</chartareas>
</asp:Chart>
<强> CS:强>
protected void Page_Load(object sender, EventArgs e)
{
List<MyDataModel> data = new List<MyDataModel> {
new MyDataModel { Color = Color.LightBlue, Label = "Value 1", Value = 100 },
new MyDataModel { Color = Color.LightBlue, Label = "Value 2", Value = 100 },
new MyDataModel { Color = Color.LightBlue, Label = "Value 3", Value = 100 },
new MyDataModel { Color = Color.Blue, Label = "Value 4", Value = 100 },
new MyDataModel { Color = Color.Blue, Label = "Value 5", Value = 400 },
};
foreach (MyDataModel dm in data)
{
Chart1.Series[0].Points.Add(new DataPoint
{
Color = dm.Color,
Label = dm.Value.ToString(),
YValues = new double[] { dm.Value }
});
Chart1.Series[1].Points.Add(new DataPoint
{
Color = Color.Transparent,
Label = dm.Label,
YValues = new double[] { dm.Value }
});
}
}