Adding an Exclamation Mark to Cells with Large Numbers
Jump to navigation
Jump to search
// Display an exclamation point next to the first statistic in each cell, if it is over 80.
// Get the values for the first statistic shown on the table.
var values = table.get(table.statistics[0]);
// Get the default text in each cell in the table.
var cell_texts = table.cellText;
// Loop through each cell...
for (var row = 0; row < table.numberRows; row++)
for (var column = 0; column < table.numberColumns; column++) {
var value = values[row][column];
if (value > 80) {
// Put an exclamation point next to the first statistic.
cell_texts[row][column] = ['!'];
}
}
// Now store the new cell texts.
table.cellText = cell_texts;
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.