Skip to content
ChartForgeX
Class

ChartColorScale

ChartForgeX.Core

Namespace
ChartForgeX.Core
Assembly
ChartForgeX
Modifiers
sealed

Maps finite numeric values to continuous color stops or discrete bands. Continuous scales infer their domain from source values unless fixed bounds are supplied; an inferred constant domain uses the low color.

Inheritance

  • object
  • ChartColorScale

Usage

Explore 33 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.

Accepted by parameters 16

Methods

ColorFor 2 overloads
public ChartColor ColorFor(double value) #

Resolves a finite value using discrete bands or the continuous scale's explicit domain.

Parameters

value double required
The finite numeric value to color.

Returns

ChartColor The selected color. Continuous scales without fixed bounds require the source-domain overload.
public ChartColor ColorFor(double value, double sourceMinimum, double sourceMaximum) #

Resolves a value to a color within this scale.

Parameters

value double required
The value to color.
sourceMinimum double required
The minimum source value when the scale has no explicit minimum.
sourceMaximum double required
The maximum source value when the scale has no explicit maximum.

Returns

ChartColor The selected color. Discrete bands ignore the finite ordered source domain. An automatic constant domain uses the low color; a domain collapsed at its sole fixed endpoint clamps observations to that endpoint's color.
public static ChartColorScale Discrete(IEnumerable<ChartColorBand> bands) #

Creates a discrete scale with strictly ascending exclusive upper bounds and one final unbounded band.

Parameters

bands System.Collections.Generic.IEnumerable<ChartForgeX.Core.ChartColorBand> required
Ordered bands. Boundary equality selects the next band; the final upper bound must be null.

Returns

ChartColorScale An immutable scale whose colors do not depend on the observed domain.
Diverging 3 overloads
public static ChartColorScale Diverging(ChartColor lowColor, ChartColor midpointColor, ChartColor highColor, double? midpointValue = null) #

Creates a three-color diverging scale.

Parameters

lowColor ChartForgeX.Primitives.ChartColor required
The color for low values.
midpointColor ChartForgeX.Primitives.ChartColor required
The color for the midpoint value.
highColor ChartForgeX.Primitives.ChartColor required
The color for high values.
midpointValue double? = null optional
An optional midpoint value. When omitted, the midpoint is halfway between the effective minimum and maximum.

Returns

ChartColorScale A color scale.
public static ChartColorScale Diverging(IEnumerable<ChartColor> lowColors, ChartColor midpointColor, IEnumerable<ChartColor> highColors, double? midpointValue = null) #

Creates a diverging scale with any number of steps on each side of the midpoint. The low colours are spread evenly from the minimum to the midpoint value and the high colours from the midpoint value to the maximum.

Parameters

lowColors System.Collections.Generic.IEnumerable<ChartForgeX.Primitives.ChartColor> required
The colours below the midpoint, from the lowest value up to the step next to the midpoint; at least one.
midpointColor ChartForgeX.Primitives.ChartColor required
The color for the midpoint value.
highColors System.Collections.Generic.IEnumerable<ChartForgeX.Primitives.ChartColor> required
The colours above the midpoint, from the step next to the midpoint up to the highest value; at least one.
midpointValue double? = null optional
An optional midpoint value. When omitted, the midpoint is halfway between the effective minimum and maximum.

Returns

ChartColorScale A color scale.
public static ChartColorScale Diverging(IEnumerable<ChartColorStop> lowStops, ChartColorStop midpoint, IEnumerable<ChartColorStop> highStops) #

Creates a diverging scale with absolute numeric anchors on both sides of a fixed midpoint anchor.

Parameters

lowStops System.Collections.Generic.IEnumerable<ChartForgeX.Core.ChartColorStop> required
At least one ascending anchor, all below the midpoint.
midpoint ChartForgeX.Core.ChartColorStop required
The exact midpoint value and color.
highStops System.Collections.Generic.IEnumerable<ChartForgeX.Core.ChartColorStop> required
At least one ascending anchor, all above the midpoint.

Returns

ChartColorScale An immutable continuous color scale with a fixed endpoint domain.
public double EffectiveMaximum(double sourceMaximum) #

Gets the effective maximum value used by this scale.

Parameters

sourceMaximum double required
The source data maximum.

Returns

double The fixed maximum or inferred maximum, clamped above a sole fixed minimum.
public double EffectiveMidpoint(double sourceMinimum, double sourceMaximum) #

Gets the effective midpoint value used by this scale.

Parameters

sourceMinimum double required
The source data minimum.
sourceMaximum double required
The source data maximum.

Returns

