VisorVisor
ComponentsData Display

Layer Chart

A zoomable icicle that opens a tree layer by layer, and the day span strip it opens into.

LayerChart opens a tree one layer at a time: all clients, a client, an engagement, a package, a ticket, a day. Rows are layers. The focus's ancestors sit on top as compressed path rows, then the focus row, then three layers below it at falling heights, and a gutter names each row's layer. Client blocks take Paper's project hues, so switch the site theme to Paper (light or dark) to see the colours as designed. On other themes the chart falls back to neutrals.

Layers

Click a block (or focus it and press Enter) and it grows to full width while its children open below it. Click the focus row, or press Esc, to go up a layer. ← and → move along the main row. Hours and Money re-measure the same shapes: a node can carry a value per measure, and a value of zero (investment, unassigned time in money) leaves the chart. Agent time adds a paler band under the rows where it is measured and a note under the first row where it is not. Open a day to see its span strip.

Narrow

Under 560px the rows drop to their narrow heights (40, 108, 52 and 22px), the gutter goes, and the sub lines and slots one layer down drop out. Thin blocks keep their accessible names, and the "+n" block stays a 24px target.

Kinds

A node's kind sets its fill, and its children inherit it. Blocks are separated by ground, never lines.

  • solid: the hue, lighter by depth.
  • covered: pale with a dot grid, the label on a plate so it reads.
  • not-billable: hatched, the label on a solid plate.
  • unresolved: coral, the only coral in the chart.
  • today: true: paler, because today counts once it is over.

Thin blocks

Labels step down by width: name, big number, sub line and share, then name and number, then the number, then nothing. Children thinner than 6px fold into one "+n" block, at least 24px wide, that opens their parent (onFocusChange reports reason: "more", so the page can show the full list). Every block keeps a hover card and an accessible name: "{ref} {name}, {value}".

Span strip

SpanStrip draws a day's spans as 5-minute cells on a time axis, separated by ground: attended time and calls in one lane, agent time in its own, thinner lane. The axis runs at least 8am to 7pm. Pass lanes to choose the lanes and hue for the project's colour.

Attended 4.17 hCall 0.5 hAgent 2.17 h

Colour

hue takes a Paper project-hue angle (75, 99, 123 … 339) on a top-level node, and its children inherit it. The chart reads --paper-hue-<angle>-fill, -fill-strong, -ink and -solid, from the strong fill at the top layer to the pale fill at the bottom. hue: "tide" is the studio's own investment, read from the theme's --layer-chart-investment-* tokens; Paper binds them to Tide. The unresolved fill and its ink, the opening motion and the ground are layer-chart component tokens (see Component tokens). Every part carries a data-slot (layer-chart-block, layer-chart-band, layer-chart-note, layer-chart-card, span-strip-lane, span-strip-legend).

Installation

npx visor add layer-chart

This copies four files into your project:

  • components/ui/layer-chart/layer-chart.tsx — LayerChart (and the SpanStrip export)
  • components/ui/layer-chart/layer-chart-layout.ts — the partition, rows, geometry and folding
  • components/ui/layer-chart/span-strip.tsx — SpanStrip
  • components/ui/layer-chart/layer-chart.module.css — the styles

API Reference

LayerChartProps

PropTypeDefaultDescription
data*LayerNode—The tree. Each node has an `id` (unique across the tree) and a `name`, and optionally `ref`, `layer` (names its row in the gutter), `value`, `hue`, `kind`, `today`, `sub` (the sub line) and `children`. `hue` and `kind` pass down to the children.
measure(node: LayerNode) => number | undefined(node) => node.valueReads a node's value in the current measure. Undefined on a parent sums its children; zero leaves the chart. Pass another accessor to re-measure the same shapes.
focusIdstring—The open block (controlled).
defaultFocusIdstring—The block open at first (uncontrolled). Defaults to the root.
onFocusChange(id: string, node: LayerNode, reason: 'open' | 'up' | 'more') => void—Called when a block opens: a click or `Enter` (`open`), `Esc` or a click on the focus row (`up`), or a "+n" block, which opens its parent (`more`).
format(value: number, info: { node: LayerNode; short: boolean }) => stringtwo decimals at mostFormats a value. `short` is the number alone, drawn on thin blocks.
renderBlock(node: LayerNode, info: { role: 'kids' | 'gkids'; width: number }) => ReactNode—Content at the foot of a block over 120px wide one layer down (and two layers down at desk width): an estimate Meter in a package block.
renderCard(node: LayerNode, info: { value: number; share?: number; more?: LayerNode[] }) => ReactNode—The hover card's content. Defaults to the name, the layer, the value and the share of the parent.
band{ value: (node) => number | undefined; label?: string; format?: (v: number) => string; note?: (layer: string) => ReactNode }—An optional paler band under every row where `value` returns a number (agent time), labelled `"{label} {format(v)}"` on wide blocks. `note` writes one line under the first row below the focus without the band.
aria-labelstring"Layers"Names the group of rows.

LayerChart renders a <div> and accepts all standard div attributes.

SpanStripProps

PropTypeDefaultDescription
spans*{ kind: 'attended' | 'call' | 'agent'; start: number; end: number }[]—The day's spans, in minutes after midnight. Each is cut into cells of `cell` minutes.
lanes{ label: string; kinds: SpanKind[] }[]"You" (attended, call) and "Agent" (agent)One lane per row. A lane of agent time alone is drawn thinner. The Agent lane is left out by default when there are no agent spans.
huenumber | 'tide'—The project's hue: a Paper project-hue angle, or `"tide"`.
cellnumber5Minutes per cell.
tickEverynumber120Minutes between axis labels.
kindLabelsPartial<Record<SpanKind, string>>—The legend's word for each kind (Attended, Call, Agent).
formatHours(hours: number) => string"{n} h"Formats a total for the legend and the lanes' names.

Accessibility

  • The rows are a group named by aria-label (default "Layers"). Every block is a <button> named "{ref} {name}, {value}"; the open block carries aria-current="true".
  • Enter opens the focused block, Esc goes up a layer, ← and → move along the main row. After a block opens, keyboard focus moves to it.
  • Blocks with no width (a value of zero, or off the canvas) leave the tab order and the accessibility tree.
  • The hover card repeats what the block's name says, so it is hidden from assistive tech.
  • Each span lane is an image named with its totals ("You: attended 3.5 h, call 0.5 h").
  • Kinds differ by pattern as well as colour (dots, hatching), and the unresolved block is named in its label (WCAG 1.4.1). On Paper every label passes AA on its fill in both modes.
  • Under prefers-reduced-motion: reduce blocks open without animating.