# TopologyLegend

Represents an optional topology legend.

 Class  

`ChartForgeX.Topology`

**Namespace**

`ChartForgeX.Topology`

**Assembly**

`ChartForgeX`

**Source**

[TopologyLegend.cs:13](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L13)

**Modifiers**

sealed

Represents an optional topology legend.

## Inheritance

- object
- TopologyLegend

## Usage

 Explore 26 API references to this type 

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 16

- Property [TopologyChart.Legend](/api/chartforgex-topology-topologychart/#property-legend)
- Extension method [TopologyLegend.Item](/api/chartforgex-topology-topologylegend/#extension-item-chartforgex-topology-topologylegend-action-chartforgex-topology-topologylegenditem)
- Extension method [TopologyLegend.Items](/api/chartforgex-topology-topologylegend/#extension-items-chartforgex-topology-topologylegend-collections-generic-ienumerable-chartforgex-topology-topologylegenditem)
- Extension method [TopologyLegend.Title](/api/chartforgex-topology-topologylegend/#extension-title-chartforgex-topology-topologylegend-string)
- Method [TopologyLegend.AddEdgeColor](/api/chartforgex-topology-topologylegend/#method-addedgecolor-string-chartforgex-primitives-chartcolor)
- Method [TopologyLegend.AddEdgeKind](/api/chartforgex-topology-topologylegend/#method-addedgekind-string-chartforgex-topology-topologyedgekind-nullable-chartforgex-primitives-chartcolor-chartforgex-topology-topologyedgelinestyle)
- Method [TopologyLegend.AddEvidence](/api/chartforgex-topology-topologylegend/#method-addevidence-string-chartforgex-topology-topologyedgeevidence)
- Method [TopologyLegend.AddNodeKind](/api/chartforgex-topology-topologylegend/#method-addnodekind-string-chartforgex-topology-topologynodekind-nullable-chartforgex-primitives-chartcolor-string-nullable-chartforgex-primitives-chartcolor-string)
- Method [TopologyLegend.AddStatus](/api/chartforgex-topology-topologylegend/#method-addstatus-string-chartforgex-topology-topologyhealthstatus-nullable-chartforgex-primitives-chartcolor)
- Method [TopologyLegend.Create](/api/chartforgex-topology-topologylegend/#method-create-string)
- Method [TopologyLegend.Default](/api/chartforgex-topology-topologylegend/#method-default)
- Method [TopologyLegend.Infer](/api/chartforgex-topology-topologylegend/#method-infer-chartforgex-topology-topologychart)
- Method [TopologyLegend.Resolve](/api/chartforgex-topology-topologylegend/#method-resolve-chartforgex-topology-topologychart-chartforgex-topology-topologylegendmode)
- Method [TopologyLegendFluent.Item](/api/chartforgex-topology-topologylegendfluent/#method-item-chartforgex-topology-topologylegend-chartforgex-topology-topologylegenditem)
- Method [TopologyLegendFluent.Items](/api/chartforgex-topology-topologylegendfluent/#method-items-chartforgex-topology-topologylegend-collections-generic-ienumerable-chartforgex-topology-topologylegenditem)
- Method [TopologyLegendFluent.Title](/api/chartforgex-topology-topologylegendfluent/#method-title-chartforgex-topology-topologylegend-string)

### Accepted by parameters 10

- Extension method [TopologyChart.Legend](/api/chartforgex-topology-topologychart/#extension-legend-chartforgex-topology-topologychart-action-chartforgex-topology-topologylegend) parameter `configure`
- Extension method [TopologyChart.Legend](/api/chartforgex-topology-topologychart/#extension-legend-chartforgex-topology-topologychart-chartforgex-topology-topologylegend) parameter `value`
- Method [TopologyChartFluent.Legend](/api/chartforgex-topology-topologychartfluent/#method-legend-chartforgex-topology-topologychart-action-chartforgex-topology-topologylegend) parameter `configure`
- Method [TopologyChartFluent.Legend](/api/chartforgex-topology-topologychartfluent/#method-legend-chartforgex-topology-topologychart-chartforgex-topology-topologylegend) parameter `value`
- Extension method [TopologyLegend.Item](/api/chartforgex-topology-topologylegend/#extension-item-chartforgex-topology-topologylegend-chartforgex-topology-topologylegenditem) parameter `topologyLegend`
- Extension method [TopologyLegend.Items](/api/chartforgex-topology-topologylegend/#extension-items-chartforgex-topology-topologylegend-collections-generic-ienumerable-chartforgex-topology-topologylegenditem) parameter `topologyLegend`
- Extension method [TopologyLegend.Title](/api/chartforgex-topology-topologylegend/#extension-title-chartforgex-topology-topologylegend-string) parameter `topologyLegend`
- Method [TopologyLegendFluent.Item](/api/chartforgex-topology-topologylegendfluent/#method-item-chartforgex-topology-topologylegend-chartforgex-topology-topologylegenditem) parameter `topologyLegend`
- Method [TopologyLegendFluent.Items](/api/chartforgex-topology-topologylegendfluent/#method-items-chartforgex-topology-topologylegend-collections-generic-ienumerable-chartforgex-topology-topologylegenditem) parameter `topologyLegend`
- Method [TopologyLegendFluent.Title](/api/chartforgex-topology-topologylegendfluent/#method-title-chartforgex-topology-topologylegend-string) parameter `topologyLegend`

 Filter members   

    Show inherited   

 

## Constructors

 `public TopologyLegend()` [#](#constructor-ctor) 

[TopologyLegend.cs:13](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L13)

## Methods

 `public TopologyLegend AddEdgeColor(string label, ChartColor color)` [#](#method-addedgecolor-string-chartforgex-primitives-chartcolor) 

[TopologyLegend.cs:63](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L63)

Adds an edge legend item for one colour, such as a stripe on multi-colour edges.

Parameters

**label string required**

The item label.

**color ChartForgeX.Primitives.ChartColor required**

The represented colour.

Returns

 `TopologyLegend` The current legend. 

 `public TopologyLegend AddEdgeKind(string label, TopologyEdgeKind edgeKind, ChartColor? color = null, TopologyEdgeLineStyle lineStyle = Auto)` [#](#method-addedgekind-string-chartforgex-topology-topologyedgekind-nullable-chartforgex-primitives-chartcolor-chartforgex-topology-topologyedgelinestyle) 

[TopologyLegend.cs:159](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L159)

Adds an edge-kind legend item.

Parameters

**label string required**

The item label.

**edgeKind ChartForgeX.Topology.TopologyEdgeKind required**

The represented edge kind.

**color ChartForgeX.Primitives.ChartColor? = null optional**

An optional color override.

**lineStyle ChartForgeX.Topology.TopologyEdgeLineStyle = Auto optional**

An optional edge line style override.

Returns

 `TopologyLegend` The current legend. 

 `public TopologyLegend AddEvidence(string label, TopologyEdgeEvidence evidence)` [#](#method-addevidence-string-chartforgex-topology-topologyedgeevidence) 

[TopologyLegend.cs:74](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L74)

Adds an edge legend item for link evidence. Assumed links are drawn with the same short dash as the edges.

Parameters

**label string required**

The item label.

**evidence ChartForgeX.Topology.TopologyEdgeEvidence required**

The represented evidence.

Returns

 `TopologyLegend` The current legend. 

 `public TopologyLegend AddNodeKind(string label, TopologyNodeKind nodeKind, ChartColor? color = null, string? symbol = null, ChartColor? backgroundColor = null, string? iconId = null)` [#](#method-addnodekind-string-chartforgex-topology-topologynodekind-nullable-chartforgex-primitives-chartcolor-string-nullable-chartforgex-primitives-chartcolor-string) 

[TopologyLegend.cs:146](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L146)

Adds a node-kind legend item.

Parameters

**label string required**

The item label.

**nodeKind ChartForgeX.Topology.TopologyNodeKind required**

The represented node kind.

**color ChartForgeX.Primitives.ChartColor? = null optional**

An optional color override.

**symbol string? = null optional**

An optional short symbol override.

**backgroundColor ChartForgeX.Primitives.ChartColor? = null optional**

An optional node marker background color override.

**iconId string? = null optional**

An optional topology icon id for the legend marker.

Returns

 `TopologyLegend` The current legend. 

 `public TopologyLegend AddStatus(string label, TopologyHealthStatus status, ChartColor? color = null)` [#](#method-addstatus-string-chartforgex-topology-topologyhealthstatus-nullable-chartforgex-primitives-chartcolor) 

[TopologyLegend.cs:131](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L131)

Adds a status legend item.

Parameters

**label string required**

The item label.

**status ChartForgeX.Topology.TopologyHealthStatus required**

The represented status.

**color ChartForgeX.Primitives.ChartColor? = null optional**

An optional color override.

Returns

 `TopologyLegend` The current legend. 

 `public static TopologyLegend Create(string? title = "Topology Legend")` [#](#method-create-string) 

[TopologyLegend.cs:23](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L23)

Creates a new topology legend.

Parameters

**title string? = "Topology Legend" optional**

The optional legend title.

Returns

 `TopologyLegend` A topology legend. 

 `public static TopologyLegend Default()` [#](#method-default) 

[TopologyLegend.cs:30](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L30)

Creates a generic default health legend.

Returns

 `TopologyLegend` A default topology legend. 

 `public static TopologyLegend Infer(TopologyChart chart)` [#](#method-infer-chartforgex-topology-topologychart) 

[TopologyLegend.cs:103](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L103)

Infers a generic legend from statuses, node kinds, node symbols, and edge kinds used by the chart.

Parameters

**chart ChartForgeX.Topology.TopologyChart required**

The topology chart.

Returns

 `TopologyLegend` An inferred topology legend. 

 `public static TopologyLegend? Resolve(TopologyChart chart, TopologyLegendMode mode)` [#](#method-resolve-chartforgex-topology-topologychart-chartforgex-topology-topologylegendmode) 

[TopologyLegend.cs:45](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L45)

Resolves the legend according to the requested legend mode.

Parameters

**chart ChartForgeX.Topology.TopologyChart required**

The topology chart.

**mode ChartForgeX.Topology.TopologyLegendMode required**

The legend mode.

Returns

 `TopologyLegend?` The resolved legend, if any. 

## Inherited Methods

 `public virtual bool Equals(object? obj)` [#](#method-equals-object) 

Inherited from object

Parameters

**obj object? required**

Returns

 `bool` 

 `public virtual int GetHashCode()` [#](#method-gethashcode) 

Inherited from object

Returns

 `int` 

 `public Type GetType()` [#](#method-gettype) 

Inherited from object

Returns

 `Type` 

 `public virtual string? ToString()` [#](#method-tostring) 

Inherited from object

Returns

 `string?` 

## Properties

 `public string? Title { get; set; }` [#](#property-title) 

[TopologyLegend.cs:13](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L13)

Gets or sets the legend title.

 `public List<TopologyLegendItem> Items { get; }` [#](#property-items) 

[TopologyLegend.cs:16](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/Topology/TopologyLegend.cs#L16)

Gets the legend items.

## Extension Methods

 Item 2 overloads 

 `public static TopologyLegend Item(TopologyLegend topologyLegend, TopologyLegendItem item)` [#](#extension-item-chartforgex-topology-topologylegend-chartforgex-topology-topologylegenditem) 

Adds an item to [TopologyLegend.Items](/api/chartforgex-topology-topologylegend/): Gets the legend items.

Parameters

**topologyLegend ChartForgeX.Topology.TopologyLegend required**

The instance.

**item ChartForgeX.Topology.TopologyLegendItem required**

The item.

Returns

 `TopologyLegend` The same instance. 

 `public static TopologyLegend Item(TopologyLegend topologyLegend, Action<TopologyLegendItem> configure)` [#](#extension-item-chartforgex-topology-topologylegend-action-chartforgex-topology-topologylegenditem) 

Creates an item, configures it and adds it to [TopologyLegend.Items](/api/chartforgex-topology-topologylegend/): Gets the legend items.

Parameters

**topologyLegend ChartForgeX.Topology.TopologyLegend required**

The instance.

**configure System.Action<ChartForgeX.Topology.TopologyLegendItem> required**

Configures the new item before it is added.

Returns

 `TopologyLegend` The same instance. 

 `public static TopologyLegend Items(TopologyLegend topologyLegend, IEnumerable<TopologyLegendItem> items)` [#](#extension-items-chartforgex-topology-topologylegend-collections-generic-ienumerable-chartforgex-topology-topologylegenditem) 

Adds items to [TopologyLegend.Items](/api/chartforgex-topology-topologylegend/): Gets the legend items.

Parameters

**topologyLegend ChartForgeX.Topology.TopologyLegend required**

The instance.

**items System.Collections.Generic.IEnumerable<ChartForgeX.Topology.TopologyLegendItem> required**

The items, in order.

Returns

 `TopologyLegend` The same instance. 

 `public static TopologyLegend Title(TopologyLegend topologyLegend, string? value)` [#](#extension-title-chartforgex-topology-topologylegend-string) 

Sets [TopologyLegend.Title](/api/chartforgex-topology-topologylegend/): Gets or sets the legend title.

Parameters

**topologyLegend ChartForgeX.Topology.TopologyLegend required**

The instance.

**value string? required**

The value.

Returns

 `TopologyLegend` The same instance. 

Examples

```csharp
// C# initializer or property                                         // C# fluent
new global::ChartForgeX.Topology.TopologyLegend { Title = value };    topologyLegend.Title(value);
```

<!-- PowerForge markdown artifact sha256:B773548B63DFA16AA6758319C6188594CD3133C844B2BC51399FD8FA9E59169A -->
