Skip to main content
100%

Internalizing chart variables (mod)

✓ Published0🌍 Public
ZZJONSSON
Last edited Jan 11, 2012
Created on Jan 11, 2012

Three small circles are plotted as a scatter of three data points, each mapping an `x` and `y` value to screen coordinates. The example demonstrates how to store chart scales on a DOM node by setting an SVG element’s `__chart__` property via `d3.select(...).property`. Inside the property function, two linear scales are built with `d3.scale.linear`, using the parent’s `offsetWidth` and `offsetHeight` for ranges. The circles then access these scales through `this.__chart__` when setting `cx` and `cy`, avoiding closure variables.

AI-generated description

Similar vizzes