Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Baseline chart

Area chart split by a horizontal reference line — fill above the baseline in one colour (profit), below in another (loss). Common for diff series, deviation-from-target, gains-vs-losses.

The demo plots the US Federal Funds Rate, 1965–1985, baselined against the long-run 5 % anchor most macro texts use when discussing the Volcker disinflation. The visible spikes above the baseline track the late-60s Vietnam-era overheating, the post-oil-shock inflation, and the Volcker shock of 1979–82 that crushed double-digit inflation by taking the funds rate above 16 % — a peak you can read straight off the 1981 fill.

Source: Federal funds rate — Wikipedia

Public surface

use wisp_chart::baseline::BaselineChart;

let bc = BaselineChart::new(
    vec![(0.0, 10.0), (1.0, 25.0), (2.0, -10.0), (3.0, 15.0)],
    0.0, // baseline y-value
);
let g = bc.emit_graphics(&theme, Vec2::new(480.0, 240.0));

Per-segment colouring

Info

Each segment between consecutive points is coloured by the sign of the average y of its endpoints relative to the baseline. Segments that cross the baseline currently render with the average-side colour — a future refinement could split the segment at the crossing point for exact colouring.