human-kit charts

Area

Chart.Area fills the space between each series and zero. Each row is a point on the top line of the area. The points are focus targets, but they show only when they have the focus.

Requests per day
dayrequests
Jun 1, 2025320
Jun 2, 2025410
Jun 3, 2025380
Jun 4, 2025520
Jun 5, 2025610
Jun 6, 2025580
Jun 7, 2025690
Jun 8, 2025720
Jun 9, 2025650
Jun 10, 2025780
Jun 11, 2025840
Jun 12, 2025810
Jun 13, 2025900
Jun 14, 2025960

Anatomy

<script lang="ts">
	import { Chart } from '@human-kit/charts';
	import { scaleTime } from '@human-kit/charts/scales/time';
</script>

<Chart.Root data={rows} x="day" y="requests" xScale={{ type: scaleTime }}>
	<Chart.Title>Requests per day</Chart.Title>
	<Chart.Plot>
		<Chart.Area />
	</Chart.Plot>
</Chart.Root>

The mark makes a <g> with one group for each series. A series group holds a filled <path>, a <path> for the top line, and one <circle> for each point.

Stacked

Give stacked to put the series one on the other. The first series is on the top, and each area is on the area of the next series. Thus the order from the top to the bottom is the order of the legend, and ArrowDown goes down on the screen. The y scale includes the top of the stack.

Visits per source, in thousands
monthSearchDirectSocial
January 202530126
February 202534149
March 202533158
April 2025381512
May 2025421811
June 2025452015
July 2025442217
August 2025492119

Without stacked, each area starts at zero, and the areas can cover each other. Give the fill an opacity, so that the user can see all of the series.

A stack changes the domain of the y scale. On the server, a guide before the mark does not see the top of the stack. Thus put the mark before the guides, or give the domain of the y scale.

Points

The default radius r is 0. The points are hidden, but they stay focus targets. The focused point gets the radius focusRadius, which is 4 pixels by default. Give r to show all of the points.

Styles

Give each series a color with the CSS color. The filled path uses it as its fill, and the top line uses it as its stroke.

.chart [data-area] {
	opacity: 0.2;
}

.chart [data-line] {
	stroke-width: 2;
}
ElementAttributeWhen
Group of the markdata-markAlways. The value is area.
Group of the markdata-stackedstacked is true.
Group of a seriesdata-seriesThe series has a name. The value is the name.
Filled pathdata-areaAlways.
Top linedata-lineAlways.
Pointdata-pointAlways.
Pointdata-focusedThe point has the focus.
Pointdata-focus-visibleThe point has the focus, and the focus came from the keyboard.
Pointdata-selectedThe point is selected.

API reference

Area

An area mark. It makes one filled <path> and one line per series. The points show only when they have the focus.

Prop Type Default

* required.

Data attribute Description
data-mark On the group of the mark. The value is area.
data-stacked On the group of the mark, when stacked is true.
data-series On the group of each series. The value is the name of the series.
data-area On the filled path of each series.
data-line On the top line of each series.
data-point On each point: a circle, a rect for a bar, or a path for a dot.
data-focused On the point that has the focus.
data-focus-visible On the focused point, when the focus came from the keyboard.
data-selected On the selected point. The point also has aria-current="true".