Color code a data table in dc.js

后端 未结 1 1237
南旧
南旧 2020-12-18 13:18

I have a vary basic question and very little understanding of dc.js. I am trying to create a score card using the data that i have and display it as a data table using dc.js

相关标签:
1条回答
  • 2020-12-18 14:03

    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; }
    
    0 讨论(0)
提交回复
热议问题