suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Charts70
  • Overview
  • Area Chart
  • Bar Chart
  • Line Chart
  • Pie Chart
  • Radar Chart
  • Radial Chart
  • Tooltip Chart

suiss/ui ยท Chart

Line Chart

Ten line charts for trends over time, from a single smooth line to dots, labels, goals, forecasts and several series.

Line Chart 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.

Line charts follow a trend across time. Start with the default for one series, add dots or printed values when each reading matters, draw a goal line to show a target, and continue the line as a dashed forecast for values that have not happened yet. Linear and step lines avoid suggesting values between readings, and the multiple and interactive variants compare several series on the same axes.

Each chart is built on the Chart and Card components.

Every variant below is its own registry item, so you can add only the ones you need. Each one renders the same design on React, React Native, SwiftUI and Jetpack Compose.

Default

A single smooth line through six months of values, without point markers.

components/charts/line-chart-default.tsx
"use client"

import { CartesianGrid, Line, LineChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

The starting line chart: one smooth series without point markers, a month axis and a tooltip. Use it to show a trend over time when the overall shape matters more than individual readings.

Replace chartData, point each dataKey at your fields and set the label and color in chartConfig. Change the curve with type on the line, or set dot to show markers. Focus the chart and use the arrow keys to move the tooltip between months.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-default

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-default
  1. Install the following dependencies:
$ pnpm add recharts
  1. Add the pieces it builds on: Card, Chart.

  2. Copy and paste the following code into your project.

components/charts/line-chart-default.tsx
  1. Update the import paths to match your project setup.

Usage

import { LineChartDefault } from "@/components/charts/line-chart-default"
<LineChartDefault />
Web

Web preview

uniwind/components/charts/line-chart-default.tsx
swift/Charts/LineChartDefault.swift
kotlin/charts/LineChartDefault.kt

The baseline line chart inside a Card: one series drawn as a natural curve with a month axis, a dashed horizontal grid and a tooltip. There is no value axis.

Replace chartData with your records and change each dataKey to match your fields. Set the label and color in chartConfig, and change the curve with the type prop on Line. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-default

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-default
$ pnpm dlx shadcn@latest add @esuiss/line-chart-default

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-default --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-default

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-default --platform kotlin

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

  1. Add the pieces it builds on: Card, Chart.

  2. Copy and paste the following code into components/charts/line-chart-default.tsx:

uniwind/components/charts/line-chart-default.tsx
  1. Update the import paths to match your project setup.
  1. Add the pieces it builds on: Card, Chart.

  2. Copy and paste the following code into components/charts/line-chart-default.tsx:

nativewind/components/charts/line-chart-default.tsx
  1. Update the import paths to match your project setup.
  1. Add the pieces it builds on: Card, Chart.

  2. Copy and paste the following code into components/charts/line-chart-default.tsx:

stylesheet/components/charts/line-chart-default.tsx
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Copy the theme files every view uses:

swift/Theme/Theme.swift
swift/Theme/Tokens.swift
  1. Copy the source and every file it uses:
swift/Charts/LineChartDefault.swift
swift/Components/Card.swift
swift/Components/Chart.swift
swift/Components/Haptics.swift
swift/Components/Item.swift
swift/Components/Separator.swift
  1. Add the files to your app target.
  1. Apply the Compose compiler plugin, enable Compose, set compileSdk to 37 or higher and minSdk to 24 or higher, and add the dependencies:
build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
kotlin/theme/Tokens.kt
  1. Copy the source and every file it uses:
kotlin/charts/LineChartDefault.kt
kotlin/components/Card.kt
kotlin/components/Chart.kt
kotlin/components/Content.kt
kotlin/components/FormSupport.kt
kotlin/components/Haptics.kt
kotlin/components/Icon.kt
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { LineChartDefault } from "@/components/charts/line-chart-default"
<LineChartDefault />
import SwiftUI

struct LineExample: View {
  var body: some View {
    LineChartDefault()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartDefault

@Composable
fun LineExample() {
    LineChartDefault()
}

Dots

A weight trend with a dot at every monthly reading and a fixed value axis on the right.

components/charts/line-chart-dots.tsx
"use client"

import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"

import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const chartData = [
  82.4, 81.6, 81.9, 80.8, 80.1, 79.6, 79.8, 78.9, 78.4, 77.9,
].map((weight, index) => ({
  month: new Intl.DateTimeFormat("en-US", { month: "short" }).format(

A health-style weight card with a dot on every monthly reading and a fixed value axis on the right. The dots make it clear where measurements actually exist, so use this variant when readings are sparse or irregular.

Replace the readings in chartData and rename weight in the data, the line and chartConfig. Set the value axis domain and ticks to suit your numbers, and change the unit in the tooltip formatter. The headline value and the change below it are static text, so update them with the data or compute them from it.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-dots

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-dots

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartDots } from "@/components/charts/line-chart-dots"
<LineChartDots />
Web

Web preview

uniwind/components/charts/line-chart-dots.tsx
swift/Charts/LineChartDots.swift
kotlin/charts/LineChartDots.kt

Ten monthly weights drawn with type="linear" and a dot on every reading, plus a larger dot for the touched point. A value axis on the right covers a fixed range, and the tooltip formats values in kilograms. The header shows the latest weight and the change since January as static text.

Replace the weight array in chartData and update the header text to match. Adjust the YAxis domain and ticks for your range. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-dots

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-dots
$ pnpm dlx shadcn@latest add @esuiss/line-chart-dots

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-dots --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-dots

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-dots --platform kotlin

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartDots } from "@/components/charts/line-chart-dots"
<LineChartDots />
import SwiftUI

struct LineDotsExample: View {
  var body: some View {
    LineChartDots()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartDots

@Composable
fun LineDotsExample() {
    LineChartDots()
}

Forecast

A solid line for actual values that continues as a dashed forecast over a shaded future range.

components/charts/line-chart-forecast.tsx
"use client"

import { CartesianGrid, Line, LineChart, ReferenceArea, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

Actual values drawn as a solid line that continues as a dashed forecast over a shaded future period. Use it whenever you show projections next to history and need readers to tell them apart.

Fill the actual and forecast arrays and start the forecast with the last actual value so the lines meet; at that point the tooltip lists both values. Move the shaded period with x1 and x2 on the reference area. Both series share one color in chartConfig, so the dash pattern, the shading and the series names in the tooltip tell them apart.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-forecast

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-forecast

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartForecast } from "@/components/charts/line-chart-forecast"
<LineChartForecast />
Web

Web preview

uniwind/components/charts/line-chart-forecast.tsx
swift/Charts/LineChartForecast.swift
kotlin/charts/LineChartForecast.kt

Two series share one axis: actual fills the first nine months and forecast continues from September, drawn with strokeDasharray. A ReferenceArea shades September to December to mark the forecast period. Missing values are null, so each line stops where its data ends.

Replace the actual and forecast arrays; the forecast starts at the index set in chartData. Move the ReferenceArea x1 and x2 to match your forecast range. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-forecast

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-forecast
$ pnpm dlx shadcn@latest add @esuiss/line-chart-forecast

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-forecast --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-forecast

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-forecast --platform kotlin

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartForecast } from "@/components/charts/line-chart-forecast"
<LineChartForecast />
import SwiftUI

struct LineForecastExample: View {
  var body: some View {
    LineChartForecast()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartForecast

@Composable
fun LineForecastExample() {
    LineChartForecast()
}

Goal Dots

Nightly sleep hours with a goal line and dots colored green or orange depending on whether the goal was met.

components/charts/line-chart-goal-dots.tsx
"use client"

import {
  CartesianGrid,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "recharts"

import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,

Nightly sleep plotted against a dashed goal line, with each dot colored green if the goal was met and orange if not. Pick it over the plain goal chart when readers should spot hits and misses at a glance.

Replace chartData and set GOAL to your target; the dot colors follow the comparison. Adjust the value axis domain and ticks, and change the two dot colors in the custom dot renderer. The headline figure is static text, so wire it up to real values. Color alone marks a hit or miss on the chart, so keep a text explanation like the one in the header.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-goal-dots

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-goal-dots

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartGoalDots } from "@/components/charts/line-chart-goal-dots"
<LineChartGoalDots />
Web

Web preview

uniwind/components/charts/line-chart-goal-dots.tsx
swift/Charts/LineChartGoalDots.swift
kotlin/charts/LineChartGoalDots.kt

Seven nights of sleep drawn as a monotone line. The dot prop is a function that colors each point by comparing it with GOAL, and a dashed green ReferenceLine marks the goal itself. The tooltip formats values as hours and minutes.

Replace chartData with your nightly hours and set GOAL. The header average is static text, so update it with your own value. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-goal-dots

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-goal-dots
$ pnpm dlx shadcn@latest add @esuiss/line-chart-goal-dots

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-goal-dots --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-goal-dots

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-goal-dots --platform kotlin

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartGoalDots } from "@/components/charts/line-chart-goal-dots"
<LineChartGoalDots />
import SwiftUI

struct LineGoalDotsExample: View {
  var body: some View {
    LineChartGoalDots()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartGoalDots

@Composable
fun LineGoalDotsExample() {
    LineChartGoalDots()
}

Goal

Daily step counts plotted against a labeled dashed goal line at 10,000 steps.

components/charts/line-chart-goal.tsx
"use client"

import {
  CartesianGrid,
  Line,
  LineChart,
  ReferenceLine,
  XAxis,
  YAxis,
} from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,

Daily steps as a line with dots, plotted against a labeled dashed goal line. Use it when a single target gives the values their meaning, such as quotas, budgets or fitness goals.

Replace chartData and set GOAL to your target. Change the label on the ReferenceLine, the unit in the tooltip formatter and the axis tickFormatter to fit your metric. The value axis scales to the data only, so set a domain if the goal can fall outside it. Focus the chart and use the arrow keys to step through the days.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-goal

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-goal

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartGoal } from "@/components/charts/line-chart-goal"
<LineChartGoal />
Web

Web preview

uniwind/components/charts/line-chart-goal.tsx
swift/Charts/LineChartGoal.swift
kotlin/charts/LineChartGoal.kt

Seven days of steps drawn as a monotone line with dots, a value axis in thousands on the right and a labeled dashed ReferenceLine at GOAL. The tooltip formats the count with thousands separators.

Replace chartData with your daily values and set GOAL. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-goal

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-goal
$ pnpm dlx shadcn@latest add @esuiss/line-chart-goal

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-goal --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-goal

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-goal --platform kotlin

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartGoal } from "@/components/charts/line-chart-goal"
<LineChartGoal />
import SwiftUI

struct LineGoalExample: View {
  var body: some View {
    LineChartGoal()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartGoal

@Composable
fun LineGoalExample() {
    LineChartGoal()
}

Interactive

Monthly temperatures for several cities, with chips to show or hide each city and an average, high or low switch.

components/charts/line-chart-interactive.tsx
"use client"

import * as React from "react"
import {
  CartesianGrid,
  Line,
  LineChart,
  ReferenceLine,
  useActiveTooltipDataPoints,
  XAxis,
  YAxis,
} from "recharts"

import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  type ChartConfig,

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.

Replace CITIES with your series and add a label and color for each to chartConfig; the visible state sets which ones start visible. The high and low modes come from a demo formula, so replace temperature with real values and fit the fixed value axis domain to your range, since values outside it are clipped. The last visible city can't be hidden, and new lines draw in with an animation that is skipped when reduced motion is preferred.

Installation

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

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

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

Web preview

uniwind/components/charts/line-chart-interactive.tsx
swift/Charts/LineChartInteractive.swift
kotlin/charts/LineChartInteractive.kt

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".

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.

Installation

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

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-interactive
$ pnpm dlx shadcn@latest add @esuiss/line-chart-interactive

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-interactive --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-interactive

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-interactive --platform kotlin

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

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

struct LineInteractiveExample: View {
  var body: some View {
    LineChartInteractive()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartInteractive

@Composable
fun LineInteractiveExample() {
    LineChartInteractive()
}

Labeled

A single line with a dot and a printed value at every point, and no grid.

components/charts/line-chart-labeled.tsx
"use client"

import { LabelList, Line, LineChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

A single smooth line with a dot and a printed value at every point and no grid. Choose it for short series where readers want the exact numbers without hovering.

Replace chartData, point each dataKey at your fields and set the label and color in chartConfig. The position prop on LabelList moves the value labels; raise the chart's top margin if they get clipped. Labels overlap on long series, so keep it to a dozen points or fewer.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-labeled

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-labeled

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartLabeled } from "@/components/charts/line-chart-labeled"
<LineChartLabeled />
Web

Web preview

uniwind/components/charts/line-chart-labeled.tsx
swift/Charts/LineChartLabeled.swift
kotlin/charts/LineChartLabeled.kt

One natural curve with dots on each month and a LabelList above every point, so values are readable without touching the chart. There is no grid; a month axis and a tooltip remain.

Replace chartData with your records and change each dataKey to match your fields. Change position and offset on the LabelList to move the labels. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-labeled

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-labeled
$ pnpm dlx shadcn@latest add @esuiss/line-chart-labeled

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-labeled --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-labeled

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-labeled --platform kotlin

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartLabeled } from "@/components/charts/line-chart-labeled"
<LineChartLabeled />
import SwiftUI

struct LineLabeledExample: View {
  var body: some View {
    LineChartLabeled()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartLabeled

@Composable
fun LineLabeledExample() {
    LineChartLabeled()
}

Linear

A single line drawn with straight segments between readings instead of a smoothed curve.

components/charts/line-chart-linear.tsx
"use client"

import { CartesianGrid, Line, LineChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

One series joined by straight segments instead of a smoothed curve. Prefer it to the default when smoothing would imply values between readings that were never measured.

Replace chartData, point each dataKey at your fields and set the label and color in chartConfig. Focus the chart and use the arrow keys to move the tooltip between months.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-linear

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-linear

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartLinear } from "@/components/charts/line-chart-linear"
<LineChartLinear />
Web

Web preview

uniwind/components/charts/line-chart-linear.tsx
swift/Charts/LineChartLinear.swift
kotlin/charts/LineChartLinear.kt

One series with type="linear", so each month connects to the next with a straight segment. It has a month axis, a dashed grid and a tooltip.

Replace chartData with your records and change each dataKey to match your fields. Set the label and color in chartConfig. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-linear

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-linear
$ pnpm dlx shadcn@latest add @esuiss/line-chart-linear

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-linear --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-linear

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-linear --platform kotlin

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartLinear } from "@/components/charts/line-chart-linear"
<LineChartLinear />
import SwiftUI

struct LineLinearExample: View {
  var body: some View {
    LineChartLinear()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartLinear

@Composable
fun LineLinearExample() {
    LineChartLinear()
}

Multiple

Two lines compared on the same axes, with a legend identifying each series.

components/charts/line-chart-multiple.tsx
"use client"

import { CartesianGrid, Line, LineChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,

Two series as smooth lines on shared axes, with a legend below. Use it to compare how two metrics move over the same period.

Replace chartData and rename the series keys in the data, both Line elements and chartConfig. Add a Line with its own config entry for each extra series; the legend and tooltip pick it up. Beyond four or five lines, consider the interactive variant that lets readers toggle series.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-multiple

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-multiple

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartMultiple } from "@/components/charts/line-chart-multiple"
<LineChartMultiple />
Web

Web preview

uniwind/components/charts/line-chart-multiple.tsx
swift/Charts/LineChartMultiple.swift
kotlin/charts/LineChartMultiple.kt

Desktop and mobile series drawn as monotone lines on the same axis. A legend below the plot names both series, and the tooltip lists each value for the touched month.

Replace chartData with your records and change each dataKey to match your fields. Add a Line and a chartConfig entry for each extra series; the legend picks them up. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-multiple

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-multiple
$ pnpm dlx shadcn@latest add @esuiss/line-chart-multiple

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-multiple --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-multiple

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-multiple --platform kotlin

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartMultiple } from "@/components/charts/line-chart-multiple"
<LineChartMultiple />
import SwiftUI

struct LineMultipleExample: View {
  var body: some View {
    LineChartMultiple()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartMultiple

@Composable
fun LineMultipleExample() {
    LineChartMultiple()
}

Step

A single line drawn as horizontal steps, holding each value until the next reading.

components/charts/line-chart-step.tsx
"use client"

import { CartesianGrid, Line, LineChart, XAxis } from "recharts"

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,

A single line drawn as flat steps that hold each value until the next reading. It fits values that change in discrete jumps, like prices, plan tiers or headcount.

Replace chartData, point each dataKey at your fields and set the label and color in chartConfig. Set the curve type to stepAfter or stepBefore to move where each jump happens. Focus the chart and use the arrow keys to move the tooltip between months.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-step

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-step

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartStep } from "@/components/charts/line-chart-step"
<LineChartStep />
Web

Web preview

uniwind/components/charts/line-chart-step.tsx
swift/Charts/LineChartStep.swift
kotlin/charts/LineChartStep.kt

One series with type="step", which draws flat runs and vertical jumps instead of slopes. Use it for values that change at discrete moments. It has a month axis, a dashed grid and a tooltip.

Replace chartData with your records and change each dataKey to match your fields. Set the label and color in chartConfig. The component takes no props.

Installation

$ pnpm dlx shadcn@latest add @esuiss/line-chart-step

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-step
$ pnpm dlx shadcn@latest add @esuiss/line-chart-step

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-step --platform swift
$ pnpm dlx shadcn@latest add @esuiss/line-chart-step

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add charts line-chart-step --platform kotlin

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

Follow the manual steps under Default and copy this variant's source instead.

Usage

import { LineChartStep } from "@/components/charts/line-chart-step"
<LineChartStep />
import SwiftUI

struct LineStepExample: View {
  var body: some View {
    LineChartStep()
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.charts.LineChartStep

@Composable
fun LineStepExample() {
    LineChartStep()
}
NextPie ChartPreviousBar Chart

On this page

  1. 01Default
  2. 02Dots
  3. 03Forecast
  4. 04Goal Dots
  5. 05Goal
  6. 06Interactive
  7. 07Labeled
  8. 08Linear
  9. 09Multiple
  10. 10Step