linked

command
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Command linked wires two charts together through the host program.

Hovering a stage in the throughput chart highlights the flows that touch it in the sankey beside it. That is the whole shape of dependent interaction in figure: the library says what the pointer is on, the host decides what that means somewhere else, and the second chart is told in the same vocabulary any other caller would use.

There is no link between the two charts inside figure, and that is deliberate. A link is a statement about two charts, and figure's model is one chart — so the mapping from "the parse stage" to "the flows through it" lives here, in ordinary Go, where it can be a lookup, a database query, or a rule nobody could have written down in a chart specification.

The three pieces figure contributes:

  • geom.KeyBy names the column that identifies a row, so Event.Key is a name the other chart also knows. A row number would not be: it is an index into a table as it stands this frame, and the two charts are drawn from two different tables.
  • Plot.SetLayers replaces the second chart's layers, so a highlight that arrives on every pointer move does not accumulate one layer per move.
  • Live.Rebuild puts the reader's zoom back, so answering a hover does not throw away wherever they had been looking.
  • An overlay draws the feedback. The first chart gets a crosshair and a tooltip where the pointer is; the second gets a ring round the node the hovered stage feeds. Both are drawn by figure, over the finished chart, and neither is hit-testable — so pointing at the tooltip cannot dismiss it.

Why the highlight recolours rather than overdraws

The obvious way to highlight some flows is to draw them again on top, and geom.Faceter.Subset would build exactly that layer. It would be wrong here. A sankey's geometry is a property of its whole edge list — where a node sits and how thick it is depends on everything flowing through it — so a sankey over three of five edges lays out three edges, and the highlight would sit beside the flows it meant to mark rather than on them.

So the highlight is a colour rather than a layer: the same five edges, drawn once, with a column saying which of them are interesting. A mark whose layout is a function of one row — a scatter, a bar, a rect — can be overdrawn with Subset instead. Which of the two applies is a property of the mark, and it is worth knowing before reaching for either.

Like the other documented examples it is executed by a test, so it cannot quietly stop compiling or stop producing charts.

go run ./examples/linked -throughput throughput.svg -flow flow.svg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL