Density Area Recipe

Grouped density area chart of car acceleration
Derived density paths with grouped color and guides.

Minimal flow

Runnable: install ggaction and provide the named data array as plain row objects.

import { chart } from "ggaction";

const program = chart()
  .createCanvas({ margin: { top: 100, right: 140 } })
  .createData({ values })
  .createAreaMark()
  .encodeDensity({ field: "value", groupBy: "group" })
  .encodeColor({ field: "group" })
  .createGuides();

You must decide

The library infers

Use createGuides({ grid: { horizontal: {}, vertical: {} } }) for both grid directions. Legends still default to the right; pass explicit top layout options only when that composition is intentional.

Continue

Density area tutorial · Encodings · Legends