2012-05-08 170 views
4

我在我的一个VB.NET项目中使用了MSChart Control。我已决定将数据显示在饼图中,如下表所示。MSChart:饼图标签重叠问题

enter image description here

但标签上正在相互重叠的摆脱它,如下图所示我曾尝试“智能标签”属性。

Chart1.Series("Default").SmartLabelStyle.Enabled = True 
Chart1.Series("Default").SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.No 

Chart1.Series("Default").SmartLabelStyle.CalloutLineAnchorCapStyle = LineAnchorCapStyle.None 

Chart1.Series("Default").SmartLabelStyle.CalloutLineColor = Color.Red 

Chart1.Series("Default").SmartLabelStyle.CalloutLineWidth = 1 
Chart1.Series("Default").SmartLabelStyle.CalloutStyle = LabelCalloutStyle.None 

并不能帮助我 ...虽然它让我看到输出按下面的屏幕截图。 enter image description here

哪些是我必须用来摆脱它的属性? ......

编辑:

如果我不设置自定义属性PieLabelStyle=Outside它没有任何区别,你可以看到在屏幕下面shote。

enter image description here

请帮助我..

+0

http://stackoverflow.com/questions/2147930/hide-labels-in-pie-charts-ms-chart-for-net/19782813#19782813 – Raheel

回答

13

更改PieLabelStyle CustomSettings到外部。这应该将所有标签放在图表的周围,并用指向相关部分的线条。

为VB

Chart1.Series(0)("PieLabelStyle") = "Outside" 
Chart1.ChartAreas(0).Area3DStyle.Enable3D = true 
Chart1.ChartAreas(0).Area3DStyle.Inclination = 10 

为C#

Chart1.Series[0]["PieLabelStyle"] = "Outside"; 
Chart1.ChartAreas[0].Area3DStyle.Enable3D = true; 
Chart1.ChartAreas[0].Area3DStyle.Inclination = 10; 
+0

我已经设置该属性,因为你告诉我... 。但是,正如你可以从我更新的问题看到它没有任何区别。非常感谢您回复... – Pritesh

+0

尝试将代码更改为我更新的答案。如果你仍然希望图表看起来2D,那么XAngle属性很可能会更改为0,但我没有测试过的opprtunity。 – APrough

+0

这对我有用,除了我看不到XAngle属性 – nuander

0

我都尝试使用Visual Studio设计以及设置在上面的代码指令。它没有工作。

在visual Studio designer中,转到Series1-> CustomProperties。您可以展开 CustomProperties并根据图表类型设置各个属性。 但是在CustomProperties的第一行中,在各个字段中设置了CustomProperties的文本表示。 由于我的图表是从其他ChartType转换而来的,它在第一行包含自定义属性,但这些属性不适用于Pie。这是无法尊重CustomProperties设置的原因。 我删除CustomProperties来手动第一线...

PieLabelStyle =外

开始工作了!所有标签都变得可读。我将其视为Chart设计师的一个缺陷。在改变ChartType时,它应该自动清理旧的CustomProperties。