axis line stroke color inconsistent #1516

Open
davidjmcclelland opened this Issue Feb 16, 2016 · 1 comment

Projects

None yet

1 participant

@davidjmcclelland

I am new to nvd3 - I am using the simple line graph with legend,
If I set my axis line colors via:

                d3.selectAll("line")
                    .style("stroke","#FF0000");

And then remove the tallest series by clicking the legend, any new axis lines are drawn in whatever the default color is (where is that set?), not Red.

Is there a redraw function or something that can control the color of any new lines drawn after the chart is created? I tried using CSS as follows but this does not color the axis lines, and doesn't solve my use case even if it did:

line {
stroke:#FF0000;
}

I have been able to style text and paths using CSS, but CSS is too static - my users author and style their charts using the UI I am developing. I have the same problem dynamically styling axis tick label text - any new text comes in black, not Red.

I have seen many solutions which require building the grid in d3. I chose nvd3 to avoid having to manage all that, although I am already making many d3 calls in my nvd3 chart to style it. It does everything else I need very well - thank you!

@davidjmcclelland

Below shows how adding a statechange triggers a refresh via updateStyles and a kludgey wait for the animation to complete.

Any suggestions on a cleaner method that this to keep styles intact when animations occur?

chart.dispatch.on ('stateChange', function (e) {updateStyles (e)});

        function updateChart(){
            // d3.select(#chartId)
        }
        function updateStyles(e){
            setTimeout(function() { doUpdateStyles(); }, thisWidget.duration);
          //  console.log("legend was clicked");
        }
        function doUpdateStyles(){
            d3.selectAll("text")
                .style("fill", chartStyles.text);
            d3.selectAll("line")
                .style("stroke",chartStyles.gridStyle);
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment