suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Components84
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Code Block
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Trace
  • Wheel Picker
  • Widget

suiss/ui · Component

Chart

Themed building blocks for Recharts charts, with a shared color config, tooltip and legend.

Chart is an open-source component 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.

import { Bar, BarChart, CartesianGrid, XAxis } from "recharts"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const visitors = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 73, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 214, mobile: 140 },
]

Chart does not draw charts itself; it styles charts you compose with recharts. A ChartContainer takes a config that maps each data key to a label, an optional icon and a color, and wraps your Recharts chart in a ResponsiveContainer. Inside the chart, use ChartTooltip with content={<ChartTooltipContent />} and ChartLegend with content={<ChartLegendContent />} to render a tooltip and legend that read labels and colors from the config.

Use it for bar, line, area and pie charts in dashboards and reports. Because you work with Recharts directly, every Recharts chart type and prop remains available.

For ready-made charts built on it, see the area, bar, line, pie, radar and radial charts, and the tooltip variants.

Installation

$ pnpm dlx shadcn@latest add @esuiss/chart

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 chart
  1. Install the following dependencies and add the cn helper:
$ pnpm add recharts
  1. Copy and paste the following code into your project.
components/ui/chart.tsx
"use client"

import * as React from "react"
import type { TooltipValueType } from "recharts"
import * as RechartsPrimitive from "recharts"
import { cn } from "@/lib/utils"

const THEMES = { light: "", dark: ".dark" } as const

const INITIAL_DIMENSION = { width: 320, height: 200 } as const
const UNSAFE_IDENTIFIER_CHARACTERS = /[^\w-]/g
const UNSAFE_VALUE_CHARACTERS = /[;{}<>\\]/
type TooltipNameType = number | string

export type ChartConfig = Record<
  string,
  1. Update the import paths to match your project setup.

Usage

import {
  Bar,
  BarChart,
  CartesianGrid,
  XAxis,
} from "recharts"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"
const visitors = [
  { month: "January", desktop: 186 },
  { month: "February", desktop: 305 },
  { month: "March", desktop: 237 },
]

const visitorsConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig
<ChartContainer config={visitorsConfig} className="w-full max-w-lg">
  <BarChart accessibilityLayer data={visitors}>
    <CartesianGrid vertical={false} />
    <XAxis dataKey="month" tickLine={false} tickMargin={10} axisLine={false} />
    <ChartTooltip content={<ChartTooltipContent />} />
    <Bar dataKey="desktop" fill="var(--color-desktop)" radius={8} />
  </BarChart>
</ChartContainer>

Examples

Multiple series

Two bar series with a ChartLegend and a tooltip that sets indicator="dashed".

import { Bar, BarChart, CartesianGrid, XAxis } from "recharts"
import {
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const visitors = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 73, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },

Stacked

Stacks two bar series and sets hideLabel on ChartTooltipContent to hide the tooltip label.

import { Bar, BarChart, CartesianGrid, XAxis } from "recharts"
import {
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const visitors = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 73, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },

Line series

Two smooth lines with a tooltip that sets indicator="line".

import { CartesianGrid, Line, LineChart, XAxis } from "recharts"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const visitors = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 73, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 214, mobile: 140 },
]

Area series

Two stacked, semi-transparent areas.

import { Area, AreaChart, CartesianGrid, XAxis } from "recharts"
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const visitors = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 73, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 214, mobile: 140 },
]

Donut

A pie chart with an inner radius. Each row is its own category, so the color is in the row (for example fill: "var(--color-safari)") and nameKey on ChartLegendContent looks labels up by that field. The container uses aspect-square max-w-72.

