Skip to main content
100%

Rectangles using data

✓ Published0🌍 Public
IIgathi
Last edited Jul 15, 2018
Created on Jul 15, 2018

This example shows how to bind a hardcoded JSON dataset of four rectangles—each with position, size, color, and a name—to SVG elements using D3 v4. It first creates the rectangles via `d3.selectAll("rect").data(...).enter().append("rect")`, then sets their `x`, `y`, `width`, and `height` attributes and `fill` style from the data. It also appends text labels next to each rectangle, positioning them relative to the rectangle’s coordinates and size. The visualization demonstrates basic data joins and attribute binding in D3, with the source data defined inline in the script.

AI-generated description

Built with blockbuilder.org

forked from <a href='http://bl.ocks.org/Igathi/'>Igathi</a>'s block: <a href='http://bl.ocks.org/Igathi/713b5a2deed36e1f2a153d7a303d8279'>Rectangles using data</a>

mit Licensed

Similar vizzes