Blog>
Snippets

Structuring Your Dataset for TanStack React Charts

Demonstrate how to structure a simple dataset into a format compatible with TanStack React Charts, including labeling axes and data series.
const dataset = [
  {
    label: 'Series 1',
    data: [{ x: 1, y: 10 }, { x: 2, y: 20 }, { x: 3, y: 25 }]
  },
  {
    label: 'Series 2',
    data: [{ x: 1, y: 5 }, { x: 2, y: 15 }, { x: 3, y: 30 }]
  }
];
This snippet defines a dataset compatible with TanStack React Charts. It consists of two series, each with its own label and data points. Each data point is defined by an x and y value, representing the position along the X-axis and Y-axis respectively.