Php 在Google可视化表中格式化每条记录的最小值和最大值

Php 在Google可视化表中格式化每条记录的最小值和最大值,php,ajax,formatting,google-visualization,Php,Ajax,Formatting,Google Visualization,是否有一种简单的方法可以格式化表中的每条记录,以区分该记录的最高值和最低值?我见过arrow格式化程序,但看起来我需要提供一个值,然后将其添加到每个单元格中。不完全是我所需要的,但也许我可以修改它,使之适合我的情况。这是一个我想应用它的表 比如说,, 在第一个记录中,JTB将是红色的,橙色公园将是绿色的,因为这是因为商品成本越低越好。我可以提供代码,如果需要的话,但我主要只需要在正确的方向推动。我使用ajax请求表,然后使用php生成表,然后编码为JSON并返回ajax,然后生成Google可视

是否有一种简单的方法可以格式化表中的每条记录,以区分该记录的最高值和最低值?我见过arrow格式化程序,但看起来我需要提供一个值,然后将其添加到每个单元格中。不完全是我所需要的,但也许我可以修改它,使之适合我的情况。这是一个我想应用它的表

比如说,,
在第一个记录中,JTB将是红色的,橙色公园将是绿色的,因为这是因为商品成本越低越好。我可以提供代码,如果需要的话,但我主要只需要在正确的方向推动。我使用ajax请求表,然后使用php生成表,然后编码为JSON并返回ajax,然后生成Google可视化。

您必须手动添加单元格属性以突出显示低/高值。假设您有用于低值和高值的CSS类“low”和“high”,您可以这样做:

for (var i = 0; i < data.getNumberOfRows(); i++) {
    var lowIndices = [], highIndices = [], lowVal = null, highVal = null;
    for (var j = 1; j < data.getNumberOfColumns(); j++) {
        if (lowVal == null || data.getValue(i, j) < lowVal) {
            // if we have a new lowVal, reset lowVal and lowIndices
            lowVal = data.getValue(i, j);
            lowIndices = [j];
        }
        else if (data.getValue(i, j) == lowVal) {
            // if we tied a lowVal, add the new index
            lowIndices.push(j);
        }

        if (highVal == null || data.getValue(i, j) > highVal) {
            // if we have a new highVal, reset highVal and highIndices
            highVal = data.getValue(i, j);
            highIndices = [j];
        }
        else if (data.getValue(i, j) == highVal) {
            // if we tied a highVal, add the new index
            highIndices.push(j);
        }
    }
    // add the high/low classes to the appropriate cells
    for (var k = 0; k < lowIndices.length; k++) {
        data.setProperty(i, lowIndices[k], 'className', 'low');
    }
    for (var l = 0; l < highIndices.length; l++) {
        data.setProperty(i, highIndices[l], 'className', 'high');
    }
}