Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Count Buckets Histogram Stats Block for React

An order-value histogram of eight $25 buckets with the count above each column, the most common bucket drawn solid, the median bucket underlined and three figures above the chart: orders, the median bucket and the busiest bucket's share.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A plain histogram for React with Base UI. A centred header names the most common order size ("Most orders are $50–75") and one framed figure holds the rest. At its top, three figures: the orders counted (a rolling number), the bucket the median order falls in and the most common bucket with its share in its label. Under them, eight columns, one per $25 of order value, with the count above each column and the bucket's range under it. The most common bucket is solid, the others a lighter weight, and the median bucket's label is underlined. The counts, the total, the median bucket and every share are computed from one typed list of counts, and a visually hidden table holds the numbers. On a phone the labels show the lower edge of every other bucket. The columns grow from the baseline once on load. It's built from SlidingNumber and Guides, in your theme's foreground colour.

FAQ

How do I change the buckets?

Edit COUNTS at the top of the file: one count per bucket, from the smallest orders up. WIDTH is the width of a bucket in dollars; the last bucket has no upper edge and is labelled "$175+". For another number of buckets change grid-cols-8 in the two lists to match. Heights, the total, the median bucket (where the running count first reaches half) and every share are computed.

How are the column heights set?

Each column's height is its count as a share of the biggest count, over the room the chart leaves under the count labels, so the tallest column never touches the label above it. Counts are written above every column, so the chart can be read without the heights.

Is the chart accessible?

Yes. The columns are drawn for the eye and hidden from assistive technology; the chart has an accessible name that lists every bucket and its count, and a visually hidden table inside the figure gives each bucket's count and share. The three figures are a description list in text. The chart box is dir="ltr" because order values run from small to large in every language, and values sit in bdi elements.

How does it fit on a phone?

All eight columns stay, narrower, and the labels switch to each bucket's lower edge with every other one shown. The caption says so. The three figures stay in one row. Nothing scrolls sideways at 320 pixels.

What moves?

The header and the figure fade up once on load, the columns grow from the baseline one after the other and the counts fade in, and the order total rolls up when it scrolls into view. With reduced motion everything simply appears.

  • Pro

    A response-time histogram of ten 50 ms buckets with a smoothed density curve over them, a solid median line and a dashed mean line, and a band of three figures under it: mean, median and 90th percentile.

  • Pro

    A payload-size histogram on a log axis with gridlines at 1, 10, 100, 1K and 10K, ten buckets that double in size, a note that each line is ten times the one below, and p50, p90 and p99 badges tagged on their columns.

  • Pro

    A file-size histogram of seven bins stacked by kind (documents, images, video) in three foreground weights, with a Count and Share switch that turns absolute heights into 100% columns.

  • Pro

    Sixteen latency bins in a neutral fill with vertical markers at the median, the 95th and the 99th percentile, labelled at alternating heights, and a list of the three values in the header.

  • Pro

    Seven weekday columns for a gym's check-ins in a card in card, the busiest day drawn in full and the others at 30%, with the count above each column and a one-line takeaway under the axis.

  • Pro

    Pareto Chart Stats

    Bar and column

    A defect Pareto: seven bars sorted largest first, a cumulative line on a second axis, an 80% line and a bracket over the vital few, with a list of every cause's count, share and running share.