Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Charts

BarChart

Compare amounts across categories (MUI X's BarChart). Hover a column for exact values.

import { BarChart } from "@stylhero/ui";

Example

Code
import { BarChart } from "@stylhero/ui";

const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"];

function BarChartExample() {
  return <BarChart title="Builds per month" labels={months} description="Builds rose from 40 in January to 95 in June."
    series={[{ name: "Gaming", data: [30, 42, 50, 61, 70, 72] }, { name: "Work", data: [10, 12, 15, 18, 20, 23] }]} stacked />;
}

Props

PropTypeDefaultDescription
labels required string[] - X-axis categories, e.g. ["Mon", "Tue", ...].
series required ChartSeries[] - Up to 8 series. More than that should be grouped into "Other" before charting.
description string -
height number 260
stacked boolean -
subtitle ReactNode -
title ReactNode -
valueFormat Fmt defaultFmt

Also takes the HTML attributes of its root element (id, style, data-*, aria-*, event handlers…).

Types

type ChartSeries = { name: string; data: number[] };

type Fmt = (n: number) => string;

Accessibility

  • role="img" labelled by description (else the title). The "Show as table" button switches to a data table with the same numbers.

Generated from src/components/Charts.tsx. Something wrong or missing? Open an issue.