【发布时间】:2016-01-10 04:23:56
【问题描述】:
我遇到了一个问题,如果最大列之间的差异远大于其他列,那么饼图的标签就会相互重叠。看起来很丑。
我的饼图控件:-
<div id="demographicsCharting" class="demographicsCharting" runat="server">
<p style="margin:10px 0 0 10px;">
<b>Demographics of Employees:</b>
</p>
<asp:Chart ID="demographicsChart" runat="server" Palette="SeaGreen" Width="382px" ImageType="Jpeg" >
<Legends>
<asp:Legend Name="StateCategories" IsTextAutoFit="true"></asp:Legend>
</Legends>
<Series>
<asp:Series Name="State" YValueType="Int32" ChartType="Pie" IsVisibleInLegend="true" >
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="Default"></asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
在服务器端:-
// Get dictionary: key-value pair for number of employees per state //
var stateArray = CreateStateDictionary(Employees);
demographicsCharting.Attributes.Add("style", "display:block");
// map all the key-value pairs to the charting asp control //
demographicsChart.Series["State"].Points.DataBindXY(stateArray.Keys, stateArray.Values);
要么我需要使我的饼图更大,以便能够为图表上的每个标签提供足够的空间。或者我需要能够将标签移出饼图并将它们放在圆周上。
我尝试过这样的事情:-
轴标签样式和格式
您可以使用 Axis 对象的 LabelStyle 属性设置轴标签样式。您在此属性中设置的标签样式属性(例如 LabelStyle.Font)适用于轴的标签。如果坐标轴标签距离太近,可以将 LabelStyle.LabelsAutoFit 或 LabelStyle.Offset 属性设置为 True。
但无法让它工作。
感谢任何帮助。
【问题讨论】: