Chart
Plot rows of data with BarChart, LineChart, AreaChart or PieChart. Each key in series is one series, colored in order. For a chart they don't cover, compose Recharts parts inside ChartContainer and set each series' label and color in config.
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Composition
Examples
Stacked bar chart
Stack the series in one bar per category with stacked.
Horizontal bar chart
Run the bars left to right with orientation="horizontal". The categories move to the y-axis.
Line chart
Area chart
Fade each area toward the axis with fill="gradient".
Pie chart
Plot one value per row with PieChart. donut cuts out the middle.
Series labels and colors
Each series is labelled by its key and colored in order. Set a label or color for a key in config.
Custom bar chart
Compose Recharts parts inside ChartContainer for a chart the data charts don't cover, such as a patterned series.
This example also needs:
Custom area chart
Plot two series as areas, with a tooltip and a legend.
This example also needs:
Custom line chart
Plot two series as lines, with a tooltip and a legend.
This example also needs:
Props
AreaChart
| Prop | Type | Default | Description |
|---|---|---|---|
categoryAxis | boolean | true | Shows the axis with each row's category. |
className | string | No default documented | No description |
config | ChartConfig | No default documented | Label, icon and color for each series, keyed by its key. Without one, a series is labelled by its key. |
curve | "linear" | "natural" | "monotone" | "step" | "natural" | How each area's edge joins its points. |
dataRequired | ChartDatum[] | No default documented | The rows to plot, one per category. |
fill | "solid" | "gradient" | "solid" |
|
grid | boolean | true | Draws grid lines across the values. |
indicator | "dashed" | "line" | "dot" | "dot" | The tooltip's mark beside each value. |
legend | boolean | true | Shows a legend under the chart. |
seriesRequired | string[] | No default documented | The keys in each row to plot. Each key is one series, colored in order. The palette has five colors, so a sixth series repeats the first series' color. |
stacked | boolean | false | Stacks the series on top of each other. |
tooltip | boolean | true | Shows a tooltip on hover. |
valueAxis | boolean | false | Shows the axis with the value scale. |
xKeyRequired | string | No default documented | The key in each row that holds its category, such as |
BarChart
| Prop | Type | Default | Description |
|---|---|---|---|
categoryAxis | boolean | true | Shows the axis with each row's category. |
className | string | No default documented | No description |
config | ChartConfig | No default documented | Label, icon and color for each series, keyed by its key. Without one, a series is labelled by its key. |
dataRequired | ChartDatum[] | No default documented | The rows to plot, one per category. |
grid | boolean | true | Draws grid lines across the values. |
indicator | "dashed" | "line" | "dot" | "dashed" | The tooltip's mark beside each value. |
legend | boolean | true | Shows a legend under the chart. |
orientation | "horizontal" | "vertical" | "vertical" | The direction the bars run. |
radius | number | 4 | Corner radius of each bar, in px. A stack rounds only its outer end. |
seriesRequired | string[] | No default documented | The keys in each row to plot. Each key is one series, colored in order. The palette has five colors, so a sixth series repeats the first series' color. |
stacked | boolean | false | Stacks the series in one bar per category. |
tooltip | boolean | true | Shows a tooltip on hover. |
valueAxis | boolean | false | Shows the axis with the value scale. |
xKeyRequired | string | No default documented | The key in each row that holds its category, such as |
ChartContainer
| Prop | Type | Default | Description |
|---|---|---|---|
configRequired | ChartConfig | No default documented | No description |
ChartLegend
ChartLegend adds no props of its own; it accepts the props of the element or primitive it wraps.
ChartLegendContent
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | No default documented | No description |
hideIcon | boolean | false | No description |
nameKey | string | No default documented | No description |
verticalAlign | "bottom" | "top" | "bottom" | No description |
ChartTooltip
ChartTooltip adds no props of its own; it accepts the props of the element or primitive it wraps.
ChartTooltipContent
| Prop | Type | Default | Description |
|---|---|---|---|
active | boolean | No default documented | No description |
className | string | No default documented | No description |
color | string | No default documented | No description |
formatter | ChartTooltipFormatter | No default documented | No description |
hideIndicator | boolean | false | No description |
hideLabel | boolean | false | No description |
indicator | "dashed" | "line" | "dot" | "dot" | No description |
labelKey | string | No default documented | No description |
nameKey | string | No default documented | No description |
LineChart
| Prop | Type | Default | Description |
|---|---|---|---|
categoryAxis | boolean | true | Shows the axis with each row's category. |
className | string | No default documented | No description |
config | ChartConfig | No default documented | Label, icon and color for each series, keyed by its key. Without one, a series is labelled by its key. |
curve | "linear" | "natural" | "monotone" | "step" | "natural" | How each line joins its points. |
dataRequired | ChartDatum[] | No default documented | The rows to plot, one per category. |
dots | boolean | false | Marks each data point with a dot. |
grid | boolean | true | Draws grid lines across the values. |
indicator | "dashed" | "line" | "dot" | "line" | The tooltip's mark beside each value. |
legend | boolean | true | Shows a legend under the chart. |
seriesRequired | string[] | No default documented | The keys in each row to plot. Each key is one series, colored in order. The palette has five colors, so a sixth series repeats the first series' color. |
tooltip | boolean | true | Shows a tooltip on hover. |
valueAxis | boolean | false | Shows the axis with the value scale. |
xKeyRequired | string | No default documented | The key in each row that holds its category, such as |
PieChart
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | No default documented | No description |
config | ChartConfig | No default documented | Label, icon and color for each slice, keyed by its name. Without one, a slice is labelled by its name. |
dataRequired | ChartDatum[] | No default documented | The slices to plot, one row each. The palette has five colors, so a sixth slice repeats the first slice's color. |
donut | boolean | false | Cuts out the middle, so the pie becomes a ring. |
labels | boolean | false | Writes each slice's value beside it. |
legend | boolean | true | Shows a legend under the chart. |
nameKeyRequired | string | No default documented | The key in each row that holds the slice's name, such as |
tooltip | boolean | true | Shows a tooltip on hover. |
valueKeyRequired | string | No default documented | The key in each row that holds the slice's value. |
Chart isn't in the Vue package yet. The React version is ready to use today.