2.0 alpha
These docs describe 2.0. Install it with @once-ui-system/core@alpha.
On 1.8.x? Read the 1.x docs
TrademarkTrademarkDocs
Ctrl k
Search docs...
Data

Setup

Updated: May 14, 2025
View on GitHub
The Once UI data-viz module is a collection of opinionated chart solutions built on top of Recharts and Date-fns. It was designed to help you create beautiful and interactive charts with minimal code. The default settings for the data viz module are stored in the src/resources/data.config.js file. You can use it to define the default height, highlight color, data mode and variant. All charts share the same props for common settings, so it's easy to swap between different chart types with minimal code changes. Each chart may have additional, chart-specific props. Every chart takes these. The sections below walk through the ones worth explaining; this is the whole list.
Prop
Type
Default
title
Heading above the chart.
React.ReactNode
description
Supporting line under the title.
React.ReactNode
seriesrequired
Which keys in `data` to plot, and optionally what colour each is.
SeriesConfigSeriesConfig[]
datarequired
The rows. Each needs the keys named in `series`, plus whatever the x axis reads.
DataPoint[]
legend
Legend position and visibility.
LegendConfig
date
Format and range for a time axis.
DateConfig
emptyState
What to show when `data` is empty.
React.ReactNode
errorState
What to show when `error` is set.
React.ReactNode
error
Render the error state instead of the chart.
boolean
tooltip
Show a tooltip on hover.
boolean
grid
Which grid lines to draw. Chart types differ in what they default to.
xybothnone
axis
Which axes to label.
xybothnone
variant
Fill treatment for the plotted area.
flatoutlinegradient
loading
Render the loading state instead of the chart.
boolean
Use the series and data props to define the chart data to render, and assign colors to override defaults. The series prop is an array of objects, where each object has a key property that defines the name of the series, and an optional color property that defines the color of the series. Match the key property with the property name in the data prop.
Prop
Type
Default
series
{[{key: string, color?: string}]}
data
{[{date: string, [key: string]: number}]}
When working with time series data, use the date prop to define the date format. Alternatively, you can translate the date values to Date objects to render the dates based on the default format. Render textual context above the chart with the title and description props.
Prop
Type
Default
title
ReactNode
description
ReactNode
Use the axis prop to control the visibility of the x and y axis.
Prop
Type
Default
axis
xybothnone
both
Use the legend prop to control the visibility, position, and direction of the legend.
Prop
Type
Default
legend
{{display: boolean, position: Position}}
Use the date prop to define the date format and datepicker visibility and options.
Prop
Type
Default
date
{{format: string, start: Date, end: Date, selector: boolean, presets: { display: boolean, granularity: string }, dual: boolean}}
Set the variant prop to gradient, flat, or outline to change the chart's appearance.
Prop
Type
Default
variant
gradientflatoutline
gradient
Use the data-viz-style prop to change the chart's color mode to categorical, divergent, or sequential. Colors are assigned automatically. You can override them in the series prop. When using data-viz-style="divergent" or data-viz-style="sequential", we recommend using the default colors, since they are distributed evenly.
Prop
Type
Default
data-viz-style
Overrides the DataThemeProvider mode for this chart only. Falls back to the provider value.
categoricaldivergentsequential
You can override the default container styles with Flex props.
Prop
Type
Default
…and every FlexProps propinherited
Charts fetch nothing themselves, so the four states of a request are props you set from wherever the data comes from. Handle them and a chart degrades into a readable panel rather than an empty frame.
Prop
Type
Default
loading
Show the loading state instead of the chart.
booleanfalse
error
Show the error state instead of the chart.
booleanfalse
emptyState
Replaces the default message when data is empty.
ReactNode
errorState
Replaces the default message when error is set.
ReactNode
An empty data array is not an error — it means the query ran and matched nothing, which is why emptyState is separate from errorState. Passing loading rather than withholding the chart keeps the panel's height stable, so the page does not jump when the data lands.
Prop
Type
Default
grid
Which grid lines to draw. Bar charts default to y, line charts to both.
xybothnone
varies
tooltip
Show the hover tooltip.
booleantrue
grid and axis are separate on purpose: a bar chart usually wants horizontal guides to compare heights against (grid="y") while still labelling both axes, and a sparkline-style chart wants axis="none" with the grid left on.
Edit this page on GitHub
TrademarkTrademark
Built with curiosity by Lorant One and the Design Engineers Club