Out of the box, React Charts is very forgiving and requires very little to use. Let's get started by going over the bare minimum configuration required to render a chart!
Series
objects (more on this in a bit), each with a data
property that is an array of Datums
(be patient, we'll explain soon!)type DailyStars = {date: Date,stars: number,}type Series = {label: string,data: DailyStars[]}const data: Series[] = [{label: 'React Charts",data: [{date: new Date(),stars: 202123,}// ...]},{label: 'React Query",data: [{date: new Date(),stars: 10234230,}// ...]}]
primaryAxis: AxisOptions<TDatum>
secondaryAxes: AxisOptions<TDatum>[]
function App() {const primaryAxis = React.useMemo((): AxisOptions<DailyStars> => ({getValue: datum => datum.date,}),[])const secondaryAxes = React.useMemo((): AxisOptions<DailyStars>[] => [{getValue: datum => datum.stars,},],[])return (<Chartoptions={{data,primaryAxis,secondaryAxes,}}/>)}
Now that you know how to build a simple chart, let's dive deeper!
The latest TanStack news, articles, and resources, sent to your inbox.