Javascript 如何设置包含特定值的google表格图表列的样式

Javascript 如何设置包含特定值的google表格图表列的样式,javascript,css,google-visualization,Javascript,Css,Google Visualization,状态列中有五种值-{none、active、hold、…}。所以我想在颜色上把“active”设为绿色,在黄色中把“hold”设为颜色等 类似地,在“剩余天数”列中,小于10的值应为红色 var f_div = document.createElement("div"); f_div.id = "filter_div119_PlanName"; parent_w_div.insertBefore(f_

状态列中有五种值-{none、active、hold、…}。所以我想在颜色上把“active”设为绿色,在黄色中把“hold”设为颜色等 类似地,在“剩余天数”列中,小于10的值应为红色

var f_div = document.createElement("div");
                        f_div.id = "filter_div119_PlanName";
                        parent_w_div.insertBefore(f_div,w_div); 


                        var PlanNamefilter = new google.visualization.ControlWrapper({
                          "controlType": "CategoryFilter",
                          "containerId": "filter_div119_PlanName",
                          "options": {
                             "filterColumnLabel": "Plan Name", 

                            "values": ["Silver","Delux","Premium","Basic","Gold","Diamond"],
                            "ui": {
                              "allowTyping": false,
                              "allowMultiple": true
                            }
                          }
                        });
                        filters_bind.push(PlanNamefilter);

var data119 = google.visualization.arrayToDataTable([[{type:"string", label:"Plan Name"}, {type:"string",label:"Status"}, ...
var chart119 = new google.visualization.ChartWrapper({
                chartType: "Table",
                containerId: "widget_119",

                options : {hAxis: {title: "Labale", textPosition: "out"},vAxis: {title: "Value"},legend: {position:"none"},width:"100%",height:"100%",chartArea:{top:30,height:"85%",width:"85%"},showRowNumber: true,allowHtml: true, page: "enable", pageSize: 8, pagingSymbols: {prev: 'prev', next: 'next'}}
                }); dashboard.bind(filters_bind, chart119);
                            dashboard.draw(data119);}

若解决方案不需要第三方库,那个就更好了。

谷歌可视化中的ColorFormat应该是您正在寻找的东西,因为您已经在使用谷歌可视化了

你可以检查一下

状态列的示例代码 状态列的示例代码 代码解释
formatter.addRange(from,to,color,bgcolor)
将指定一条规则,当单元格的值在
from
的范围内时,文本颜色将更改为
color
,背景颜色将更改为
bgcolor

formatter.format(dataTable,columnIndex)
将上述指定的格式化程序应用于列
columnIndex
dataTable
(在您的情况下,状态为索引1,剩余天数为索引3)



没有我坎比亚的颜色在塔布拉的扇形线。。。o normal o falla

你能用jquery吗?我想这些表格的列只能用谷歌的apiEnglish来设计。答案通常用英语提供。请更新您的答案
var formatter = new google.visualization.ColorFormat();
formatter.addRange("active", null, 'green', 'white');
formatter.addRange("hold", null, 'yellow', 'white');
formatter.format(data, 1); // Apply formatter to second column
var formatter = new google.visualization.ColorFormat();
formatter.addRange(null, 10, 'red', 'white');
formatter.format(data, 3); // Apply formatter to fourth column
    var table = new google.visualization.Table(document.getElementById('table_div7'));

    var formatter = new google.visualization.ColorFormat();

    formatter.addRange('normal', null, 'white', 'green');
    formatter.addRange('falla' ,  null, 'white', 'red');
    formatter.format(data, 0); //  colores  columna fanstatus   

table.draw(data, {allowHtml: true, width: '80%', height: '10%'});
  }
<div id="table_div7"></div>