2016-03-09 82 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”; –