import { Pie, PieChart } from "recharts"
import {
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/chart"

const browsers = [
  { browser: "safari", visitors: 275, fill: "var(--color-safari)" },
  { browser: "chrome", visitors: 200, fill: "var(--color-chrome)" },
  { browser: "firefox", visitors: 187, fill: "var(--color-firefox)" },
  { browser: "edge", visitors: 173, fill: "var(--color-edge)" },
  { browser: "other", visitors: 90, fill: "var(--color-other)" },

Accessibility

  • Enable accessibilityLayer on the Recharts chart to support keyboard navigation. The chart is then focusable and arrow keys move between data points, showing the tooltip for each.
  • ChartContainer gives the chart an aria-label: yours, or "Chart of" followed by the config labels. A chart element that already has an aria-label keeps it.
  • Charts are visual; provide a nearby summary or table when the exact values matter.
  • Do not rely on color alone to tell series apart; the legend and tooltip pair each color with its label.

API Reference

ChartContainer

Provides the config, injects the color variables and makes the chart responsive.

PropTypeDefault
configChartConfigRequired
childrenReact.ReactNodeRequired
initialDimension{ width: number; height: number }{ width: 320, height: 200 }
aria-labelstring"Chart of <series labels>"

Also accepts the props of React.ComponentProps<"div">.

config maps each data key to a label, an optional icon, and a color or per-theme theme colors. Each key becomes a CSS custom property scoped to the chart, such as --color-desktop; reference it from your series, as in fill="var(--color-desktop)". Set color for a single value, or theme with light and dark values to switch colors with the .dark class. Config keys and color values containing unsafe characters are skipped when generating CSS.

Pass the Recharts chart as children. initialDimension is the width and height used before the container is measured. Without an aria-label, the chart gets "Chart of" followed by the config labels, or "Chart" when there are none. The container is aspect-video by default; override its size with className, for example aspect-square max-w-72. It restyles Recharts defaults, such as grid lines, axis ticks and the tooltip cursor. It sets data-slot="chart" and a unique data-chart id that scopes the generated --color-* variables.

ChartTooltip, ChartLegend and ChartStyle are also exported; the first two are the Recharts Tooltip and Legend components.

ChartTooltipContent

A styled tooltip body that lists each series with its indicator, label and value.

PropTypeDefault
hideLabelbooleanfalse
hideIndicatorbooleanfalse
indicator"line" | "dot" | "dashed""dot"
nameKeystring-
labelKeystring-

Also accepts the props of the Recharts Tooltip and React.ComponentProps<"div">.

Render it with <ChartTooltip content={<ChartTooltipContent />} />. nameKey is the field used to look up each item's config entry instead of its name or data key, and labelKey the field used to look up the heading label. Number values are formatted with toLocaleString().

ChartLegendContent

A styled legend that lists series in config order with a swatch or icon.

PropTypeDefault
hideIconbooleanfalse
nameKeystring-

Also accepts the props of React.ComponentProps<"div"> and the Recharts DefaultLegendContentProps.

Render it with <ChartLegend content={<ChartLegendContent />} />. hideIcon shows a color swatch even when the config entry has an icon. nameKey is the field used to look up each legend item's config entry instead of its data key.

Web

Web preview

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import Charts
import SwiftUI

struct ChartTooltipDotExample: View {
  var body: some View {
    ChartStackedTooltip(title: "Dot indicator", description: "indicator=\"dot\"", defaultIndex: 2) { payload in
      ChartTooltipContent(payload, indicator: .dot)
    }
  }
}

let chartMonthData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.phosphoricons.regular.Desktop
import com.esuiss.ui.components.BarChart
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartMargin

Charts are composed declaratively: a chart root such as LineChart, AreaChart, BarChart, ComposedChart, PieChart, RadialBarChart or RadarChart goes inside a ChartContainer, and series and axes such as Line, Area, Bar, XAxis, YAxis and CartesianGrid are added as children. These child components render nothing themselves; the root reads them and draws everything with react-native-svg.

Charts animate in when they first render: bars grow from the baseline, lines draw along their path, areas reveal from left to right, pie and radial sectors sweep open and radar shapes grow from the center. When the data changes, shapes animate from their previous values to the new ones.

Colors are theme tokens, not hex values. A series color such as chart-1, chart-2 or primary resolves to the current token color, so charts follow light and dark mode automatically.

For ready-made charts built on it, see the area, bar, line, pie, radar and radial charts.

Installation

$ pnpm dlx shadcn@latest add @esuiss/chart

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

$ pnpm dlx @esuiss/ui@latest add chart
$ pnpm dlx shadcn@latest add @esuiss/chart

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

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

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

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

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

  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-reanimated react-native-svg react-native-worklets
  1. Add the pieces it builds on: Icon, Text.

  2. Copy the primitives it uses into components/primitives:

uniwind/components/primitives/chart.tsx
import * as React from "react"
import {
  type AccessibilityActionEvent,
  Easing,
  type GestureResponderEvent,
  type LayoutChangeEvent,
  type StyleProp,
  StyleSheet,
  type TextStyle,
  View,
  type ViewProps,
} from "react-native"
import { useReducedMotion } from "react-native-reanimated"
import { useHaptics } from "./haptics"

type ChartDatum = Record<string, unknown>
uniwind/components/primitives/haptics.tsx
import * as React from "react"

type HapticsImpactStyle = "light" | "medium" | "heavy" | "soft" | "rigid"

type HapticsNotificationType = "success" | "warning" | "error"

interface HapticsAdapter {
  impact(style: HapticsImpactStyle): void
  selection(): void
  notification(type: HapticsNotificationType): void
}

interface HapticsContextValue {
  adapter: HapticsAdapter | null
  enabled: boolean
}
  1. Copy and paste the following code into components/ui/chart.tsx:
uniwind/components/ui/chart.tsx
import { cn } from "cn"
import type {
  Icon as PhosphorIcon,
  IconProps as PhosphorIconProps,
} from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import Svg, {
  Circle,
  ClipPath,
  Defs,
  LinearGradient,
  Path,
  Rect,
  Stop,
} from "react-native-svg"
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-reanimated react-native-svg react-native-worklets
  1. Add the pieces it builds on: Icon, Text.

  2. Copy the primitives it uses into components/primitives:

nativewind/components/primitives/chart.tsx
import * as React from "react"
import {
  type AccessibilityActionEvent,
  Easing,
  type GestureResponderEvent,
  type LayoutChangeEvent,
  type StyleProp,
  StyleSheet,
  type TextStyle,
  View,
  type ViewProps,
} from "react-native"
import { useReducedMotion } from "react-native-reanimated"
import { useHaptics } from "./haptics"

type ChartDatum = Record<string, unknown>
nativewind/components/primitives/haptics.tsx
import * as React from "react"

type HapticsImpactStyle = "light" | "medium" | "heavy" | "soft" | "rigid"

type HapticsNotificationType = "success" | "warning" | "error"

interface HapticsAdapter {
  impact(style: HapticsImpactStyle): void
  selection(): void
  notification(type: HapticsNotificationType): void
}

interface HapticsContextValue {
  adapter: HapticsAdapter | null
  enabled: boolean
}
  1. Copy and paste the following code into components/ui/chart.tsx:
nativewind/components/ui/chart.tsx
import { cn } from "cn"
import type {
  Icon as PhosphorIcon,
  IconProps as PhosphorIconProps,
} from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import Svg, {
  Circle,
  ClipPath,
  Defs,
  LinearGradient,
  Path,
  Rect,
  Stop,
} from "react-native-svg"
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install phosphor-react-native react-native-reanimated react-native-svg react-native-worklets
  1. Add the pieces it builds on: Icon, Text.

  2. Copy the primitives it uses into components/primitives:

stylesheet/components/primitives/chart.tsx
import * as React from "react"
import {
  type AccessibilityActionEvent,
  Easing,
  type GestureResponderEvent,
  type LayoutChangeEvent,
  type StyleProp,
  StyleSheet,
  type TextStyle,
  View,
  type ViewProps,
} from "react-native"
import { useReducedMotion } from "react-native-reanimated"
import { useHaptics } from "./haptics"

type ChartDatum = Record<string, unknown>
stylesheet/components/primitives/haptics.tsx
import * as React from "react"

type HapticsImpactStyle = "light" | "medium" | "heavy" | "soft" | "rigid"

type HapticsNotificationType = "success" | "warning" | "error"

interface HapticsAdapter {
  impact(style: HapticsImpactStyle): void
  selection(): void
  notification(type: HapticsNotificationType): void
}

interface HapticsContextValue {
  adapter: HapticsAdapter | null
  enabled: boolean
}
  1. Copy and paste the following code into components/ui/chart.tsx:
stylesheet/components/ui/chart.tsx
import type { Icon as PhosphorIcon } from "phosphor-react-native"
import * as React from "react"
import {
  Platform,
  type StyleProp,
  StyleSheet,
  type TextStyle,
  View,
  type ViewStyle,
} from "react-native"
import Svg, {
  Circle,
  ClipPath,
  Defs,
  LinearGradient,
  Path,
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Add the Swift package to your app:

Package.swift
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")
  1. Copy the theme files every view uses:
swift/Theme/Theme.swift
import CoreText
import SwiftUI
import UIKit

struct RGBA: Sendable {
  let red: CGFloat
  let green: CGFloat
  let blue: CGFloat
  let alpha: CGFloat

  init(_ hex: UInt32, _ alpha: CGFloat = 1) {
    red = CGFloat((hex >> 16) & 0xFF) / 255
    green = CGFloat((hex >> 8) & 0xFF) / 255
    blue = CGFloat(hex & 0xFF) / 255
    self.alpha = alpha
  }
swift/Theme/Tokens.swift
import SwiftUI

public enum EsuissColor {
  public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
  public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF))
  public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
  public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
  public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
  public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B))
  public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
  1. Copy the source and every file it uses:
swift/Components/Chart.swift
import Charts
import SwiftUI

public struct ChartConfig: ExpressibleByDictionaryLiteral, Sendable {
  public struct Item: Sendable {
    public var label: String?
    public var color: Color?
    public var icon: Image?

    public init(_ label: String? = nil, color: Color? = nil, icon: Image? = nil) {
      self.label = label
      self.color = color
      self.icon = icon
    }
  }
swift/Components/Haptics.swift
import SwiftUI

extension EnvironmentValues {
  @Entry public var hapticsEnabled = true
}

extension View {
  public func haptics(_ enabled: Bool) -> some View {
    environment(\.hapticsEnabled, enabled)
  }

  func hapticFeedback<Trigger: Equatable>(_ feedback: SensoryFeedback, trigger: Trigger) -> some View {
    modifier(HapticFeedbackModifier(feedback: feedback, trigger: trigger) { _, _ in true })
  }

  func hapticFeedback<Trigger: Equatable>(
swift/Components/Item.swift
import SwiftUI

public enum ItemVariant: CaseIterable, Sendable {
  case `default`, outline, muted
}

public enum ItemSize: CaseIterable, Sendable {
  case `default`, sm, xs

  var horizontalPadding: CGFloat {
    switch self {
    case .default: 16
    case .sm: 14
    case .xs: 12
    }
  }
swift/Components/Separator.swift
import SwiftUI

public struct Separator: View {
  let orientation: Axis

  public init(_ orientation: Axis = .horizontal) {
    self.orientation = orientation
  }

  public var body: some View {
    Rectangle()
      .fill(EsuissColor.border)
      .frame(width: orientation == .vertical ? 1 : nil, height: orientation == .horizontal ? 1 : nil)
      .frame(maxWidth: orientation == .horizontal ? .infinity : nil, maxHeight: orientation == .vertical ? .infinity : nil)
      .accessibilityHidden(true)
  }
  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")
    implementation("com.adamglin:phosphor-icon-android:1.0.0")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
package com.esuiss.ui.theme

import android.content.res.AssetManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
kotlin/theme/Tokens.kt
package com.esuiss.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp

@Immutable
data class Colors(
    val background: Color,
    val foreground: Color,
    val card: Color,
    val cardForeground: Color,
    val popover: Color,
    val popoverForeground: Color,
    val primary: Color,
  1. Copy the source and every file it uses:
kotlin/components/Chart.kt
package com.esuiss.ui.components

import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.Easing
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.BoxWithConstraints
kotlin/components/Content.kt
package com.esuiss.ui.components

import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

val LocalContentStyle = compositionLocalOf { TextStyle.Default }

val LocalContentColor = compositionLocalOf { Color.Unspecified }

val LocalIconSize = compositionLocalOf { 20.dp }
kotlin/components/FormSupport.kt
package com.esuiss.ui.components

import android.provider.Settings
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
kotlin/components/Haptics.kt
package com.esuiss.ui.components

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.hapticfeedback.HapticFeedback
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback

val LocalHapticsEnabled = staticCompositionLocalOf { true }

@Composable
fun ProvideHaptics(enabled: Boolean, content: @Composable () -> Unit) {
    CompositionLocalProvider(LocalHapticsEnabled provides enabled, content = content)
}
kotlin/components/Icon.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Icon(
    imageVector: ImageVector,
  1. Update the com.esuiss.ui package names to match your project.

Usage

import * as React from "react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Bar, BarChart, type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, XAxis } from "@/components/ui/chart"

const monthData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const deviceConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
  mobile: { label: "Mobile", color: "chart-2" },
} satisfies ChartConfig

function StackedTooltipChart({
  title,
  description,
  defaultIndex,
  content,
}: {
  title: string
  description: string
  defaultIndex: number
  content: React.ReactElement
}) {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>{title}</CardTitle>
        <CardDescription>{description}</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={deviceConfig}
          accessibilityLabel={title}
          className="h-52 w-full"
        >
          <BarChart
            data={monthData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={defaultIndex}
              cursor={false}
              content={content}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}

export function ChartTooltipDotExample() {
  return (
    <StackedTooltipChart
      title="Dot indicator"
      description='indicator="dot"'
      defaultIndex={2}
      content={<ChartTooltipContent indicator="dot" />}
    />
  )
}
import * as React from "react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Bar, BarChart, type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, XAxis } from "@/components/ui/chart"

const monthData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
  { month: "April", desktop: 173, mobile: 190 },
  { month: "May", desktop: 209, mobile: 130 },
  { month: "June", desktop: 264, mobile: 140 },
]

const deviceConfig = {
  desktop: { label: "Desktop", color: "chart-1" },
  mobile: { label: "Mobile", color: "chart-2" },
} satisfies ChartConfig

function StackedTooltipChart({
  title,
  description,
  defaultIndex,
  content,
}: {
  title: string
  description: string
  defaultIndex: number
  content: React.ReactElement
}) {
  return (
    <Card variant="filled" size="sm">
      <CardHeader>
        <CardTitle>{title}</CardTitle>
        <CardDescription>{description}</CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer
          config={deviceConfig}
          accessibilityLabel={title}
          style={{ height: 208, width: "100%" }}
        >
          <BarChart
            data={monthData}
            margin={{ top: 70, right: 4, left: 4, bottom: 0 }}
          >
            <XAxis
              dataKey="month"
              tickMargin={8}
              interval={0}
              tickFormatter={(value: string) => value.slice(0, 3)}
            />
            <ChartTooltip
              defaultIndex={defaultIndex}
              cursor={false}
              content={content}
            />
            <Bar
              dataKey="desktop"
              stackId="a"
              radius={[0, 0, 4, 4]}
              maxBarSize={30}
            />
            <Bar
              dataKey="mobile"
              stackId="a"
              radius={[4, 4, 0, 0]}
              maxBarSize={30}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>
  )
}

export function ChartTooltipDotExample() {
  return (
    <StackedTooltipChart
      title="Dot indicator"
      description='indicator="dot"'
      defaultIndex={2}
      content={<ChartTooltipContent indicator="dot" />}
    />
  )
}
import Charts
import SwiftUI

struct ChartTooltipDotExample: View {
  var body: some View {
    ChartStackedTooltip(title: "Dot indicator", description: "indicator=\"dot\"", defaultIndex: 2) { payload in
      ChartTooltipContent(payload, indicator: .dot)
    }
  }
}

let chartMonthData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
  ("May", 209, 130),
  ("June", 264, 140),
]

let chartDevices: ChartConfig = [
  "desktop": .init("Desktop", color: Palette.blue500),
  "mobile": .init("Mobile", color: Palette.teal500),
]

struct ChartStackedTooltip<Tooltip: View>: View {
  let title: String
  let description: String
  var config = chartDevices
  let defaultIndex: Int
  @ViewBuilder let tooltip: (ChartTooltipPayload) -> Tooltip

  var body: some View {
    Card(.filled, size: .sm) {
      CardHeader(LocalizedStringKey(title), description: LocalizedStringKey(description))
      CardContent {
        ChartContainer(config: config) {
          ChartAnimator(animationDuration: 400) { progress in
            Chart {
              ForEach(chartMonthData.indices, id: \.self) { index in
                let item = chartMonthData[index]
                BarMark(
                  x: .value("Month", item.month),
                  yStart: .value("Start", 0),
                  yEnd: .value("Desktop", item.desktop * progress),
                  width: .fixed(30)
                )
                .clipShape(UnevenRoundedRectangle(bottomLeadingRadius: 4, bottomTrailingRadius: 4, style: .continuous))
                .foregroundStyle(config.color("desktop"))
                BarMark(
                  x: .value("Month", item.month),
                  yStart: .value("Start", item.desktop * progress),
                  yEnd: .value("Mobile", (item.desktop + item.mobile) * progress),
                  width: .fixed(30)
                )
                .clipShape(UnevenRoundedRectangle(topLeadingRadius: 4, topTrailingRadius: 4, style: .continuous))
                .foregroundStyle(config.color("mobile"))
                ChartAnchorMark(x: .value("Month", item.month), y: .value("Mobile", item.desktop + item.mobile))
              }
            }
            .chartYScale(range: .plotDimension(endPadding: 70))
            .chartXAxis { ChartAxis.x(values: chartMonthData.map(\.month)) { String($0.prefix(3)) } }
            .chartYAxis(.hidden)
            .chartTooltip(
              x: chartMonthData.map(\.month),
              defaultIndex: defaultIndex,
              cursor: false,
              accessibilityLabel: title,
              items: { index in
                [
                  ChartTooltipItem("desktop", value: chartMonthData[index].desktop),
                  ChartTooltipItem("mobile", value: chartMonthData[index].mobile),
                ]
              },
              content: tooltip
            )
          }
        }
        .frame(height: 208)
      }
    }
  }
}
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.phosphoricons.regular.Desktop
import com.esuiss.ui.components.BarChart
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartMargin
import com.esuiss.ui.components.ChartRadius
import com.esuiss.ui.components.ChartTooltipContent
import com.esuiss.ui.components.ChartTooltipIndicator
import com.esuiss.ui.components.ChartTooltipScope

@Composable
fun ChartTooltipDotExample() {
    ChartStackedTooltip("Dot indicator", "indicator=\"dot\"", 2) { ChartTooltipContent(indicator = ChartTooltipIndicator.Dot) }
}

class ChartMonth(val month: String, val desktop: Double, val mobile: Double)

val chartMonthData = listOf(
    ChartMonth("January", 186.0, 80.0),
    ChartMonth("February", 305.0, 200.0),
    ChartMonth("March", 237.0, 120.0),
    ChartMonth("April", 173.0, 190.0),
    ChartMonth("May", 209.0, 130.0),
    ChartMonth("June", 264.0, 140.0),
)

val chartDeviceConfig = ChartConfig(
    "desktop" to ChartConfigItem("Desktop") { chart1 },
    "mobile" to ChartConfigItem("Mobile") { chart2 },
)

@Composable
fun ChartTooltipCard(title: String, description: String, content: @Composable () -> Unit) {
    Card(variant = CardVariant.Filled, size = CardSize.Sm) {
        CardHeader(title, description = description)
        CardContent { content() }
    }
}

@Composable
fun ChartStackedTooltip(
    title: String,
    description: String,
    defaultIndex: Int,
    config: ChartConfig = chartDeviceConfig,
    tooltip: @Composable ChartTooltipScope.() -> Unit,
) {
    ChartTooltipCard(title, description) {
        ChartContainer(config, Modifier.fillMaxWidth().height(208.dp)) {
            BarChart(
                chartMonthData,
                margin = ChartMargin(top = 70.dp, right = 4.dp, bottom = 0.dp, left = 4.dp),
                accessibilityLabel = title,
            ) {
                XAxis(label = { it.month }, tickMargin = 8.dp, interval = 0, tickFormatter = { it.take(3) })
                ChartTooltip(defaultIndex = defaultIndex, cursor = null, content = tooltip)
                Bar("desktop", value = { it.desktop }, stackId = "a", radius = ChartRadius(0.dp, 0.dp, 4.dp, 4.dp), maxBarSize = 30.dp)
                Bar("mobile", value = { it.mobile }, stackId = "a", radius = ChartRadius(4.dp, 4.dp, 0.dp, 0.dp), maxBarSize = 30.dp)
            }
        }
    }
}

Examples

Tooltip line

Set indicator to line on the tooltip content.

React Native
Chart tooltip line in React Native, light modeChart tooltip line in React Native, dark mode
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import Charts
import SwiftUI

struct ChartTooltipLineExample: View {
  var body: some View {
    ChartStackedTooltip(title: "Line indicator", description: "indicator=\"line\"", defaultIndex: 2) { payload in
      ChartTooltipContent(payload, indicator: .line)
    }
  }
}

let chartMonthData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.phosphoricons.regular.Desktop
import com.esuiss.ui.components.BarChart
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartMargin

Tooltip dashed

Set indicator to dashed on the tooltip content.

React Native
Chart tooltip dashed in React Native, light modeChart tooltip dashed in React Native, dark mode
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import Charts
import SwiftUI

struct ChartTooltipDashedExample: View {
  var body: some View {
    ChartStackedTooltip(title: "Dashed indicator", description: "indicator=\"dashed\"", defaultIndex: 2) { payload in
      ChartTooltipContent(payload, indicator: .dashed)
    }
  }
}

let chartMonthData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.phosphoricons.regular.Desktop
import com.esuiss.ui.components.BarChart
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartMargin

Tooltip no indicator

Hide the indicator to show only names and values.

React Native
Chart tooltip no indicator in React Native, light modeChart tooltip no indicator in React Native, dark mode
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import Charts
import SwiftUI

struct ChartTooltipNoIndicatorExample: View {
  var body: some View {
    ChartStackedTooltip(title: "No indicator", description: "Just the name and value", defaultIndex: 2) { payload in
      ChartTooltipContent(payload, hideIndicator: true)
    }
  }
}

let chartMonthData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.phosphoricons.regular.Desktop
import com.esuiss.ui.components.BarChart
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartMargin

Tooltip no label

Hide the category label of the tooltip.

React Native
Chart tooltip no label in React Native, light modeChart tooltip no label in React Native, dark mode
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import Charts
import SwiftUI

struct ChartTooltipNoLabelExample: View {
  var body: some View {
    ChartStackedTooltip(title: "No label", description: "The month is hidden", defaultIndex: 2) { payload in
      ChartTooltipContent(payload, hideLabel: true)
    }
  }
}

let chartMonthData: [(month: String, desktop: Double, mobile: Double)] = [
  ("January", 186, 80),
  ("February", 305, 200),
  ("March", 237, 120),
  ("April", 173, 190),
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.phosphoricons.regular.Desktop
import com.esuiss.ui.components.BarChart
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer
import com.esuiss.ui.components.ChartMargin

Tooltip label formatter

A formatted date as the tooltip label, set with labelFormatter.

React Native
Chart tooltip label formatter in React Native, light modeChart tooltip label formatter in React Native, dark mode
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Area,
  AreaChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Area,
  AreaChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
} from "@/components/ui/chart"
import Charts
import SwiftUI

@MainActor let chartEnglish = Locale(identifier: "en_US")

let chartEnergyValues: [Double] = [512, 604, 455, 389, 662, 598, 431, 520, 690, 447, 575, 402, 633, 558]

let chartEnergyConfig: ChartConfig = [
  "energy": .init("Active energy", color: Palette.red500),
]

func chartDate(year: Int, month: Int, day: Int) -> Date {
  let calendar = Foundation.Calendar(identifier: .gregorian)
  let first = calendar.date(from: DateComponents(year: year, month: month, day: 1)) ?? .now
  return calendar.date(byAdding: .day, value: day - 1, to: first) ?? first
}
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.AreaChart
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig
import com.esuiss.ui.components.ChartConfigItem
import com.esuiss.ui.components.ChartContainer

Tooltip formatter

Custom value formatting with formatter.

React Native
Chart tooltip formatter in React Native, light modeChart tooltip formatter in React Native, dark mode
import { View } from "react-native"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
import { View } from "react-native"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
import Charts
import SwiftUI

@MainActor let chartEnglish = Locale(identifier: "en_US")

let chartEnergyValues: [Double] = [512, 604, 455, 389, 662, 598, 431, 520, 690, 447, 575, 402, 633, 558]

let chartEnergyConfig: ChartConfig = [
  "energy": .init("Active energy", color: Palette.red500),
]

func chartDate(year: Int, month: Int, day: Int) -> Date {
  let calendar = Foundation.Calendar(identifier: .gregorian)
  let first = calendar.date(from: DateComponents(year: year, month: month, day: 1)) ?? .now
  return calendar.date(byAdding: .day, value: day - 1, to: first) ?? first
}
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.BarChart
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig

Tooltip icons

Icons from the config in place of color indicators.

React Native
Chart tooltip icons in React Native, light modeChart tooltip icons in React Native, dark mode
import { DesktopIcon, DeviceMobileIcon } from "phosphor-react-native"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
import { DesktopIcon, DeviceMobileIcon } from "phosphor-react-native"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
import Charts
import PhosphorSwift
import SwiftUI

struct ChartTooltipIconsExample: View {
  var body: some View {
    ChartStackedTooltip(
      title: "With icons",
      description: "An icon instead of a color",
      config: chartDeviceIcons,
      defaultIndex: 3
    ) { payload in
      ChartTooltipContent(payload)
    }
  }
}
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.Desktop
import com.adamglin.phosphoricons.regular.DeviceMobile
import com.esuiss.ui.components.BarChart
import com.esuiss.ui.components.Card
import com.esuiss.ui.components.CardContent
import com.esuiss.ui.components.CardHeader
import com.esuiss.ui.components.CardSize
import com.esuiss.ui.components.CardVariant
import com.esuiss.ui.components.ChartConfig

Tooltip custom

A fully custom tooltip rendered from a function.

React Native
Chart tooltip custom in React Native, light modeChart tooltip custom in React Native, dark mode
import { View } from "react-native"
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Bar,
  BarChart,
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  XAxis,
} from "@/components/ui/chart"

This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.

import Charts
import SwiftUI

@MainActor let chartEnglish = Locale(identifier: "en_US")

struct ChartCustomDemo: View {
  let steps: [(day: String, steps: Double)] = [
    ("Monday", 8412),
    ("Tuesday", 10230),
    ("Wednesday", 6120),
    ("Thursday", 12480),
    ("Friday", 9050),
    ("Saturday", 14320),
    ("Sunday", 4870),
  ]
  let config: ChartConfig = ["steps": .init("Steps", color: Palette.orange500)]
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.BarChart
import com.esuiss.ui.components.Card

Tooltip interactive

Settings that change the tooltip on a stacked bar chart with a legend.

React Native
Chart tooltip interactive in React Native, light modeChart tooltip interactive in React Native, dark mode
import * as React from "react"
import { View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  Bar,
  BarChart,
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import * as React from "react"
import { View } from "react-native"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import {
  Bar,
  BarChart,
  CartesianGrid,
  type ChartConfig,
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartTooltip,
  ChartTooltipContent,
  XAxis,
  YAxis,
} from "@/components/ui/chart"
import Charts
import SwiftUI

struct ChartInteractiveDemo: View {
  let quarters: [(quarter: String, phones: Double, laptops: Double, services: Double)] = [
    ("Q1 25", 69.1, 9, 26.3),
    ("Q2 25", 46.8, 8, 26.6),
    ("Q3 25", 44.6, 8, 27.4),
    ("Q4 25", 46.2, 8.7, 28.8),
    ("Q1 26", 71, 9.5, 29.1),
    ("Q2 26", 49.4, 8.6, 29.4),
    ("Q3 26", 47.3, 8.9, 30.1),
    ("Q4 26", 49, 9.3, 31.2),
  ]
  let config: ChartConfig = [
    "phones": .init("Phones", color: Palette.blue500),
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.contentDescription

Accessibility

  • The chart is one accessible element labelled with its series names and data range; pass accessibilityLabel to ChartContainer to override the names.
  • With a tooltip it has the adjustable role: VoiceOver and TalkBack swipe actions step through data points, and the selected values are announced as the value text.
  • Without a tooltip it has the image role.
  • With Reduce Motion on, charts skip the enter and update animations and draw in their final state.

API Reference

ChartPalette

Resolves token colors to concrete values.

PropTypeDefault
colorsreadonly ChartColor[]Required
children(palette: Partial<Record<ChartColor, string>>) => React.ReactNodeRequired

Pass the token colors to resolve, and a function as children that receives the resolved colors for custom drawing. useChart() returns the config inside a container.

ChartContainer

Sizes the chart and provides the config.

PropTypeDefault
configChartConfigRequired

Also accepts the props of ChartPrimitive.ContainerProps.

Describe each series in a ChartConfig object with a label, a token color and an optional icon, keyed by data key. Series colors accept chart-1 to chart-5, theme colors such as primary, destructive and foreground, and palette colors such as green-500 and red-500. The container is full width with a 16:9 aspect ratio unless you give it an h-, size- or aspect- class.

Line, Area, Bar, Pie, RadialBar and Radar take isAnimationActive, animationDuration and animationEasing. Bars default to 400 ms and curves, sectors and radar shapes to 1500 ms, with ease easing. Set isAnimationActive={false} to draw a series in its final state, for example when its data changes on every interaction. Value labels from LabelList and pie label appear once a series finishes animating.

LineChart

Cartesian chart for Line series.

Takes data, margin, onActiveIndexChange and children from ChartPrimitive.RootProps.

AreaChart

Cartesian chart for Area series, with optional stacking.

Takes data, margin, stackOffset, onActiveIndexChange and children from ChartPrimitive.RootProps.

BarChart

Cartesian chart for Bar series, vertical or horizontal.

Takes data, margin, layout, barGap, barCategoryGap, onActiveIndexChange and children from ChartPrimitive.RootProps.

ComposedChart

Cartesian chart that mixes lines, areas and bars.

Takes data, margin, onActiveIndexChange and children from ChartPrimitive.RootProps.

PieChart

Pie and donut charts built from Pie.

Takes margin, onActiveIndexChange and children from ChartPrimitive.RootProps.

RadialBarChart

Circular bars built from RadialBar.

Takes data, margin, innerRadius, outerRadius, startAngle, endAngle, barSize, cx, cy, onActiveIndexChange and children from ChartPrimitive.RootProps.

RadarChart

Polar chart built from Radar and PolarGrid.

Takes data, margin, outerRadius, cy, onActiveIndexChange and children from ChartPrimitive.RootProps.

ChartTooltipContent

Default tooltip card.

PropTypeDefault
classNamestring-
indicator"line" | "dot" | "dashed""dot"
hideLabelbooleanfalse
hideIndicatorbooleanfalse
nameKeystring-
labelFormatter( label: React.ReactNode, payload: ChartPrimitive.TooltipItem[] ) => React.ReactNode-
formatter( value: ChartPrimitive.ChartValue, name: string, item: ChartPrimitive.TooltipItem, index: number, payload: ChartPrimitive.ChartDatum ) => React.ReactNode-

Add ChartTooltip with content={<ChartTooltipContent />} to make the chart respond to touch: touching or dragging selects the nearest data point, draws a cursor and shows the tooltip, with a selection haptic. Use defaultIndex on ChartTooltip to start with a point selected, or onActiveIndexChange on the chart to react to selection. labelFormatter formats the label, formatter renders each row yourself, and nameKey is the data key used to look up series names in the config.

ChartLegendContent

Default legend with swatches or icons.

PropTypeDefault
classNamestring-
nameKeystring-

Add ChartLegend with content={<ChartLegendContent />} for a legend in config order. nameKey is the data key used to look up legend names in the config.

ChartConfig

ParameterTypeDefault
_ elements[(String, Item)]-
dictionaryLiteral(String, Item)...-

Overloads: init(_:), init(dictionaryLiteral:).

PropertyType
keys[String]

ChartConfig.label

ParameterTypeDefault
_ keyString-

Returns String.

ChartConfig.color

ParameterTypeDefault
_ keyString-

Returns Color.

ChartContainer

Sizes the chart and provides the config.

ParameterTypeDefault
configChartConfig-
content() -> Content-

ChartAnimationEasing

Values: .ease, .easeIn, .easeOut, .easeInOut, .linear.

ChartAnimator

ParameterTypeDefault
isAnimationActiveBooltrue
animationDurationDouble1500
animationEasingChartAnimationEasing: .ease | .easeIn | .easeOut | .easeInOut | .linear.ease
content(Double) -> Content-

ChartAnchorMark

ParameterTypeDefault
xPlottableValue<X>-
yPlottableValue<Y>-

ChartSectorRest

ParameterTypeDefault
totalDouble-
progressDouble-

ChartTooltipItem

ParameterTypeDefault
_ keyString-
valueDouble-
colorColor?nil
PropertyType
keyString
valueDouble
colorColor?
idString

ChartTooltipPayload

ParameterTypeDefault
indexInt-
labelString-
items[ChartTooltipItem]-
PropertyType
indexInt
labelString
items[ChartTooltipItem]
totalDouble

ChartTooltipIndicator

Values: .dot, .line, .dashed.

ChartTooltipContent

Default tooltip card.

ParameterTypeDefault
_ payloadChartTooltipPayload-
indicatorChartTooltipIndicator: .dot | .line | .dashed.dot
hideLabelBoolfalse
hideIndicatorBoolfalse
labelFormatter(ChartTooltipPayload) -> LabelContent-
formatter(ChartTooltipItem) -> ValueContent-

Overloads: init(_:indicator:hideLabel:hideIndicator:labelFormatter:formatter:), init(_:indicator:hideLabel:hideIndicator:formatter:), init(_:indicator:hideLabel:hideIndicator:labelFormatter:), init(_:indicator:hideLabel:hideIndicator:).

ChartLegendContent

Default legend with swatches or icons.

ParameterTypeDefault
keys[String]?nil
hideIconBoolfalse

.chartTooltip

ParameterTypeDefault
x[Value]-
labels[String]?nil
selectionBinding<Int?>?nil
defaultIndexInt?nil
cursorBooltrue
stickyBooltrue
accessibilityLabelString?nil
items(Int) -> [ChartTooltipItem]-
content(ChartTooltipPayload) -> Tooltip-
y[Value]-
angle[Double]-
startAngleAngle.zero
endAngleAngle.degrees(360)
innerRadiusCGFloat0
outerRadiusCGFloat1

Overloads: chartTooltip(x:labels:selection:defaultIndex:cursor:sticky:accessibilityLabel:items:content:), chartTooltip(y:labels:selection:defaultIndex:sticky:accessibilityLabel:items:content:), chartTooltip(angle:labels:startAngle:endAngle:innerRadius:outerRadius:selection:defaultIndex:sticky:accessibilityLabel:items:content:).

RadialBar

ParameterTypeDefault
_ keyString-
valueDouble-
colorColor?nil
PropertyType
keyString
valueDouble
colorColor?
idString

RadialBarTrack

Values: .none, .control, .tint.

RadialBarChart

Circular bars built from RadialBar.

ParameterTypeDefault
_ bars[RadialBar]-
domainClosedRange<Double>?nil
innerRadiusCGFloat0
outerRadiusCGFloat0.8
barSizeCGFloat?nil
startAngleAngle.degrees(90)
endAngleAngle.degrees(-270)
roundedBoolfalse
trackRadialBarTrack: .none | .control | .tint.none
showsLabelsBoolfalse
selectionBinding<Int?>?nil
defaultIndexInt?nil
stickyBooltrue
accessibilityLabelString?nil
isAnimationActiveBooltrue
animationDurationDouble1500
animationEasingChartAnimationEasing: .ease | .easeIn | .easeOut | .easeInOut | .linear.ease
tooltip(ChartTooltipPayload) -> Tooltip-

Overloads: init(_:domain:innerRadius:outerRadius:barSize:startAngle:endAngle:rounded:track:showsLabels:selection:defaultIndex:sticky:accessibilityLabel:isAnimationActive:animationDuration:animationEasing:tooltip:), init(_:domain:innerRadius:outerRadius:barSize:startAngle:endAngle:rounded:track:isAnimationActive:animationDuration:animationEasing:).

PolarGridType

Values: .polygon, .circle.

PolarGrid

ParameterTypeDefault
gridTypePolarGridType: .polygon | .circle.polygon
strokeColorEsuissColor.border
strokeWidthCGFloat1
fillColor?nil
fillOpacityDouble1
PropertyType
gridTypePolarGridType
strokeColor
strokeWidthCGFloat
fillColor?
fillOpacityDouble

PolarAngleAxis

ParameterTypeDefault
textStyleTextStyle.xs
highlightsSelectionBoolfalse
PropertyType
textStyleTextStyle
highlightsSelectionBool

PolarRadiusAxis

ParameterTypeDefault
angleAngle-
tickCountInt5
PropertyType
angleAngle
tickCountInt

Radar

ParameterTypeDefault
_ keyString-
values[Double]-
colorColor?nil
fillOpacityDouble0.3
strokeWidthCGFloat2
strokeOpacityDouble1
dotCGFloat?nil
PropertyType
keyString
values[Double]
colorColor?
fillOpacityDouble
strokeWidthCGFloat
strokeOpacityDouble
dotCGFloat?
idString

RadarChart

Polar chart built from Radar and PolarGrid.

ParameterTypeDefault
_ series[Radar]-
labels[String]-
domainClosedRange<Double>?nil
outerRadiusCGFloat0.8
centerUnitPoint.center
marginEdgeInsetsEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5)
gridPolarGrid?PolarGrid()
angleAxisPolarAngleAxisPolarAngleAxis()
radiusAxisPolarRadiusAxis?nil
selectionBinding<Int?>?nil
defaultIndexInt?nil
stickyBooltrue
accessibilityLabelString?nil
items((Int) -> [ChartTooltipItem])?nil
isAnimationActiveBooltrue
animationDurationDouble1500
animationEasingChartAnimationEasing: .ease | .easeIn | .easeOut | .easeInOut | .linear.ease
tooltip(ChartTooltipPayload) -> Tooltip-

ChartConfigItem

ParameterTypeDefault
labelString?null
iconImageVector?null
color(Colors.() -> Color)?null

ChartConfig

ParameterTypeDefault
itemsvararg Pair<String, ChartConfigItem>-
PropertyType
keysList<String> get()

ChartConfig.get

ParameterTypeDefault
keyString-

Returns ChartConfigItem?.

ChartContainer

Sizes the chart and provides the config.

ParameterTypeDefault
configChartConfig-
modifierModifierModifier
content@Composable BoxScope.() -> Unit-

chartColor

ParameterTypeDefault
keyString-

Returns Color.

ChartCurve

Values: Natural, Monotone, Linear, Step.

ChartLayout

Values: Horizontal, Vertical.

ChartStackOffset

Values: None, Expand.

ChartAxisOrientation

Values: Left, Right.

ChartTooltipIndicator

Values: Dot, Line, Dashed.

ChartLabelPosition

Values: Top, InsideStart.

ChartEasing

Values: Ease, EaseIn, EaseOut, EaseInOut, Linear.

ChartMargin

ParameterTypeDefault
topDp5.dp
rightDp5.dp
bottomDp5.dp
leftDp5.dp

ChartDot

ParameterTypeDefault
radiusDp-
colorColor?null
strokeColorColor?null
strokeWidthDp0.dp

ChartRadius

ParameterTypeDefault
topStartDp-
topEndDp-
bottomEndDp-
bottomStartDp-

ChartCell

ParameterTypeDefault
colorColor?null
alphaFloat1f

ChartCursor

ParameterTypeDefault
colorColor?null
widthDp1.dp

ChartSector

ParameterTypeDefault
liftDp0.dp
ringChartRing?null

ChartRing

ParameterTypeDefault
gapDp-
widthDp-

ChartLabelList

ParameterTypeDefault
positionChartLabelPosition: Top | InsideStartChartLabelPosition.Top
offsetDp5.dp
colorColor?null
fontSizeTextUnit12.sp
formatter((index: Int, value: Double) -> String)?null

ChartFill

ValueParameters
Solidcolor: Color? = null, alpha: Float = 1f
VerticalGradientcolor: Color? = null, topAlpha: Float, bottomAlpha: Float
HorizontalGradientstops: List<Pair<Float, Color>>

ChartTooltipContent

Default tooltip card.

Receiver: ChartTooltipScope.

ParameterTypeDefault
modifierModifierModifier
indicatorChartTooltipIndicator: Dot | Line | DashedChartTooltipIndicator.Dot
hideLabelBooleanfalse
hideIndicatorBooleanfalse
labelFormatter(@Composable (label: String, items: List<ChartTooltipItem>) -> Unit)?null
formatter(@Composable RowScope.(item: ChartTooltipItem) -> Unit)?null
colorColor?null
payloadList<ChartTooltipItem>items

ChartLegendContent

Default legend with swatches or icons.

ParameterTypeDefault
keysList<String>-
modifierModifierModifier
hideIconBooleanfalse

CartesianChartScope.CartesianGrid

ParameterTypeDefault
strokeDasharrayList<Float>?null

CartesianChartScope.XAxis

ParameterTypeDefault
label(T) -> String-
hideBooleanfalse
tickMarginDp2.dp
intervalInt?null
ticksList<Int>?null
minTickGapDp5.dp
tickFormatter((String) -> String)?null
domainClosedFloatingPointRange<Double>?null

Overloads: XAxis(label, hide, tickMargin, interval, ticks, minTickGap, tickFormatter), XAxis(domain).

CartesianChartScope.YAxis

ParameterTypeDefault
orientationChartAxisOrientation: Left | RightChartAxisOrientation.Left
hideBooleanfalse
tickMarginDp2.dp
widthDp?null
domainClosedFloatingPointRange<Double>?null
ticksList<Double>?null
tickCountInt5
tickFormatter((Double) -> String)?null
label(T) -> String-
tickStyleTextStyle?null

Overloads: YAxis(hide, domain, ticks, tickCount), YAxis(label, tickStyle).

CartesianChartScope.Line

ParameterTypeDefault
dataKeyString-
value(T) -> Double?-
curveChartCurve: Natural | Monotone | Linear | StepChartCurve.Linear
strokeColor?null
strokeWidthDp1.dp
strokeDasharrayList<Float>?null
dotChartDot?null
dotColor((T) -> Color)?null
activeDotChartDot?ChartDot(4.dp)
labelListChartLabelList?null
isAnimationActiveBooleantrue
animationDurationInt1500
animationEasingChartEasing: Ease | EaseIn | EaseOut | EaseInOut | LinearChartEasing.Ease

CartesianChartScope.Area

ParameterTypeDefault
dataKeyString-
value(T) -> Double?-
base((T) -> Double)?null
curveChartCurve: Natural | Monotone | Linear | StepChartCurve.Linear
strokeColor?null
strokeWidthDp1.dp
fillChartFillChartFill.Solid(alpha = 0.6f)
stackIdString?null
dotChartDot?null
activeDotChartDot?ChartDot(4.dp)
isAnimationActiveBooleantrue
animationDurationInt1500
animationEasingChartEasing: Ease | EaseIn | EaseOut | EaseInOut | LinearChartEasing.Ease

CartesianChartScope.Bar

ParameterTypeDefault
dataKeyString-
value(T) -> Double?-
base((T) -> Double)?null
fillChartFillChartFill.Solid()
radiusChartRadiusChartRadius(0.dp)
barSizeDp?null
maxBarSizeDp?null
stackIdString?null
nameKey((T) -> String)?null
cells((Int) -> ChartCell)?null
backgroundColor?null
labelListChartLabelList?null
isAnimationActiveBooleantrue
animationDurationInt400
animationEasingChartEasing: Ease | EaseIn | EaseOut | EaseInOut | LinearChartEasing.Ease

CartesianChartScope.ReferenceLine

ParameterTypeDefault
yDouble-
strokeColor?null
strokeDasharrayList<Float>?null
labelString?null

CartesianChartScope.ReferenceArea

ParameterTypeDefault
x1Int-
x2Int-
fillColor?null
fillOpacityFloat0.5f

CartesianChartScope.ChartTooltip

ParameterTypeDefault
defaultIndexInt?null
cursorChartCursor?ChartCursor()
content@Composable ChartTooltipScope.() -> Unit{ ChartTooltipContent() }

CartesianChartScope.ChartLegend

ParameterTypeDefault
hideIconBooleanfalse

LineChart

Cartesian chart for Line series.

ParameterTypeDefault
dataList<T>-
modifierModifierModifier
marginChartMarginChartMargin()
accessibilityLabelString?null
selectedIndexInt?null
onSelectedIndexChange((Int?) -> Unit)?null
contentCartesianChartScope<T>.() -> Unit-

AreaChart

Cartesian chart for Area series, with optional stacking.

ParameterTypeDefault
dataList<T>-
modifierModifierModifier
marginChartMarginChartMargin()
stackOffsetChartStackOffset: None | ExpandChartStackOffset.None
accessibilityLabelString?null
selectedIndexInt?null
onSelectedIndexChange((Int?) -> Unit)?null
contentCartesianChartScope<T>.() -> Unit-

BarChart

Cartesian chart for Bar series, vertical or horizontal.

ParameterTypeDefault
dataList<T>-
modifierModifierModifier
marginChartMarginChartMargin()
layoutChartLayout: Horizontal | VerticalChartLayout.Horizontal
barGapDp4.dp
barCategoryGapDp?null
accessibilityLabelString?null
selectedIndexInt?null
onSelectedIndexChange((Int?) -> Unit)?null
contentCartesianChartScope<T>.() -> Unit-

ComposedChart

Cartesian chart that mixes lines, areas and bars.

ParameterTypeDefault
dataList<T>-
modifierModifierModifier
marginChartMarginChartMargin()
accessibilityLabelString?null
selectedIndexInt?null
onSelectedIndexChange((Int?) -> Unit)?null
contentCartesianChartScope<T>.() -> Unit-

PieChartScope.Pie

ParameterTypeDefault
dataList<T>-
value(T) -> Double-
nameKey(T) -> String-
innerRadiusFloat0f
outerRadiusFloat0.8f
cxFloat0.5f
cyFloat0.5f
startAngleFloat0f
endAngleFloat360f
paddingAngleFloat0f
cornerRadiusDp0.dp
strokeColor?null
strokeWidthDp1.dp
fillOpacityFloat1f
cells((Int) -> ChartCell)?null
sectors((Int) -> ChartSector)?null
label((Int) -> String)?null
labelLineColor?null
isAnimationActiveBooleantrue
animationDurationInt1500
animationEasingChartEasing: Ease | EaseIn | EaseOut | EaseInOut | LinearChartEasing.Ease

PieChartScope.ChartTooltip

ParameterTypeDefault
defaultIndexInt?null
content@Composable ChartTooltipScope.() -> Unit{ ChartTooltipContent() }

PieChartScope.ChartLegend

ParameterTypeDefault
hideIconBooleanfalse

RadialBarChartScope.PolarAngleAxis

ParameterTypeDefault
domainClosedFloatingPointRange<Double>-

RadialBarChartScope.RadialBar

ParameterTypeDefault
dataKeyString-
value(T) -> Double-
nameKey((T) -> String)?null
fillColor?null
cornerRadiusDp0.dp
backgroundColor?null
stackIdString?null
strokeColor?null
strokeWidthDp0.dp
cells((Int) -> ChartCell)?null
labelListChartLabelList?null
isAnimationActiveBooleantrue
animationDurationInt1500
animationEasingChartEasing: Ease | EaseIn | EaseOut | EaseInOut | LinearChartEasing.Ease

RadialBarChartScope.ChartTooltip

ParameterTypeDefault
defaultIndexInt?null
content@Composable ChartTooltipScope.() -> Unit{ ChartTooltipContent() }

RadialBarChartScope.ChartLegend

ParameterTypeDefault
hideIconBooleanfalse

PieChart

Pie and donut charts built from Pie.

ParameterTypeDefault
modifierModifierModifier
marginChartMarginChartMargin()
accessibilityLabelString?null
selectedIndexInt?null
onSelectedIndexChange((Int?) -> Unit)?null
contentPieChartScope.() -> Unit-

RadialBarChart

Circular bars built from RadialBar.

ParameterTypeDefault
dataList<T>-
modifierModifierModifier
marginChartMarginChartMargin()
innerRadiusFloat0f
outerRadiusFloat0.8f
cxFloat0.5f
cyFloat0.5f
startAngleFloat0f
endAngleFloat360f
barSizeDp?null
accessibilityLabelString?null
selectedIndexInt?null
onSelectedIndexChange((Int?) -> Unit)?null
contentRadialBarChartScope<T>.() -> Unit-

PolarGridType

Values: Polygon, Circle.

RadarChartScope.PolarGrid

ParameterTypeDefault
gridTypePolarGridType: Polygon | CirclePolarGridType.Polygon
strokeColor?null
strokeWidthDp1.dp
fillColor?null
fillOpacityFloat1f

RadarChartScope.PolarAngleAxis

ParameterTypeDefault
label(T) -> String-
tickStyleTextStyle?null
activeTickStyleTextStyle?null

RadarChartScope.PolarRadiusAxis

ParameterTypeDefault
angleFloat0f
domainClosedFloatingPointRange<Double>?null
tickCountInt5
tickBooleantrue
tickStyleTextStyle?null

RadarChartScope.Radar

ParameterTypeDefault
dataKeyString-
value(T) -> Double-
fillColor?null
fillOpacityFloat1f
strokeColor?null
strokeWidthDp1.dp
strokeOpacityFloat1f
dotChartDot?null
activeDotChartDot?ChartDot(4.dp)
isAnimationActiveBooleantrue
animationDurationInt1500
animationEasingChartEasing: Ease | EaseIn | EaseOut | EaseInOut | LinearChartEasing.Ease

RadarChartScope.ChartTooltip

ParameterTypeDefault
defaultIndexInt?null
cursorChartCursor?ChartCursor()
content@Composable ChartTooltipScope.() -> Unit{ ChartTooltipContent() }

RadarChartScope.ChartLegend

ParameterTypeDefault
hideIconBooleanfalse

RadarChart

Polar chart built from Radar and PolarGrid.

ParameterTypeDefault
dataList<T>-
modifierModifierModifier
marginChartMarginChartMargin()
outerRadiusFloat0.8f
cyFloat0.5f
accessibilityLabelString?null
selectedIndexInt?null
onSelectedIndexChange((Int?) -> Unit)?null
contentRadarChartScope<T>.() -> Unit-
NextCheckboxPreviousCarousel

On this page

  1. 01Installation
  2. 02Usage
  3. 03Examples
    • Multiple series
    • Stacked
    • Line series
    • Area series
    • Donut
  4. 04Accessibility
  5. 05API Reference
    • ChartContainer
    • ChartTooltipContent
    • ChartLegendContent
  6. 06Installation
  7. 07Usage
  8. 08Examples
    • Tooltip line
    • Tooltip dashed
    • Tooltip no indicator
    • Tooltip no label
    • Tooltip label formatter
    • Tooltip formatter
    • Tooltip icons
    • Tooltip custom
    • Tooltip interactive
  9. 09Accessibility
  10. 10API Reference
    • ChartPalette
    • ChartContainer
    • LineChart
    • AreaChart
    • BarChart
    • ComposedChart
    • PieChart
    • RadialBarChart
    • RadarChart
    • ChartTooltipContent
    • ChartLegendContent
    • ChartConfig
    • ChartConfig.label
    • ChartConfig.color
    • ChartContainer
    • ChartAnimationEasing
    • ChartAnimator
    • ChartAnchorMark
    • ChartSectorRest
    • ChartTooltipItem
    • ChartTooltipPayload
    • ChartTooltipIndicator
    • ChartTooltipContent
    • ChartLegendContent
    • .chartTooltip
    • RadialBar
    • RadialBarTrack
    • RadialBarChart
    • PolarGridType
    • PolarGrid
    • PolarAngleAxis
    • PolarRadiusAxis
    • Radar
    • RadarChart
    • ChartConfigItem
    • ChartConfig
    • ChartConfig.get
    • ChartContainer
    • chartColor
    • ChartCurve
    • ChartLayout
    • ChartStackOffset
    • ChartAxisOrientation
    • ChartTooltipIndicator
    • ChartLabelPosition
    • ChartEasing
    • ChartMargin
    • ChartDot
    • ChartRadius
    • ChartCell
    • ChartCursor
    • ChartSector
    • ChartRing
    • ChartLabelList
    • ChartFill
    • ChartTooltipContent
    • ChartLegendContent
    • CartesianChartScope.CartesianGrid
    • CartesianChartScope.XAxis
    • CartesianChartScope.YAxis
    • CartesianChartScope.Line
    • CartesianChartScope.Area
    • CartesianChartScope.Bar
    • CartesianChartScope.ReferenceLine
    • CartesianChartScope.ReferenceArea
    • CartesianChartScope.ChartTooltip
    • CartesianChartScope.ChartLegend
    • LineChart
    • AreaChart
    • BarChart
    • ComposedChart
    • PieChartScope.Pie
    • PieChartScope.ChartTooltip
    • PieChartScope.ChartLegend
    • RadialBarChartScope.PolarAngleAxis
    • RadialBarChartScope.RadialBar
    • RadialBarChartScope.ChartTooltip
    • RadialBarChartScope.ChartLegend
    • PieChart
    • RadialBarChart
    • PolarGridType
    • RadarChartScope.PolarGrid
    • RadarChartScope.PolarAngleAxis
    • RadarChartScope.PolarRadiusAxis
    • RadarChartScope.Radar
    • RadarChartScope.ChartTooltip
    • RadarChartScope.ChartLegend
    • RadarChart