Chart Control. How to remove legend labels
I got a simple code from this site:
http://www.davidhayden.com/blog/dave/archive/2008/12/02/PieChartASPNETWebsitesUsingNewMicrosoftChartControls.aspx
Now, I want to remove all the labels in the pie chart i.e. "a", "b","c","d".开发者_开发百科
I tried to do this:
Chart1.Series[0].IsValueShownAsLabel = false;
But it doesnt work..please help. I am Stuck
In VB.Net that works fine:
Chart1.Series(0).IsVisibleInLegend = False
I know you don't search for VB.Net. But maybe that helps VB.net users.
You will need to set the PieLabelStyle
something like this
Chart1.Series[0]["PieLabelStyle"] = "Disabled";
Read here
IsValueShownAsLabel determines whether the numerical value (y val) is used for the label rather than the x value. As a guess you probably need to manually set the Label property of each data point to an empty string.
Remove following code:
Chart1.Legends.Add(new Legend("Alphabet"));
Chart1.Legends["Alphabet"].Title = "Letters";
Chart1.Series[0].Legend = "Alphabet";
Update: and change
string[] xValues = { "A", "B", "C", "D" };
to
string[] xValues = { "", "", "", "" };
精彩评论