2010-01-27 56 views
17

ugly pie chart隱藏標籤(MS圖表.NET)

我似乎無法找到控制在餅圖標籤的可視性財產。由於圖例中的信息可用,因此我需要關閉標籤。

任何人都知道我可以在代碼後面使用哪些屬性?

我嘗試將系列標籤設置爲無Chart1.Series[i].Label = string.Empty;,但標籤似乎無論如何顯示。

回答

36
Chart1.Series[i]["PieLabelStyle"] = "Disabled"; 

工作過,並不需要爲每個數據點進行設置。

+0

很酷,謝謝Ben! – grenade

+0

設置它爲整個系列而不是單個數據點不適合我.. –

+0

難怪我猜不到這!謝謝。 –

0
objChart.ChartAreas[0].AxisY.LabelStyle.Enabled = false; 
+0

你用餅圖測試過了嗎?它適用於大多數圖表類型,但在二月份它不會影響餅圖。這有改變嗎? – grenade

6

更改圖表自定義屬性會做的伎倆,以及沒有編碼需要

<asp:Series Name="Series1" ChartType="Pie" CustomProperties="PieLabelStyle=Disabled"> 
1

可能是這個網站解決您的問題

保護無效的Page_Load(對象發件人,EventArgs的) {
//插入代碼以創建基本餅圖 //請參閱我的博客帖子,標題爲「ASP.NET中的餅圖」完整源代碼

 // Set pie labels to be outside the pie chart 
    this.Chart2.Series[0]["PieLabelStyle"] = "Outside"; 

    // Set border width so that labels are shown on the outside 
    this.Chart2.Series[0].BorderWidth = 1; 
    this.Chart2.Series[0].BorderColor = System.Drawing.Color.FromArgb(26, 59, 105); 

    // Add a legend to the chart and dock it to the bottom-center 
    this.Chart2.Legends.Add("Legend1"); 
    this.Chart2.Legends[0].Enabled = true; 
    this.Chart2.Legends[0].Docking = Docking.Bottom; 
    this.Chart2.Legends[0].Alignment = System.Drawing.StringAlignment.Center; 

    // Set the legend to display pie chart values as percentages 
    // Again, the P2 indicates a precision of 2 decimals 
    this.Chart2.Series[0].LegendText = "#PERCENT{P2}"; 

    // By sorting the data points, they show up in proper ascending order in the legend 
    this.Chart2.DataManipulator.Sort(PointSortOrder.Descending, Chart2.Series[0]); 
} 

還可以訪問這個網站我也藉此代碼從該網站上mscharts http://betterdashboards.wordpress.com/2009/02/04/display-percentages-on-a-pie-char

1

非常好的教程... ...和本公司在VB.NET格式回答:

Chart1.Series(0)("PieLabelStyle") = "Disabled" 

正常工作對整個設置系列