novus / nvd3

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

Add support for setting background fill behind charts (enhancement request) #1011

Open ShadSterling opened 9 years ago

ShadSterling commented 9 years ago

It would be helpful to be able to set a background behind a chart area.

In this SE question, I describe a case where it's useful, and my workaround to impose one: http://stackoverflow.com/questions/29659507/nvd3-set-background-fill-behind-line-chart

liquidpele commented 9 years ago

That's kind of a neat concept, though I think it should probably be more of a CSS thing than anything else... i.e. set the background of the svg's containing div and make sure the svg plays nice with that. Feel free to submit a pull request for us to review with a concept for this :)

ShadSterling commented 9 years ago

For the time being I'm too busy to figure out how to add it myself, unless you can point me to exactly where in the code to paste in my workaround from http://stackoverflow.com/a/29807357/776723 . If you have a working example using CSS, please post an answer to the same SO question.

brockj commented 8 years ago

I was able to get this working for line charts in 1.8.1 by using this selector: .nvd3.nv-lineChart g rect and setting an !important on the opacity

unfortunately, none of the other charts have a rectangle for the background

It may also break in the next release as the rect has been wrapped in a g with a class of nv-background