2016-03-09 123 views
0

我正在生成圓環圖,但某些情況下線標籤百分比已關閉,並且在某些情況下百分號已關閉。C#中的標籤餅圖/ Dougnhut圖表#

Donut Charts

如何解決這個問題?

- 代碼

 chart.Series["Data"].ChartType = SeriesChartType.Doughnut; 
     chart.Series["Data"]["PieLineColor"] = "LightGray"; 
     chart.Series["Data"]["DoughnutRadius"] = "30"; 
     chart.Series["Data"]["PieStartAngle"] = "270"; 
     chart.ChartAreas[0].InnerPlotPosition.Height = 90; 
     chart.ChartAreas[0].InnerPlotPosition.Width = 90; 
     chart.ChartAreas[0].Area3DStyle.Enable3D = true; 
     chart.ChartAreas[0].Area3DStyle.Inclination = 0; 
     chart.Series["Data"].Label = "#PERCENT{P0}"; 
     chart.Series["Data"].LegendText = "#VALX"; 
     chart.Series["Data"].Font = new Font("Arial", 16.0f, FontStyle.Bold); 
+0

托馬斯試圖說的是,請向我們展示創建圖表的代碼,以便我們確實有機會幫助您解決問題。你可以閱讀關於[mcve]的內容,以更好地瞭解什麼可以幫助他人幫助你。問題 – DrewJordan

+0

添加代碼 – Daniel

回答

0
Html code: 
    <asp:Chart ID="Chart1" runat="server" Height="300px" Width="400px" > 
      <Titles> 
       <asp:Title ShadowOffset="3" Name="Items" /> 
      </Titles> 
      <Legends> 
       <asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="Default" 
        LegendStyle="Row" /> 
      </Legends> 
      <Series> 
       <asp:Series Name="Data" Color="Chocolate" BackGradientStyle="HorizontalCenter" /> 
      </Series> 
      <ChartAreas > 
       <asp:ChartArea Name="ChartArea1" BorderWidth="0" BackColor="White" /> 
      </ChartAreas> 
     </asp:Chart> 

    Code behind: 
    chart.Series["Data"].ChartType = SeriesChartType.Doughnut; 
    chart.Series["Data"]["PieLabelStyle"] = "outside"; 
    chart.Series["Data"]["PieLineColor"] = "LightGray"; 
    chart.Series["Data"]["DoughnutRadius"] = "30"; 
    chart.Series["Data"]["PieStartAngle"] = "270"; 
    chart.ChartAreas[0].InnerPlotPosition.Height = 90; 
    chart.ChartAreas[0].InnerPlotPosition.Width = 90; 
    chart.ChartAreas[0].Area3DStyle.Enable3D = true; 
    chart.ChartAreas[0].Area3DStyle.Inclination = 0; 
    chart.Series["Data"].Font = new Font("Arial", 16.0f, FontStyle.Bold); 
    foreach (DataPoint p in chart.Series["Data"].Points) 
        { 
         p.Label = "#PERCENT"; 
         p.LabelToolTip = "#VALX"; 
         p.LabelForeColor = Color.Brown; 
         p.LegendText = "#VALX"; 
         p.LegendToolTip = "#PERCENT"; 
         p.LabelToolTip = "#PERCENT\n#VALX"; 

        } 

只有下面添加到您當前的.cs代碼 這將增加標籤和tooltiop既您的餡餅/ Dougnhut圖表foreach循環。 請讓我知道你是否會在這樣做時遇到任何問題。

+0

你可以使用「#VALX」爲x軸值標籤 OR 您可以使用「#VALY」爲y軸的值作爲標籤 –

+0

感謝您的幫助,我現在的問題是標籤行是在區域外,我希望她整個可見 – Daniel

+0

Chart1.Series [0] .ChartType = SeriesChartType.Pie; Chart1.Series [0] [「PieLabelStyle」] =「外部」; Chart1.Series [0] [「PieStartAngle」] =「90」; –