Skip to main content
100%

181202_02_ Put some balls in

✓ Published1🌍 Public
LLudovicGouverneur
Last edited Dec 3, 2018
Created on Dec 2, 2018

This example demonstrates how SVG viewport and viewbox scaling affect the rendering of graphical elements by dividing a single `<svg>` into a grid of paths, circles, and rectangles. The visualization shows a 7-by-30 grid of green and red grid lines, overlaid with blue circles and yellow squares, which can be interactively zoomed and panned using d3.zoom. The code uses D3 v5 selections (`select`, `selectAll`, `data`, `enter`) to generate the SVG elements dynamically, with all styling defined in CSS. The zoom functionality applies a transform to the entire SVG, illustrating how the viewport interacts with coordinate systems.

AI-generated description

Goals : - Divide a svg element in 4 sub svg elements

Elements to grasp :

The D3 Select module : understand how DOM elements can be created, selected, modified.

How View port works for french speakers.

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

Improvements since the start : - 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