Nevron Open Vision Documentation
Legend Appearance

The NLegend object derives from the NWidget base class and as such has all properties that common for widgets - background fill, margins, padding, border etc. The legend builds on top of that to provide support for gridlines and interlace styles.

Setting the Legend Background Fill

You set the legend background fill through the BackgroundFill property - the following code snippet modifes the legend background fill to semitransparent white:

Copy Code

legend.BackgroundFill = new NColorFill(NColor.FromColor(NColor.White, 0.5f));

Legend Grid Lines

The legend grid lines visually separates the data items horizontally and vertically. You control the appearance of horizontal and vertical grid lines trough the HorizontalGridStroke and VerticalGridStroke properties. The following code shows how to change the horizontal grid lines to thick solid black:

Copy Code

legend.HorizontalGridStroke = new NStroke(2, NColor.Black);

Legend Interlace Styles

The legend interlace stripes are automatically generated based on the interlace styles added to the InterlaceStyles collection of the legend. Each interlace style is represented by a NLegendInterlaceStyle object controlling the interlace stripes appearance and orientation (row / column). Furthermore the interlace stripes have Z order - stripes generated by interlace styles on top of the collection appear below interlace stripes generated by the styles afterwards. The following code creates a row and column interlace style:

Copy Code

NLegendInterlaceStylesCollection interlaceStyles = new NLegendInterlaceStylesCollection();

NLegendInterlaceStyle horzInterlaceStyle = new NLegendInterlaceStyle();
horzInterlaceStyle.Fill =
new NColorFill(NColor.FromColor(NColor.LightBlue, 0.5f));
horzInterlaceStyle.Type =
horzInterlaceStyle.Length = 1;
horzInterlaceStyle.Interval = 1;

NLegendInterlaceStyle vertInterlaceStyle = new NLegendInterlaceStyle();
vertInterlaceStyle.Fill =
new NColorFill(NColor.FromColor(NColor.DarkGray, 0.5f));
vertInterlaceStyle.Type =
vertInterlaceStyle.Length = 1;
vertInterlaceStyle.Interval = 1;

legend.InterlaceStyles = interlaceStyles;


See Also
Send Feedback