Skip to main content
100%

181202_01_Viewport

✓ Published1🌍 Public
LLudovicGouverneur
Last edited Dec 2, 2018
Created on Dec 2, 2018
Forked from SVG Path

This example demonstrates how the SVG viewport and viewBox interact to scale a coordinate system. A set of vertical and horizontal path elements, drawn as colored lines, is defined within a viewBox of “0 0 100 50” and rendered inside an SVG element with a blue border. The number of horizontal and vertical lines is parameterized, and their positions are calculated dynamically using D3’s `range` function. The code uses D3 v5 to append paths to the SVG, while line styling is specified in an external CSS file.

AI-generated description

This example is used to understand the SVG viewport and viewbox - Ludo;

For French Speakers, I recommand to read this article

Improvements : - Style of lines are defined in CSS. - Number of Horizontal and Vertical are parameter - For automatic Display, number of lines and viewbox dimensions are now linked. - Viewbox dimensions is not hardcoded anymore

This is based in SVG Path Tutorial • Easy to Understand!, made by Roberto Matthews.

MIT Licensed

Similar vizzes