Skip to content

Charts - Styling

This page groups topics about charts customistion.

Colors

Series color

Series accept a property color which is the base color used to render its components.

<LineChart series={[{ ..., color: '#fdb462'}]} />
0123410152025exemple

Color palette

To avoid having to color series one by one, charts have a default color cycle. If a series does not have a color, a default color will be applied according to the index of the series.

You can override this color cycle by using prop colors to charts components (or <ChartContainer /> if you are using composition). This prop takes an array of colors.

Such array of colors can be generated by using d3-scale-chromatic.

Here is the example of the d3 Categorical color palette.

−6−5−4−3−2−1012345678−101series 1series 2series 3series 4series 5series 6series 7series 8series 9series 10series 11series 12series 13

Styling

Size

By default, charts adapt their sizing to fill their parent element. However, you can modify this behavior by providing height and/or width props.

Those will fix the chart's size to the given value (in px).

Placement

At the core of charts layout is the drawing area which corresponds to the space available to represent data.

This space can be fined with the margin prop and its properties top, bottom, left, and right. Those values define the space between the SVG border and the drawing area.

You might want to modify those values to let more space to your axis ticks, or reduce them to provide more space for the data.

CSS

Since the library relies on SVG for rendering, you can customize them as you do with other MUI components with CSS overriding.

Chart components accept the sx props. And you can target any sub elements with its class name.