PiecewiseColorLegend API
API reference docs for the React PiecewiseColorLegend component. Learn about the props, CSS, and other APIs of this exported module.
Demos
Import
import { PiecewiseColorLegend } from '@mui/x-charts/ChartsLegend';
// or
import { PiecewiseColorLegend } from '@mui/x-charts';
// or
import { PiecewiseColorLegend } from '@mui/x-charts-pro';
Learn about the difference by reading this guide on minimizing bundle size.
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
axisDirection | 'x' | 'y' | 'z' | 'z' | The axis direction containing the color configuration to represent. |
axisId | number | string | The first axis item. | The id of the axis item with the color configuration to represent. |
classes | object | - | Override or extend the styles applied to the component. See CSS classes API below for more details. |
direction | 'horizontal' | 'vertical' | 'horizontal' | The direction of the legend layout. |
labelFormatter | func | - | Format the legend labels. Signature: function(params: PiecewiseLabelFormatterParams) => string | null
Returns: The displayed label, |
labelPosition | 'start' | 'end' | 'extremes' | 'extremes' | Where to position the labels relative to the gradient. |
markType | 'square' | 'circle' | 'line' | 'square' | The type of the mark. |
onItemClick | func | - | Callback fired when a legend item is clicked. Signature: function(event: React.MouseEvent
|
ref
is forwarded to the root element.Theme default props
You can use MuiPiecewiseColorLegend
to change the default props of this component with the theme.
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
Class name | Rule name | Description |
---|---|---|
.MuiPiecewiseColorLegend-end | end | Styles applied to the legend with the labels after the color marks. |
.MuiPiecewiseColorLegend-extremes | extremes | Styles applied to the legend with the labels on the extremes of the color marks. |
.MuiPiecewiseColorLegend-horizontal | horizontal | Styles applied to the legend in row layout. |
.MuiPiecewiseColorLegend-item | item | Styles applied to the list items. |
.MuiPiecewiseColorLegend-label | label | Styles applied to the series label. |
.MuiPiecewiseColorLegend-mark | mark | Styles applied to the marks. |
.MuiPiecewiseColorLegend-maxLabel | maxLabel | Styles applied to the list item that renders the maxLabel . |
.MuiPiecewiseColorLegend-minLabel | minLabel | Styles applied to the list item that renders the minLabel . |
.MuiPiecewiseColorLegend-root | root | Styles applied to the root element. |
.MuiPiecewiseColorLegend-start | start | Styles applied to the legend with the labels before the color marks. |
.MuiPiecewiseColorLegend-vertical | vertical | Styles applied to the legend in column layout. |
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverrides
property in a custom theme.
Source code
If you did not find the information in this page, consider having a look at the implementation of the component for more detail.