Selectively hide rows in a C # chart

Suppose I have a chart with two series. Then for each series I have a checkbox to say whether I want to see them or not. Suppose I initially draw both, and then I wanted to hide either of them. What is the best way to do this?

I know I could just Clear() and then AddXY() them back, but is there a faster way to do this?

My thoughts:


1. Set the visibility property to true / false depending on the check box.
No visibility

2. Copy points to a variable, clear and return back.
Series[].Points is read-only.

3. Copy the series into a variable, clear the points and return them.
Apparently, it stores the Series as a reference when I try to do this, and I cannot find the copy command.

So I'm apparently doing it wrong. How would you dynamically allow a chart to hide different series?

+4
source share
1 answer

To hide a series in MSChart, use the Enabled property as follows:

 msChart.Series["Series"].Enabled = false; 

and show it again:

 msChart.Series["Series"].Enabled = true; 

Therefore, you do not need to delete points and re-add them.

+16
source

All Articles