suiss/ui · Chart
Line Chart Interactive
Monthly temperatures for several cities, with chips to show or hide each city and an average, high or low switch.
Line Chart Interactive is an open-source chart from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Monthly temperatures for several cities with chips to show or hide each city and a switch between average, high and low. A row of stats under the chart shows each city's range and follows the cursor month. Use it as a pattern for comparing many series where readers pick which ones to see.
Installation
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
- Install the dependencies:
-
Add the pieces it builds on: Card, Chart, Toggle, Toggle Group.
-
Copy the source into
components/charts/line-chart-interactive.tsx:
- Update the import paths to match your project.
Usage
Replace CITIES with your own series and add a matching entry with label and color to chartConfig for each one. Set which series start visible in the visible state. The high and low modes are derived from the averages with a demo formula, so replace temperature with real values, and adjust the fixed value axis domain to your range.
Notes
The last visible city can't be hidden, so the chart is never empty. Values outside the fixed value axis range are clipped. Newly shown lines draw in with an animation that is skipped when reduced motion is preferred.

One line per visible city across twelve months. A ToggleGroup switches between average, high and low temperatures, and a row of Toggle chips shows or hides each city, keeping at least one on. Touching the plot reports the month through onActiveIndexChange, and the summary under the chart switches from each city's range to its value for that month. The lines animate with animationDuration={650} and animationEasing="ease-in-out".
Installation
The CLI also adds what it builds on: Card, Chart, Text, Toggle, Toggle Group.
Manual
- Install the dependencies:
-
Add the pieces it builds on: Card, Chart, Text, Toggle, Toggle Group.
-
Copy the source into
components/charts/line-chart-interactive.tsx:
- Update the import paths to match your project.
- Install the dependencies:
-
Add the pieces it builds on: Card, Chart, Text, Toggle, Toggle Group.
-
Copy the source into
components/charts/line-chart-interactive.tsx:
- Update the import paths to match your project.
-
Add the pieces it builds on: Card, Chart, Text, Toggle, Toggle Group.
-
Copy the source into
components/charts/line-chart-interactive.tsx:
- Update the import paths to match your project.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Set
minSdkto 24 or higher and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Replace CITIES with your series and monthly values, and add a matching entry to chartConfig and SWATCH for each. The high and low values are derived in temperature(), so replace that with real data. The component takes no props.
