dc.js 气泡图颜色比例不起作用

dc.js bubblechart colors scale is not working

我正在尝试根据特定的数据阈值设置气泡图的颜色,我的数据的域为 0 到 100。我想为值 0-40、40-60 和 > 60 显示不同的颜色。

我尝试了以下但运气不好

.colors(["#e57275", "#94dfeb","#f6df86"])
.colorDomain(function() {
    return ["Poor", "Average","Good"]
 })
 .colorAccessor(function(d) {

    if (d.value.performance < 40) {
      return "Poor";
    }
    if (d.value.performance >= 40 && d.value.performance < 60) {
      return "Average";
    }
    if (d.value.performance >= 60) {
      return "Good";
    }
 })

这是演示问题的 Plnkr

直接指定颜色就好了...

  .colors(["#e57275", "#94dfeb","#f6df86"])
  .colorAccessor(function(d) {
    //  alert('Lets chec' + d.performance)
    if (d.value.performance < 40) {
      return 0;
    }
    if (d.value.performance >= 40 && d.value.performance < 60) {
      return 1;
    }
    if (d.value.performance >= 60) {
      return 2;
    }
  })