Charts
Plot data with TanStack Charts and render it in React with Ghost UI.
How the chart works
TanStack Charts builds the chart from data, scales, and marks such as lines or bars. Ghost’s Chart renders it in React and adds styles for focus, tooltips, and labels.
See the Chart component for examples of different chart types.
Render your first chart
Install Ghost UI, then add the chart packages.
Load these styles once in your app entry point or root layout.
Render SuccessChart to see task success rise from 61% to 71%.
lineY draws a line from the rows. The x and y keys tell it which fields to plot. Use scales to set the axis ranges, and label the axes with units.
Data and interaction
Fetch and prepare the data in your app. Decide how to handle missing values, timezones, loading, and errors. Pass a new definition when the data changes so the chart can update.
Register tooltip in the definition to show values on inspection. Give the chart a useful accessible name. Provide a table or text summary when readers need exact values.
See Chart models and extensions for custom rendering and export. Use the TanStack Charts reference for marks, scales, and plugins. Match its examples to the version you installed.
Troubleshooting
- The chart is blank. Check for rows, matching field names, an axis range that includes them, and a container with usable dimensions.
- The tooltip is missing. Register the
tooltipplugin. - The chart still shows old values. Pass a new definition instead of mutating its data in place.