Shading NET Rows and Columns

From Q
Jump to: navigation, search

This rule shades any NET rows or columns in a light blue color.

// Fetch the array of cell colors (one entry for each cell).
var colors = table.cellColors;
var shade = 'AliceBlue';
 
var net_name = getNetName();
 
// Find NET rows
var net_rows = table.netRows;
table.rowLabels.forEach(function (row_label, index) {
    if (row_label == net_name && net_rows.indexOf(index) == -1)
        net_rows.push(index);
});
 
// Shade NET rows
net_rows.forEach(function (row) {
    for (var column = 0; column < table.numberColumns; column++)
        colors[row][column] = shade;
});
 
if (table.columnLabels != null) {
    // Find NET columns
    var net_columns = table.netColumns;
    table.columnLabels.forEach(function (column_label, index) {
        if (column_label == net_name && net_columns.indexOf(index) == -1)
            net_columns.push(index);
    });
 
    // Shade NET rows
    net_columns.forEach(function (column) {
        for (var row = 0; row < table.numberRows; row++)
            colors[row][column] = shade;
    });
}
 
// Apply colors to the cells
table.cellColors = colors;
 
function getNetName() {
    var net_name = 'NET';
    if (table.getTranslation)
        net_name = table.getTranslation(net_name);
    return net_name;
}

See also