Skip to content

Simple way to color bar chart #200

@textplusdata

Description

@textplusdata

Hi.
I'm trying to color a stacked bar chart, and I've looked at some other complicated solutions, but I need something simple!

I am trying this which seems to be a hotch-potch of code. I've tried the selectAll with about every combination: rect.bar, rect.stack, g.rect.bar etc.

.renderlet(function(chart){
       chart.selectAll("g.rect.stack").attr("fill", function(d){
            if(d.key == "a) Free")   
         return "green-bar";
    else if(d.key == "b) Partly Free")
         return "yellow-bar";
     else if(d.key == "c) Not Free")
         return "red-bar"; 
        });})

Anyone help me get over this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions