我遇到了一个问题,如果最大列之间的差异远大于其他列,那么饼图的标签将相互重叠。看起来很丑。
我的饼图控件:
<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。
但是无法使其正常工作。
任何帮助表示赞赏。
我使用以下技术来解决我的问题。虽然没有完全满意。
在我的图表区域中:-
<ChartAreas>
<asp:ChartArea Name="Default" Area3DStyle-Enable3D="true"></asp:ChartArea>
</ChartAreas>
在我后面的代码中:
demographicsChart.Series["State"]["PieLabelStyle"] = "Outside";
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句