Nevron Forum

Hiding series from the legend

https://www.nevron.com/Forum/Topic8174.aspx

By Rick Shaban - Monday, September 23, 2013

I have multiple series in the chart though only need to display a few of them in the legend.

I tried:

RangeM.Legend.DisplayOnLegend.VisibilityMode = VisibilityMode.Hidden

and

RangeM.Legend.DisplayOnLegend.Visible = False

But then get the error "NullReferenceException was unhandled by user code" on this line. "Object reference not set to an instance of an object."

How can this be corrected?


Below is my legend setup:
Dim legend As NLegend = chartControl.Legends(0)
legend.Data.ExpandMode = LegendExpandMode.RowsFixed
legend.Data.RowCount = 1
legend.Dock = Windows.Forms.DockStyle.Top
legend.DockMargins = New NMarginsL(10, 10, 10, 5)
legend.VerticalBorderStyle.Color = NColor.ColorFromString("255,235,241,249")
legend.Margins = New NMarginsL(40, 10, 40, 10)
legend.BoundsMode = BoundsMode.Fit
legend.Data.CellMargins = New NMarginsL(10, 0, 10, 0)
legend.OuterBottomBorderStyle.Color = NColor.ColorFromString("255,235,241,249")
legend.OuterTopBorderStyle.Color = NColor.ColorFromString("255,235,241,249")
legend.OuterLeftBorderStyle.Color = NColor.ColorFromString("255,235,241,249")
legend.OuterRightBorderStyle.Color = NColor.ColorFromString("255,235,241,249")
legend.BoundsMode = BoundsMode.Fit
legend.FillStyle = New NColorFillStyle(NColor.ColorFromString("255,235,241,249"))

Best regards,

Rick
By Nevron Support - Tuesday, September 24, 2013

Hi Rick,

You need to use:

someSeries.Legend.Mode = SeriesLegendMode.None;

In order to hide the series from the legend.