Skip to main content
100%

Line ordinal

✓ Published0🌍 Public
PPatrick Wojda
Last edited Mar 21, 2019
Created on Mar 21, 2019

This example draws a single horizontal line across an SVG canvas to illustrate ordinal positioning within a chart. The line, rendered with an arrow marker on each end, spans the width of the viewport with a 24-pixel margin. Using d3.v4, the code selects the SVG element and appends the line, then relies on the browser’s `getBoundingClientRect()` method to position two HTML labels, “Category A” and “Category B,” just below the line’s endpoints. The labels are placed via absolute CSS positioning within a container div, with their left offsets calculated from the line’s start and end coordinates minus the label’s own width.

AI-generated description

Built with blockbuilder.org

mit Licensed

Similar vizzes