5

I have used MSChart Control in my one VB.NET project. I have decided to display data as shown in below table in to Pie chart.

enter image description here

But labels are being overlapped on each other for getting rid of it I have tried “Smart Label” properties as shown below.

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

But it doesn’t help me…though it shows me output as per below screen shot. enter image description here

Which are the properties i have to use for getting rid of it?......

EDIT:

If i do set Custom Property PieLabelStyle=Outside it doesn't make any difference as you can see in below screen shote.

enter image description here

Please help me..

Pritesh
  • 3,208
  • 9
  • 51
  • 70
  • http://stackoverflow.com/questions/2147930/hide-labels-in-pie-charts-ms-chart-for-net/19782813#19782813 – Raheel Nov 05 '13 at 06:20

2 Answers2

16

Change the PieLabelStyle CustomSettings to Outside. This should put all the labels around the chart, with lines pointing to the relevant sections.

for VB

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

for C#

Chart1.Series[0]["PieLabelStyle"] = "Outside";
Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
Chart1.ChartAreas[0].Area3DStyle.Inclination = 10;
APrough
  • 2,671
  • 3
  • 23
  • 31
  • i have set that property as you have told me....but as u can see from my Updated question it doesn't make any difference. Thank you so much for replying... – Pritesh May 09 '12 at 07:56
  • Try changing the code to my updated answer. The XAngle attribute can most likely be changed to 0 if you still want the chart to look 2D, but I have not had the opprtunity to test. – APrough May 09 '12 at 14:16
  • This worked for me except that I see no XAngle property – nuander Jul 21 '14 at 22:22
  • I am not sure where the XAngle attribute came from honestly. It looks like the attribute you may be looking for is Inclination instead of XAngle? EDIT: It looks like the XAngle attribute pertains to the Dundas chart control, which is an older version of the new control. I was getting them confused. Sorry for the confusion. – APrough Jul 22 '14 at 12:17
  • Just a note you can use the InnerPlotPosition property to help size the chart, so lines connecting to labels don't get cut-off. Chart1.ChartAreas[0].InnerPlotPosition.Auto = true; – ScottLenart Feb 04 '15 at 21:38
  • I just got it working - For those not interested of 3D you can set the X rotate and Y Rotate [X angle and Y angle I guess] to 0. – marifrahman Nov 24 '15 at 01:29
0

I tried both using Visual Studio designer as well as setting above instructions in the code. It didn't work.

In visual Studio designer go to Series1->CustomProperties. You can expand CustomProperties and set individual properties dependent on the chart type. But in the first line of CustomProperties there is a text representation of CustomProperties set in individual fields. Since my chart was converted from other ChartType it contained custom properties in this first line, but these properties were not applicable to Pie. And this was the reason for failing to respect CustomProperties settings. I deleted manually first line of CustomProperties and ...

PieLabelStyle=Outside

started to work! All labels became readable. I treat this as a bug of Chart designer. Upon changing ChartType it should automatically clean up old CustomProperties.

Alt-WN
  • 81
  • 6