Visualizations

Spark Charts

A small graph capable of visualizing data in a simplified form.

Import Spark Charts

Tremor exports three components to create spark charts.

import { SparkAreaChart, SparkLineChart, SparkBarChart } from '@tremor/react';

Usage example

The example below shows a composition combining a SparkAreaChart with text elements. Note: For the height, a number value has to be set (e.g. h-12. Keep in mind that h-full won't work.)

APPL

Apple Inc.
179.26+1.72%

Usage example with a custom colors

The example below shows a chart with custom colors. Note, that for the custom HEX color to work, the tailwind.config.js has to be adjusted. Learn more about custom colors in your theming section.

API Reference: SparkAreaChart

client component
data
Required
any[]
The source data, in which each entry is a dictionary.
categories
Required
string[]
Select the categories from your data. Used to populate the legend and toolip.
index
Required
string
Sets the key to map the data to the axis.
colors
(Color | string)[]
Change the default colors. When using Typescript, import the Color type provided by Tremor.
showAnimation
boolean

Default: false

Sets an animation to the chart when it is loaded.
animationDuration
number

Default: 900

The animation duration in ms.
showGradient
boolean

Default: true

Controls the style of the tinted area.
stack
boolean

Default: false

Controls the charts behavior to be stacked or placed along each other.
curveType
string

Default: linear

Controls the type of the chart curve
connectNulls
boolean

Default: false

Connects datapoints that have null values between them
noDataText
string

Default: No Data

The displayed text when the data is empty.
autoMinValue
boolean

Default: false

Adjusts the minimum value in relation to the magnitude of the data.
minValue
number
Sets the minimum value of the shown chart data.
maxValue
number
Sets the maximum value of the shown chart data.

API Reference: SparkLineChart

client component
data
Required
any[]
The source data, in which each entry is a dictionary.
categories
Required
string[]
Select the categories from your data. Used to populate the legend and toolip.
index
Required
string
Sets the key to map the data to the axis.
colors
(Color | string)[]
Change the default colors. When using Typescript, import the Color type provided by Tremor.
showAnimation
boolean

Default: false

Sets an animation to the chart when it is loaded.
animationDuration
number

Default: 900

The animation duration in ms.
stack
boolean

Default: false

Controls the charts behavior to be stacked or placed along each other.
curveType
string

Default: linear

Controls the type of the chart curve
connectNulls
boolean

Default: false

Connects datapoints that have null values between them
noDataText
string

Default: No Data

The displayed text when the data is empty.

API Reference: SparkBarChart

client component
data
Required
any[]
The source data, in which each entry is a dictionary.
categories
Required
string[]
Select the categories from your data. Used to populate the legend and toolip.
index
Required
string
Sets the key to map the data to the axis.
colors
(Color | string)[]
Change the default colors. When using Typescript, import the Color type provided by Tremor.
showAnimation
boolean

Default: false

Sets an animation to the chart when it is loaded.
animationDuration
number

Default: 900

The animation duration in ms.
stack
boolean

Default: false

Controls the charts behavior to be stacked or placed along each other.
relative
boolean

Default: false

Controls the numeric axis values to be displayed relatively.
noDataText
string

Default: No Data

The displayed text when the data is empty.