Legend
The Legend component is used to display a legend for the visualization.
<Chart data={data}>
<Legend position="right" title="Country">
</Chart>
Props
| name | type | default | description |
|---|---|---|---|
| color | string | {value: Color} | – | Overrides the default symbol fill and stroke color. If a string is provided, this is a data key reference, similar to setting color on a mark like Line or Bar. If a static value object is provided then all symbols will be the color provided. Css color names and spectrum color names are supported for the static color value. |
| defaultHiddenSeries | string[] | – | Series that should be hidden by default (uncontrolled). This is different from hiddenEntries which only hides entries from the legend, whereas defaultHiddenSeries hides the series from both the legend and the chart. |
| descriptions | {seriesName: string, description: string, title?: string}[] | – | An array of objects containing a seriesName, description, and optional title property. The seriesName must match the value of the series property on the chart data being passed in. If set, a tooltip will appear after a short delay when you hover over a legend element. The contents of the tooltip will be the description found in the key-value pair. |
| hiddenEntries | string[] | – | List of series names that should be hidden from the legend. This does not hide these series in the chart as well, only the legend. To hide series in the chart, use hiddenSeries. |
| highlight | boolean | false | Defines if hovering over a legend element should highlight that series in the chart. |
| isToggleable | boolean | false | Sets if the series should be able to hide/show by clicking on the respective legend entry (uncontrolled). |
| keys | string[] | – | Keys from the data to generate the legend for. Defaults to all keys used to facet the data. Use this prop to limit which data fields should appear in the legend. |
| labelLimit | number | – | Max width in pixels before truncating a legend label. If not specified, labels will not be truncated. Influences legend column layout by calculating how many legend items can fit horizontally based on the label width (for top/bottom positioned legends). |
| legendLabels | {seriesName: string | number, label: string, maxLength?: number}[] | - | Defines custom labels to display in place of the series value for data. If one series has an override, any series that don't have an override will display their series value. The optional maxLength property can be used to truncate individual labels. |
| lineType | string | { value: LineType } | – | Overrides the default symbol border line type. If a string is provided, this is a data key reference, similar to setting color on a mark like Line or Bar. If a static value object is provided then all symbol borders will have the line type provided. |
| lineWidth | string | { value: LineWidth } | – | Overrides the default symbol border line width. If a string is provided, this is a data key reference, similar to setting color on a mark like Line or Bar. If a static value object is provided then all symbol borders will have the line width provided. |
| onMouseOut | (seriesName: string) => void | – | Allows triggering of a callback function when moving the mouse pointer outside of a legend item. |
| onMouseOver | (seriesName: string) => void | – | Allows triggering of a callback function when moving the mouse pointer over a legend item. |
| opacity | string | { value: number } |