novus / nvd3

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

Default svg.nvd3-svg width and height styles override chart.width() and chart.height() attributes #1434

Open mqklin opened 8 years ago

mqklin commented 8 years ago

From main.css:

/********************
  Default CSS for an svg element nvd3 used
*/
svg.nvd3-svg {
    ...
    width:100%;
    height:100%;
}

And when I try to make this: chart.height("77em"), it sets height attribute to svg element, but classes have higher priority then [attributes]!

bug

mgalloue commented 8 years ago

You can useheight: 77em !important, to change priority.

mqklin commented 8 years ago

@mgalloue, had you tried it before you wrote this? Of course it's not working because width in this case in an attribute, not style.

mgalloue commented 8 years ago

Oops, sorry yes I was speaking about style obviously. For all my charts I'm using chart.width() for sizing and it's works well, don't know what is the difference in you case.

mqklin commented 8 years ago

@mgalloue, it works because of incorrect Chrome or Firefox behaviour. It's not working in IE. chart.width() sets width as attribute and it shouldn't rewrite width as style (see screen above).

mqklin commented 8 years ago

Fix PR: https://github.com/novus/nvd3/pull/1435