Color code a data table in dc.js

﹥>﹥吖頭↗ 提交于 2019-11-29 11:57:16

You can do that with css.

I'm using datatables jquery plugin.

{ targets: 3, 
data: function (d) {
    if (d.Rating<5) {       return '<span class="red">'+d.Rating+'</span>' ;}
    else if (d.Rating<7) {  return '<span class="yellow">'+d.Rating+'</span>' ;}
    else if (d.Rating<=10) {return '<span class="green">'+d.Rating+'</span>' ;}
    else {                  return '<span class="grey">'+d.Rating+'</span>' ;}
}}

you can make as much categories as you want.
And modify appearence with css like this.

.red{ background-color:red; }
.yellow{ background-color:yellow; }
.green{ background-color:green; }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!