double The effective midpoint.
public double EffectiveMinimum(double sourceMinimum) #

Gets the effective minimum value used by this scale.

Parameters

sourceMinimum double required
The source data minimum.

Returns

double The fixed minimum or inferred minimum, clamped below a sole fixed maximum.
Sequential 3 overloads
public static ChartColorScale Sequential(ChartColor lowColor, ChartColor highColor) #

Creates a two-color sequential scale.

Parameters

lowColor ChartForgeX.Primitives.ChartColor required
The color for low values.
highColor ChartForgeX.Primitives.ChartColor required
The color for high values.

Returns

ChartColorScale A color scale.
public static ChartColorScale Sequential(IEnumerable<ChartColor> colors) #

Creates a sequential scale with evenly spaced colour stops, for example every step of a design-token ramp.

Parameters

colors System.Collections.Generic.IEnumerable<ChartForgeX.Primitives.ChartColor> required
The colours from the lowest to the highest value; at least two.

Returns

ChartColorScale A color scale.
public static ChartColorScale Sequential(IEnumerable<ChartColorStop> stops) #

Creates a sequential scale with strictly ascending absolute numeric anchors and a fixed endpoint domain.

Parameters

stops System.Collections.Generic.IEnumerable<ChartForgeX.Core.ChartColorStop> required
At least two ordered value/color anchors. Values outside the endpoints use their colors.

Returns

ChartColorScale An immutable continuous color scale.
public ChartColorScale WithCaptions(IEnumerable<ChartColorScaleCaption> captions) #

Creates a continuous scale with copied captions at absolute measurement values.

Parameters

captions System.Collections.Generic.IEnumerable<ChartForgeX.Core.ChartColorScaleCaption> required
Non-null captions at distinct finite positions; input order is immaterial.

Returns

ChartColorScale An immutable scale retaining the complete caption catalog.
public ChartColorScale WithLabels(string? lowLabel, string? midpointLabel, string? highLabel) #

Creates a copy with custom legend labels.

Parameters

lowLabel string? required
The low-end legend label.
midpointLabel string? required
The optional midpoint legend label.
highLabel string? required
The high-end legend label.

Returns

ChartColorScale A color scale.
public ChartColorScale WithMidpoint(double midpointValue) #

Creates a copy with an explicit diverging midpoint value.

Parameters

midpointValue double required
The midpoint value used by the color scale.

Returns

ChartColorScale A color scale.
public ChartColorScale WithNoDataColor(ChartColor noDataColor) #

Creates a copy with a custom no-data color.

Parameters

noDataColor ChartForgeX.Primitives.ChartColor required
The color used for regions without values.

Returns

ChartColorScale A color scale.
public ChartColorScale WithValueRange(double? minimumValue, double? maximumValue) #

Creates a copy with independently fixed or inferred color interpolation bounds.

Parameters

minimumValue double? required
The fixed minimum, or null to infer it.
maximumValue double? required
The fixed maximum, or null to infer it.

Returns

ChartColorScale A color scale.

Properties

public IReadOnlyList<ChartColorScaleCaption> Captions { get; } #

Gets the immutable numeric caption catalog, sorted by position, or an empty list.

public ChartColorScaleMode Mode { get; } #

Gets the color-selection mode.

public IReadOnlyList<ChartColorBand> Bands { get; } #

Gets the detached read-only discrete bands, or an empty list for continuous scales.

public ChartColor LowColor { get; } #

Gets the low-value color: the first stop.

public ChartColor? MidpointColor { get; } #

Gets the midpoint color of a diverging scale, or null for other modes.

public ChartColor HighColor { get; } #

Gets the high-value color: the last stop.

public IReadOnlyList<ChartColor> Colors { get; } #

Gets every continuous stop or discrete band color, ordered from the lowest to the highest value.

public double? MidpointValue { get; } #

Gets the optional midpoint value. When omitted, the midpoint is halfway between the effective minimum and maximum.

public double? MinimumValue { get; } #

Gets the optional minimum value used for color interpolation.

public double? MaximumValue { get; } #

Gets the optional maximum value used for color interpolation.

public ChartColor? NoDataColor { get; } #

Gets the optional color for missing data. Renderers supply their theme fallback when this is null.

public string? LowLabel { get; } #

Gets the optional low-end legend label.

public string? MidpointLabel { get; } #

Gets the optional midpoint legend label.

public string? HighLabel { get; } #

Gets the optional high-end legend label.

public IReadOnlyList<ChartColorStop> Stops { get; } #

Gets detached absolute continuous anchors, or an empty list for unpositioned and discrete scales.