Shading NET Rows and Columns
		
		
		
		Jump to navigation
		Jump to 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
- Table JavaScript and Plot JavaScript for an explanation of how to run this code.
 - Table JavaScript and Plot JavaScript Reference for technical information.
 - Table JavaScript and Plot JavaScript Examples Library for other examples.
 - JavaScript for information about the JavaScript programming language.
 - QScript for tools for automating projects using JavaScript.
 - JavaScript Variables for detail on how to create new variables in the Variables and Questions tab using JavaScript.