Search code examples
c#mschartlinechart

How to hide label of data points in line chart


Please refer to the picture below.

Basically I have a C# chart control with some series on it, I have one series with label (the red line in the picture) but I want to be able to toggle the label on/off. Is that possible? I can't find any properties that can do so.

Thanks a lot.

Chart


Solution

  • Short of clearing the text of the labels one simple method is to make the color transparent.

    You can do it for the whole Series s1:

    s1.LabelForeColor = checkBox_test.Checked ? Color.Black: Color.Transparent;
    

    ..or for individual DataPoints dp:

    dp.LabelForeColor = checkBox_test.Checked ? Color.Blue : Color.Transparent;