Skip to main content

legend

Legend

Legend Component reusable API class that renders a simple and configurable legend element.

Requires: module:d3-format,
Example

const 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);

exports(_selection, _data) ⏏

This function creates the graph using the selection as container

Kind: Exported function

ParamTypeDescription
_selectionD3SelectionA d3 selection that represents the container(s) where the chart(s) will be rendered
_dataLegendChartDataThe data to attach and generate the chart

exports.clearHighlight()

Command that clears all highlighted entries on a legend instance

Kind: static method of exports
Access: public

exports.colorMap([_x]) ⇒ object | module

Gets or Sets the colorMap of the chart

Kind: static method of exports
Returns: object | module - Current colorMap or Legend module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]objectColor map

exports.colorSchema([_x]) ⇒ number | module

Gets or Sets the colorSchema of the chart

Kind: static method of exports
Returns: number | module - Current colorSchema or Legend module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]arraycolorHelper.colorSchemas.britechartsColor scheme array to get/set

exports.height([_x]) ⇒ height | module

Gets or Sets the height of the legend chart

Kind: static method of exports
Returns: height | module - Current height or Legend module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]number180Desired width for the chart in pixels

exports.highlight(entryId)

Command that highlights a line entry by fading the rest of lines on a legend instance

Kind: static method of exports
Access: public

ParamTypeDescription
entryIdnumberID of the entry line

exports.highlightEntryById([_x]) ⇒ Number | Module

Gets or Sets the id of the entry to highlight

Kind: static method of exports
Returns: Number | Module - Current highlighted slice id or Donut Chart module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]NumberEntry id

exports.isHorizontal([_x]) ⇒ Boolean | module

Gets or Sets the horizontal mode on the legend

Kind: static method of exports
Returns: Boolean | module - If it is horizontal or Legend module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]BooleanfalseDesired horizontal mode for the graph

exports.margin(_x) ⇒ object | module

Gets or Sets the margin of the legend chart

Kind: static method of exports
Returns: object | module - Current margin or Legend module to chain calls
Access: public

ParamTypeDescription
_xobjectMargin object to get/set

exports.marginRatio([_x]) ⇒ number | module

Gets or Sets the margin ratio of the legend chart. Used to determine spacing between legend elements.

Kind: static method of exports
Returns: number | module - Current marginRatio or Legend module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]number1.5Margin Ratio to get/set

exports.markerSize([_x]) ⇒ object | module

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.

Kind: static method of exports
Returns: object | module - Current markerSize or Legend module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]object16Margin object to get/set

exports.numberFormat(_x) ⇒ string | module

Gets or Sets the number format of the legend chart

Kind: static method of exports
Returns: string | module - Current number format or Legend module to chain calls
Access: public

ParamTypeDescription
_xArray.<string>= 's' Desired numberFormat for the chart. See examples here

exports.unit([_x]) ⇒ String | module

Gets or Sets the unit of the value

Kind: static method of exports
Returns: String | module - Current unit or Legend module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]String''Desired unit

exports.width([_x]) ⇒ number | module

Gets or Sets the width of the legend chart

Kind: static method of exports
Returns: number | module - Current width or Legend module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]number320Desired width for the graph in pixels

exports~LegendChartData : Array.<Object>

Kind: inner typedef of exports
Properties

NameTypeDescription
idNumberId of the group (required)
nameStringName of the group (required)
quantityNumberQuantity of the group (optional)

Example

[
{
id: 1,
quantity: 2,
name: 'glittering'
},
{
id: 2,
quantity: 3,
name: 'luminous'
}
]