API: Legend

Legend Component reusable API class that renders a simple and configurable legend element.
Source:
Tutorials:
  • Tutorial: legend

Example

var donutChart = donut(),
    legendBox = legend();

donutChart
    .externalRadius(500)
    .internalRadius(200)
    .on('customMouseOver', function(data) {
        legendBox.highlight(data.data.id);
    })
    .on('customMouseOut', function() {
        legendBox.clearHighlight();
    });

d3Selection.select('.css-selector')
    .datum(dataset)
    .call(donutChart);

d3Selection.select('.other-css-selector')
    .datum(dataset)
    .call(legendBox);

Requires

  • module:d3

Methods


<static> clearHighlight()

Clears all highlighted entries
Source:

<static> colorSchema(_x)

Gets or Sets the colorSchema of the chart
Parameters:
Name Type Description
_x array Color scheme array to get/set
Source:
Returns:
Current colorSchema or Donut Chart module to chain calls
Type
number | module

<static> height(_x)

Gets or Sets the height of the legend chart
Parameters:
Name Type Description
_x number Desired width for the chart
Source:
Returns:
Current height or Legend module to chain calls
Type
height | module

<static> highlight(entryId)

Highlights a line entry by fading the rest of lines
Parameters:
Name Type Description
entryId number ID of the entry line
Source:

<static> isHorizontal(_x)

Gets or Sets the horizontal mode on the legend
Parameters:
Name Type Description
_x boolean Desired horizontal mode for the graph
Source:
Returns:
If it is horizontal or Legend module to chain calls
Type
ishorizontal | module

<static> margin(_x)

Gets or Sets the margin of the legend chart
Parameters:
Name Type Description
_x object Margin object to get/set
Source:
Returns:
Current margin or Legend module to chain calls
Type
margin | module

<static> marginRatio(_x)

Gets or Sets the margin ratio of the legend chart. Used to determine spacing between legend elements.
Parameters:
Name Type Description
_x number Margin Ratio to get/set
Source:
Returns:
Current marginRatio or Legend module to chain calls
Type
number | module

<static> markerSize(_x)

Gets or Sets the markerSize of the legend chart. This markerSize will determine the horizontal and vertical size of the colored marks added as color identifiers for the chart's categories.
Parameters:
Name Type Description
_x object Margin object to get/set
Source:
Returns:
Current markerSize or Legend module to chain calls
Type
markerSize | module

<static> numberFormat(_x)

Gets or Sets the number format of the legend chart
Parameters:
Name Type Description
_x string Desired number format for the legend chart
Source:
Returns:
Current number format or Legend module to chain calls
Type
numberFormat | module

<static> width(_x)

Gets or Sets the width of the legend chart
Parameters:
Name Type Description
_x number Desired width for the graph
Source:
Returns:
Current width or Legend module to chain calls
Type
width | module