Class Legend

Legend is a attachable widget that can be added to other dc charts to render horizontal legend labels.

Examples:

Example

chart.legend(new Legend().x(400).y(10).itemHeight(13).gap(5))

Hierarchy

  • Legend

Constructors

  • Returns Legend

Methods

  • Turn automatic width for legend items on or off. If true, itemWidth is ignored. This setting takes into account the gap.

    Returns boolean

  • Parameters

    • autoItemWidth: boolean

    Returns Legend

  • Set or get gap between legend items.

    Returns number

  • Parameters

    • gap: number

    Returns Legend

  • This can be optionally used to enable highlighting legends for the selections/filters for the chart.

    Returns boolean

  • Parameters

    • highlightSelected: boolean

    Returns Legend

  • Position legend horizontally instead of vertically.

    Returns boolean

  • Parameters

    • horizontal: boolean

    Returns Legend

  • Set or get legend item height.

    Returns number

  • Parameters

    • itemHeight: number

    Returns Legend

  • Legend item width for horizontal legend.

    Returns number

  • Parameters

    • itemWidth: number

    Returns Legend

  • Set or get the legend text function. The legend widget uses this function to render the legend text for each item. If no function is specified the legend widget will display the names associated with each group.

    Example

    // default legendText

    legend.legendText(d => d.name)

    // create numbered legend items
    chart.legend(new Legend().legendText(function(d, i) { return i + '. ' + d.name; }))

    // create legend displaying group counts
    chart.legend(new Legend().legendText(function(d) { return d.name + ': ' d.data; }))

    Returns LegendTextAccessor

  • Parameters

    Returns Legend

  • Maximum width for horizontal legend.

    Returns number

  • Parameters

    • legendWidth: number

    Returns Legend

  • Maximum number of legend items to display

    Returns number

  • Parameters

    • maxItems: number

    Returns Legend

  • Returns void

  • Set or get x coordinate for legend widget.

    Returns number

  • Parameters

    • x: number

    Returns Legend

  • Set or get y coordinate for legend widget.

    Returns number

  • Parameters

    • y: number

    Returns Legend

Generated using TypeDoc