我似乎无法找到控制在饼图标签的可视性财产。由于图例中的信息可用,因此我需要关闭标签。
任何人都知道我可以在代码后面使用哪些属性?
我尝试将系列标签设置为无Chart1.Series[i].Label = string.Empty;
,但标签似乎无论如何显示。
我似乎无法找到控制在饼图标签的可视性财产。由于图例中的信息可用,因此我需要关闭标签。
任何人都知道我可以在代码后面使用哪些属性?
我尝试将系列标签设置为无Chart1.Series[i].Label = string.Empty;
,但标签似乎无论如何显示。
Chart1.Series[i]["PieLabelStyle"] = "Disabled";
工作过,并不需要为每个数据点进行设置。
原来有一个叫PieLabelStyle晦涩DataPointCustomProperty管辖饼图标签的知名度。更糟糕的是,必须在每个数据点上设置属性。
for (var i = 0; i < chart.Series.Count; i++)
for (var j = 0; j < chart.Series[i].Points.Count; j++)
chart.Series[i].Points[j]["PieLabelStyle"] = "Disabled";
objChart.ChartAreas[0].AxisY.LabelStyle.Enabled = false;
你用饼图测试过了吗?它适用于大多数图表类型,但在二月份它不会影响饼图。这有改变吗? – grenade
更改图表自定义属性会做的伎俩,以及没有编码需要
<asp:Series Name="Series1" ChartType="Pie" CustomProperties="PieLabelStyle=Disabled">
可能是这个网站解决您的问题
保护无效的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
非常好的教程... ...和本公司在VB.NET格式回答:
Chart1.Series(0)("PieLabelStyle") = "Disabled"
正常工作对整个设置系列
很酷,谢谢Ben! – grenade
设置它为整个系列而不是单个数据点不适合我.. –
难怪我猜不到这!谢谢。 –