Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

color of linechart body #940

Open
zerkphb opened this issue Jun 1, 2015 · 1 comment
Open

color of linechart body #940

zerkphb opened this issue Jun 1, 2015 · 1 comment

Comments

@zerkphb
Copy link

zerkphb commented Jun 1, 2015

Is there any way to set the chart background color?

like:

image

@gordonwoodhull
Copy link
Contributor

The easiest thing is simply to set the CSS background-color of the div you passed to dc.js.

But you probably want just the chart area colored. Right now the best way to do this is with a "renderlet":

        .on('renderlet', function(chart) {
            if(!chart.select('rect.background').size())
                chart.svg()
                .insert('rect', ':first-child')
                .attr('class', 'background')
                .attr({width: chart.xAxisLength(), height: chart.yAxisHeight()})
                .attr('transform', 'translate(' + chart.margins().left + ', ' + chart.margins().top + ')')
                .style({fill: 'lightgreen'});
        });

There will be a bit of a lag unless you set .transitionDuration(0), disabling transitions, because the renderlet executes after transitions. #806 will help with that.

I copied most of the code from the clip path, because it's the same rectangle.

It might be nice to support this directly. Anyone else miss this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants