suiss/uim · Chart

Line Chart Interactive

A monthly temperature chart for several cities with city toggles and an average, high and low switch.

Line Chart Interactive is an open-source mobile chart from suiss/uim, drawn with react-native-svg for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Line (interactive) on iOS in light mode

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

$ pnpm dlx @esuiss/uim@latest add line-chart-interactive

The CLI also adds what it builds on: Card, Chart, Text, Toggle, Toggle Group.

Manual

  1. Install the dependencies:
npx expo install cn
  1. Add the pieces it builds on: Card, Chart, Text, Toggle, Toggle Group.

  2. Copy the source into components/charts/line-chart-interactive.tsx:

uniwind/components/charts/line-chart-interactive.tsx
import { cn } from "cn"
import * as React from "react"
import { View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
  1. Update the import paths to match your project.

Usage

import { LineChartInteractive } from "@/components/charts/line-chart-interactive"
<LineChartInteractive />

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.