novus / nvd3

A reusable charting library written in d3.js
http://nvd3.org/
Other
7.22k stars 2.15k forks source link

Use classed('classname', true) instead of attr('class', 'classname') #1900

Open n1ywb opened 7 years ago

n1ywb commented 7 years ago

In some areas, e.g. https://github.com/novus/nvd3/blob/master/src/models/discreteBar.js#L179 NVD3 unconditionally overrides the class of an existing element.

This is bad because sometimes you might want to set your own classes on those elements, e.g. if you're trying to use NVD3 with Polymer scoped styles https://www.polymer-project.org/1.0/docs/devguide/styling#scope-subtree

D3 offers a classed method for this exact use-case https://github.com/d3/d3-3.x-api-reference/blob/master/Selections.md#classed

see also https://github.com/saeidzebardast/nvd3-elements/issues/17

liquidpele commented 7 years ago

Please send us a pull request with changes to classed and I'll merge it in.