Skip to main content
100%

Create a new Blank Canvas with D3.js!

✓ Published1🌍 Public
Fframptonb
Last edited Feb 17, 2023
Created on Feb 17, 2023

This example creates a blank canvas by sizing an SVG to fill the browser viewport, then drawing a single rounded rectangle across the entire drawing area. The code uses D3.js v5’s `select` method to grab the `<svg>` element, sets its width and height from `document.body.clientWidth` and `document.documentElement.clientHeight`, and appends a `rect` with a 40-pixel corner radius via chained attribute setters. The SVG rendering approach is direct, with no external data source.

AI-generated description

Demonstrates how to create a new blank canvas using D3.js. (based on a tutorial by Curran Kelleher)

<iframe width="560" height="315" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
MIT Licensed

Similar vizzes