7

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

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
Dmitry Makovetskiyd
  • 6,942
  • 32
  • 100
  • 160

5 Answers5

15

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.

kwoxer
  • 3,734
  • 4
  • 40
  • 70
6

You will need to set the PieLabelStyle something like this

Chart1.Series[0]["PieLabelStyle"] = "Disabled";

Read here

Community
  • 1
  • 1
V4Vendetta
  • 37,194
  • 9
  • 78
  • 82
0

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 = { "", "", "", "" };
Bolu
  • 8,696
  • 4
  • 38
  • 70
0

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.

Rikalous
  • 4,514
  • 1
  • 40
  • 52
0

Use IsVisibleInLegend

Chart1.Series[0].IsVisibleInLegend = false;

  • 1
    Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. **Would you kindly [edit] your answer to include additional details for the benefit of the community?** – Jeremy Caney Jul 31 '23 at 00:34