observablehq / stdlib

The Observable standard library.
https://observablehq.com/@observablehq/standard-library
ISC License
967 stars 83 forks source link

DOM.context2d take existing canvas? #51

Closed mbostock closed 3 years ago

mbostock commented 6 years ago

The problem with:

const context = this ? this.getContext("2d") : DOM.context2d(width, height);

Is that if the width or height changes, the retained canvas is the wrong size. It’d be nice if there were a simple way to retain the canvas, but only if it is the desired size.

mbostock commented 3 years ago

this is no longer recommended; see https://observablehq.com/@d3/learn-d3-animation for the recommended update method technique.