Color Cells Containing Specific Ranges of Values
Jump to navigation
Jump to search
This code obtains the p value from a table and colors any cells containing values of p less than 0.05.
// Color yellow any cell that a p-value of less than 5%.
// Get p-values array.
var ps = table.get('p');
// Get the cell colors array.
var colors = table.cellColors;
// Look at each cell...
for (var row = 0; row < table.numberRows; row++)
for (var column = 0; column < table.numberColumns; column++) {
// Get the cell's p-value.
var p = ps[row][column];
// If the value is less than 5%, color this cell yellow.
if (p < 0.05)
colors[row][column] = 'yellow';
}
// Store the modified cell colors.
table.cellColors = colors;
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.