Skip to content

DSL — Color directives & annotations ​

Two families of named blocks that target specific data values to draw the eye: color directives (colorize, highlight, area-fill, overlay) recolor, emphasize or layer reference marks on parts of the chart, and annotations (annotation, range, note) attach text and shapes to data points, ranges, or absolute positions. Both share the same "named block with a body" shape, and highlight is the verb scenes use to switch emphasis — see Scenes & transforms.

Color directives ​

DirectivePurpose
colorize "<target>" { … }Apply a color rule to a target (axis label, value label, etc.).
highlight "<target>" { … } or highlight "<target>"Emphasize a data point or series. The short form has no body.
area-fill "<from>" "<to>" { … }Fill the area between two series with a color (line / area charts).
overlay "<col>" { … } or overlay "<from>" "<to>" { … }Draw a value mark or a range band on each bar of a bar or column chart.

colorize ​

bpc
chart bar-vertical {
  title = "E is the most frequent letter in English"
  colorPalette = "London"
  sort = descending

  colorize "E" {
    color = "#e15759"
  }

  data {
    "E" = 12.70
    "T" = 9.06
    "A" = 8.17
    "O" = 7.51
  }
}

From packages/lib/src/samples/letter-frequency.bpc

colorize paints a single category ("E") in a contrasting color over the base palette, drawing the eye to the chart's lede.

highlight ​

The short form highlight "<name>" (no body) is the common case — useful inside scene blocks for emphasising one series at a time:

bpc
scene "China spotlight" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  title = "China alone emits more than the US and India together"

  highlight "China"
}

scene "India rising" {
  title = "India passed the EU to become the third-largest emitter"

  highlight "India"
}

scene "Japan declining" {
  title = "Japan's emissions have fallen since their 2013 peak"

  highlight "Japan"
}

From packages/lib/src/samples/co2-emissions-story.bpc

Three scenes share the same data and successively highlight one country each — the canonical "guided tour" pattern.

area-fill ​

bpc
area-fill "Lower bound" "Upper bound" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  color = "#94a3b8"
  opacity = 20
}

opacity is a percentage from 0 to 100 and defaults to 30, the same scale as bgOpacity on a range annotation. opacity = 0.2 is not a 20 % fill, it is a 0.2 % one, and the band is invisible.

TIP

No bundled sample currently uses area-fill. The grammar is documented and parser-tested; the example above is illustrative.

overlay ​

bpc
overlay "Low (90% CI)" "High (90% CI)" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  title = "90% confidence interval"
  pattern = stripes
  color = "#64748b"
}

overlay "2021 to 2022" {
  title = "Change, 2021 to 2022"
  color = "#e15759"
}

Overlays sit on the bars of the seven bar and column charts: bar-vertical, bar-horizontal, bar-multi, bar-grouped, bar-split, bar-stacked and column-stacked. They read their values from extra columns of the data block. Columns that no overlay claims stay bars.

  • Single series (bar-vertical, bar-horizontal): the first unclaimed column is the bar, and every overlay sits on it.
  • Multi-series (bar-multi, bar-grouped, bar-split): each overlay sits on one series, named with bar. Without bar, or with an unknown name, it goes on the first series. On bar-split it draws in that series' panel.
  • Stacked (bar-stacked, column-stacked): an overlay spans the whole stack and its values sit on the value axis. Cues compare against the stack total, the sum of the row's visible values. A percent stack (stackMode = "percent") draws no overlay.

The number of columns sets the type: one column draws a value mark (a line across the bar), two columns draw a range band between the two values, whichever is lower or higher.

KeyApplies toMeaning
titlebothName shown in the key and the tooltip. Defaults to the column name (<from> to <to> for a range).
colorbothAny CSS color. Defaults to the text color.
opacitybothPercentage from 0 to 100. Defaults to 100 for a value and a whisker, 30 for a band.
patternrange onlysolid (default), stripes or whisker.
hiddenbothKeeps the overlay in the DSL but does not draw it. A hidden overlay has no cue.
barbothThe series the overlay sits on. Multi-series charts only: on single-series and stacked charts it is ignored and validation warns. A missing or unknown bar falls back to the first series, with a warning.
muteIfCrossesrange onlyA number. Fades every bar whose range on that row includes it, ends included. A row with a missing range end never fades.
aboveColorvalue onlyFills bars that reach the mark (equal counts as reaching).
belowColorvalue onlyFills bars below the mark.
aboveTitlevalue onlyKey label for aboveColor. Defaults to Above <title>.
belowTitlevalue onlyKey label for belowColor. Defaults to Below <title>.
repeatbothHow long the overlay lasts in a scene story, same values as an annotation's repeat. See Scenes & transforms.

