Simple annotations for d3 graphics
Include d3 (v7 or higher) before including your annotation script.
To add
Here is an example of an annotation definition:
let annotation = { note: "Boston, MA", // Whatever you want your note to say. Accepts HTML. data: [ // The coordinates of the annotation subject go first { x: +x(max_cty.pct_ba_higher), y: y(+max_cty.pci) }, // You can optionally define an intermediary point for the line to pass through { x: x(0.4), y: y(45000) }, // The coordinates of the annotation note go last { x: x(0.42), y: y(35000) }, ], width: 100, height: 55, // You can optionally specify an id for CSS styling id: 'max-anno', // Or a class class: 'annotation', // Use arrow_offset to offset the position of the arrow from its subject arrow_offset: { x: 0, y: dot_radius * 1.5 }, // Specify where the line should connect to the note line_start: 'top', // Lines can either have linear or normal curves curve_type: 'linear' }You can then add your annotation by running
Annotation notes are added to the SVG using