Skip to content

BarRaceChart

Open .md
Live preview

Loading example…

Bar race: horizontal bars that grow, shrink and swap places as time moves through frames. Play/pause, scrub with the slider, topN limits the rows. Under prefers-reduced-motion the bars step from frame to frame.

import { BarRaceChart } from "@jcsoftdev/ui/charts";

Single-component entry points tree-shake to just this component: @jcsoftdev/ui/charts/bar-chart.

<BarRaceChart
title="Citas por barbero esta semana"
categories={barbers}
series={[{ id: "citas", name: "Citas", data: appointmentsThisWeek }]}
valueFormat="integer"
orientation="vertical"
stack="none"
barRadius={6}
height={300}
dataLabels={false}
grid
tooltip
loading={false}
animate
labels={spanishLabels}
/>
Prop Type Default Description
entities * readonly BarRaceEntity[]
frames * readonly RaceFrame[] One entry per moment; values[i] belongs to entities[i].
title * string Accessible name of the chart.
description string
topN number 6 How many bars race at once (default 6).
frameDuration number 1400 Milliseconds between two frames (default 1400).
defaultPlaying boolean true Starts playing (default true; reduced motion starts paused).
loop boolean true Starts over after the last frame (default true).
valueFormat ValueFormat
height number | "fill" 340
aspectRatio number
loading boolean
playLabel string "Play"
pauseLabel string "Pause"
momentLabel string "Moment" Accessible name of the moment slider.
labels Partial<ChartLabels>
className string

* marks a required prop.

packages/ui/src/charts/bar-chart/bar-race-chart.tsx