A whisker draws the range as an error bar, suited to a margin of error or a confidence interval.

bpc
overlay "Harris low" "Harris high" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  title = "Harris margin of error"
  bar = "Harris"
  pattern = whisker
}

Problems such as an unknown column, a non-numeric cell, three or more columns, pattern on a value overlay, a cue key on the wrong kind of overlay, an unknown bar, no column left for the bars, or a chart type without bars are reported as warnings with an overlay- code.

From packages/lib/src/samples/household-income-change.bpc

The bars are the 2022 to 2023 change in real median household income. A striped range overlay shows the 90% confidence interval (estimate plus or minus the margin of error) and a value overlay marks the previous year's change.

bar ​

bpc
overlay "Harris low" "Harris high" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  bar = "Harris"
  title = "Harris margin of error"
  color = "#1f3d5c"
  pattern = stripes
}

From packages/lib/src/samples/election-margin.bpc

On bar-multi, each candidate gets a range overlay on their own bar.

muteIfCrosses ​

bpc
overlay "Low (90% CI)" "High (90% CI)" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  title = "90% confidence interval"
  pattern = stripes
  color = "#64748b"
  muteIfCrosses = 0
}

From packages/lib/src/samples/household-income-change.bpc

Bars whose interval includes zero fade to 45% opacity, so the changes that are not statistically clear read as uncertain. Only the bar fades: the overlay and the labels keep their strength. The fade has no key entry, so explain it in note.

aboveColor and belowColor ​

bpc
overlay "Target" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  title = "2% guideline"
  aboveColor = "#2a9d8f"
  belowColor = "#e15759"
}

From packages/lib/src/samples/nato-defence-spending.bpc

Each bar is colored by whether it reaches its row's mark. The key gets "Above 2% guideline" and "Below 2% guideline" entries after the overlay's own. Either key works alone: the other side keeps its normal color. colorize wins over these colors, and they win over negativeColor. With several value overlays, the first one with a color key colors the bars.

aboveTitle and belowTitle ​

bpc
overlay "Target" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  title = "2% guideline"
  aboveColor = "#2a9d8f"
  aboveTitle = "Meets the guideline"
}

Renames the key entry of a cue color. Without its color, a title is ignored.

Annotations ​

Three kinds of annotation, sharing a body of properties (text, textOffsetX, textOffsetY, showArrow, …):

Point annotation — anchored to a data key ​

bpc
annotation "2021" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  text = "All-time high cycle"
  textOffsetY = -12
  showArrow = true
}

From packages/lib/src/samples/bitcoin-price.bpc

A minimal point annotation: the key matches a data label, textOffsetY nudges the text up, and an arrow draws back to the point.

A richer point annotation with a connector line and curved leader:

bpc
annotation "2015" {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"
  text = "2015 Paris Agreement to limit global warming to 1.5°C "
  maxWidth = 224
  showLine = true
  lineStyle = curve-right
  showArrow = true
  showCircle = true
}

From packages/lib/src/samples/temperature-anomaly.bpc

Demonstrates showLine + lineStyle = curve-right for a labelled callout that arcs from the data point to the text block, plus maxWidth for wrapping.

Range and free annotations ​

bpc
range {
  theme = "blueprint-bold"
  colorPalette = "BlueprintBold"                    // range: spans a domain/value window
  orientation = vertical
  start = "2020"
  end = "2022"
  text = "Pandemic rally"
}

note {                     // free: absolutely positioned
  text = "Methodology footnote"
  x = "10%"
  y = "90%"
}

TIP

The bundled samples do not currently exercise range or note annotations — these are illustrative. The grammar is parser-tested and the AST node types (RangeAnnotationNode, FreeAnnotationNode) are exported.

The full property surface for each annotation kind is documented in the AnnotationConfig / PointAnnotationConfig / RangeAnnotationConfig / FreeAnnotationConfig types exported by @blueprint-chart/lib.

Released under the MIT License. Built static-first — your data never leaves the page.