Table of Contents

Class Legend

Namespace
ScottPlot
Assembly
ScottPlot.dll
public class Legend : IPlottable, IHasOutline, IHasBackground, IHasShadow
Inheritance
Legend
Implements
Inherited Members
Extension Methods

Constructors

Legend(Plot)

public Legend(Plot plot)

Parameters

plot Plot

Properties

Alignment

Position of the legend relative to the data area

public Alignment Alignment { get; set; }

Property Value

Alignment

AllowMultiline

[Obsolete("Multiline is now enabled by default.", true)]
public bool AllowMultiline { get; set; }

Property Value

bool

Axes

This object performs coordinate/pixel translation at render time based on the latest data area. It stores the axes to use for this plottable and also the data area (in pixels) updated just before each render. If this object is null it will be constructed using the default X and Y axes at render time.

public IAxes Axes { get; set; }

Property Value

IAxes

BackgroundColor

public Color BackgroundColor { get; set; }

Property Value

Color

BackgroundFill

[Obsolete("Assign BackgroundColor or interact with BackgroundFillStyle")]
public FillStyle BackgroundFill { get; set; }

Property Value

FillStyle

BackgroundFillStyle

public FillStyle BackgroundFillStyle { get; }

Property Value

FillStyle

BackgroundHatch

public IHatch? BackgroundHatch { get; set; }

Property Value

IHatch

BackgroundHatchColor

public Color BackgroundHatchColor { get; set; }

Property Value

Color

DisplayPlottableLegendItems

public bool DisplayPlottableLegendItems { get; set; }

Property Value

bool

Font

[Obsolete("Assign FontSize, FontName, or FontColor to control appearance of all legend items", true)]
public FillStyle Font { get; set; }

Property Value

FillStyle

FontColor

If set, this overrides the value in the LegendItem's FontStyle

public Color? FontColor { get; set; }

Property Value

Color?

FontName

If set, this overrides the value in the LegendItem's FontStyle

public string? FontName { get; set; }

Property Value

string

FontSize

If set, this overrides the value in the LegendItem's FontStyle

public float? FontSize { get; set; }

Property Value

float?

HiddenItemOpacity

This property controls how visible legend items are when their parent control's visibility is disabled. This property is only used when ShowItemsFromHiddenPlottables is enabled.

public double HiddenItemOpacity { get; set; }

Property Value

double

InterItemPadding

Space separating legend items

public PixelPadding InterItemPadding { get; set; }

Property Value

PixelPadding

IsVisible

Toggles whether this plottable is shown and contributes to the automatic axis limit detection. The calling method will check this variable (it does not need to be checked inside the Render method).

public bool IsVisible { get; set; }

Property Value

bool

LastRenderSize

public PixelSize LastRenderSize { get; }

Property Value

PixelSize

Layout

public ILegendLayout Layout { get; set; }

Property Value

ILegendLayout

LegendItems

Items which will appear in the legend

public IEnumerable<LegendItem> LegendItems { get; }

Property Value

IEnumerable<LegendItem>

Location

Position of the legend relative to the data area

[Obsolete("use Alignment")]
public Alignment Location { get; set; }

Property Value

Alignment

ManualItems

Items in this list will always be displayed in the legend

public List<LegendItem> ManualItems { get; set; }

Property Value

List<LegendItem>

Margin

Distance from the edge of the data area to the edge of the legend

public PixelPadding Margin { get; set; }

Property Value

PixelPadding

Orientation

Stack items in the legend according to this preferred orientation

public Orientation Orientation { get; set; }

Property Value

Orientation

OutlineColor

public Color OutlineColor { get; set; }

Property Value

Color

OutlinePattern

public LinePattern OutlinePattern { get; set; }

Property Value

LinePattern

OutlineStyle

public LineStyle OutlineStyle { get; set; }

Property Value

LineStyle

OutlineWidth

public float OutlineWidth { get; set; }

Property Value

float

Padding

Distance between the legend frame and the items within it

public PixelPadding Padding { get; set; }

Property Value

PixelPadding

Plot

public Plot Plot { get; }

Property Value

Plot

SetBestFontOnEachRender

Enabling this allows multi-language text in the figure legend, but may slow down the render loop.

public bool SetBestFontOnEachRender { get; set; }

Property Value

bool

ShadowAlignment

public Alignment ShadowAlignment { get; set; }

Property Value

Alignment

ShadowColor

public Color ShadowColor { get; set; }

Property Value

Color

ShadowFill

[Obsolete("Assign ShadowColor or interact with ShadowFillStyle")]
public FillStyle ShadowFill { get; set; }

Property Value

FillStyle

ShadowFillStyle

public FillStyle ShadowFillStyle { get; }

Property Value

FillStyle

ShadowOffset

public PixelOffset ShadowOffset { get; set; }

Property Value

PixelOffset

ShowItemRectangles_DEBUG

public bool ShowItemRectangles_DEBUG { get; set; }

Property Value

bool

ShowItemsFromHiddenPlottables

If enabled, the legend will include items from hidden plottables. They will be partially painted over using the background color to simulate semitransparency.

public bool ShowItemsFromHiddenPlottables { get; set; }

Property Value

bool

SymbolPadding

Padding between a symbol and label within a legend item

public float SymbolPadding { get; set; }

Property Value

float

SymbolWidth

Width of the symbol in a legend item

public float SymbolWidth { get; set; }

Property Value

float

TightHorizontalWrapping

If enabled, items in horizontal oriented legends will not be aligned in columns but instead resized tightly to fit their contents

public bool TightHorizontalWrapping { get; set; }

Property Value

bool

Methods

GetAxisLimits()

Return the 2D area (in coordinate space) occupied by the data contained in this plottable

public AxisLimits GetAxisLimits()

Returns

AxisLimits

GetImage()

Return an Image containing just the legend

public Image GetImage()

Returns

Image

GetItems()

public virtual LegendItem[] GetItems()

Returns

LegendItem[]

GetLayout(PixelSize)

public LegendLayout GetLayout(PixelSize size)

Parameters

size PixelSize

Returns

LegendLayout

GetSvgXml()

Return contents of a SVG image containing just the legend

public string GetSvgXml()

Returns

string

Render(RenderPack)

This is called automatically by the render manager

public virtual void Render(RenderPack rp)

Parameters

rp RenderPack

Render(SKCanvas, PixelRect, Alignment)

public void Render(SKCanvas canvs, PixelRect rect, Alignment alignment)

Parameters

canvs SKCanvas
rect PixelRect
alignment Alignment