svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
11.2k stars 1.08k forks source link

Add element.data() #1

Closed gka closed 11 years ago

gka commented 11 years ago

Similarily to jQuery and Raphael, this function would allow to bind arbitrary objects to SVG elements. That's super helpful for any datavis applications.

Syntax:

el.data('key', obj); // store data, return element
el.data('key'); // return data
el.data('key', null); // remove data
wout commented 11 years ago

Great idea. In fact, I needed this today in one of our svg projects. I will implement this asap.

wout commented 11 years ago

This has been implemented, tested and released. Usage is exactly as you described: https://github.com/wout/svg.js#data