NVD3.js coloring specific bars in graph

前端 未结 2 920
时光取名叫无心
时光取名叫无心 2021-01-14 09:46

Is there a way to color specific bars? If a bar is less than the line, color it red.

Code: https://github.com/tvinci/webs/blob/gh-pages/lineplusbar.html

Exam

2条回答
  •  旧巷少年郎
    2021-01-14 10:43

    You can do:

    d3.selectAll("rect.nv-bar")
        .style("fill", function(d, i){
            return d.y > 50 ? "red":"blue";
        });
    

提交回复
热议问题