Class HtmlLegend

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

Example

chart.legend(HtmlLegend().container(legendContainerElement).horizontal(false))

Hierarchy

  • HtmlLegend

Constructors

Methods

  • Set the container selector for the legend widget. Required.

    Returns Selection<HTMLElement, any, any, any>

  • Parameters

    • container: any

    Returns HtmlLegend

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

    Returns boolean

  • Parameters

    • highlightSelected: boolean

    Returns HtmlLegend

  • Display the legend horizontally instead of vertically

    Returns boolean

  • Parameters

    • horizontal: boolean

    Returns HtmlLegend

  • This can be optionally used to override class for legenditem and just use this class style. This is helpful for overriding the style of a particular chart rather than overriding the style for all charts.

    Setting this will disable the highlighting of selected items also.

    Returns string

  • Parameters

    • legendItemClass: string

    Returns HtmlLegend

  • 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 HtmlLegend().legendText(function(d, i) { return i + '. ' + d.name; }))

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

    Returns LegendTextAccessor

  • Parameters

    Returns HtmlLegend

  • Maximum number of legend items to display

    Returns number

  • Parameters

    • maxItems: number

    Returns HtmlLegend

  • Returns void

Generated using TypeDoc