2015-10-12 31 views
0

我遇到了一個問題,如果最大列之間的差異比其他列大得多,那麼餅圖的標籤將全部覆蓋其他。看起來很醜。如何格式化C#圖表控件中的餅圖中的標籤

我的餅圖控制: -

<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。

但無法讓它工作。

任何幫助表示讚賞。

回答

0

我用下面的技術來解決我的問題。雖然不完全滿意。

在我的圖表面積: -

<ChartAreas> 
      <asp:ChartArea Name="Default" Area3DStyle-Enable3D="true"></asp:ChartArea> 
</ChartAreas> 

在背後說我的代碼: -

demographicsChart.Series["State"]["PieLabelStyle"] = "Outside";