Multi-series bar chart in DC-js

后端 未结 4 588
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 07:07

I\'m using DC.js ( lib on top of D3 ) and have a great example of a single series bar chart:

\"enter

4条回答
  •  Happy的楠姐
    2020-12-10 07:28

    I was able to do this with a twist of the renderlet technique in the following link renderlet function for coloring

    My code goes as follows

    .renderlet(function (chart) {
        chart.selectAll('rect.bar').each(function(d){                           
        d3.select(this).attr("fill",                            
            (function(d){
                var colorcode ="grey"
                if(d.x[1] === "Zone1")   
                    colorcode ="#ff7373";
                else if(d.x[1] === "Zone2")
                    colorcode ="#b0e0e6";
                else if(d.x[1] === "Zone3")
                    colorcode ="#c0c0c0";
                else if(d.x[1] === "Zone4")
                    colorcode ="#003366";
                else if(d.x[1] === "Zone5")
                    colorcode ="#ffa500";
                else if(d.x[1] === "Zone6")
                    colorcode ="#468499";
                else if(d.x[1] === "Zone7")
                    colorcode ="#660066";   
                return colorcode;
            }))
        }); 
    
    });  
    

    Note : I was using a dimension with 2 values for the series .

提交回复
热议问题