Class CatPalette

Representation of a categorical palette. Can be used to determine a color given a data tuple.

Hierarchy

  • CatPalette

Index

Accessors

slot

  • get slot(): string | null
  • Returns the name of the slot this palette is linked to, or null if the palette is not linked to a slot.

    Returns string | null

Methods

getColor

  • Determine a color given a tuple.

    Parameters

    • _tuple: Tuple | null

      The tuple to determine the color for or null to get a default color.

    Returns Color

    The color of the tuple.

getFillColor

  • Determine the fill color for a data point. The fill follows the 'selected' state of a data point. If the data set has selected data points, then the ones that are selected get the normal color as fill color and the ones that are not selected get a 60% transparent color.

    // Set fill color of elements in a d3 selection.
    selection.attr( "fill", _d => palette.getFillColor( _d ) )

    Parameters

    • _e: DataPoint | Tuple | null

      The data point or tuple to determine the color for. If null is passed, the method behaves the same as getColor.

    Returns string

    The color of the data point as a string.

getOutlineColor

  • Determine the outline color for a data point. The outline color depends on both the 'highlight' state and the 'selected' state. If the point is neither highlighted or selected, null is returned to indicate that no outline needs to be rendered. If the point is highlighted or part of a selection, then the returned color is a darker version of the actual data point color.

    // Set outline color of elements in a d3 selection.
    selection.attr( "stroke", _d => palette.getOutlineColor( _d ) )

    Parameters

    • _e: DataPoint | Tuple | null

      The data point or tuple to determine the color for. If null is passed, the method behaves the same as getColor.

    Returns string | null

    The color of the data point as a string or null if no outline is needed.