[英]How to format labels in a pie-chart in C# chart control
我遇到了一個問題,如果最大列之間的差異遠大於其他列,那么餅圖的標簽將相互重疊。 看起來很丑。
我的餅圖控件:
<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";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.