Showing Significance Tests by Shading Bars
Jump to navigation
Jump to search
The following JavaScript:
- Shades bars that are significantly above average in grey/black.
- Shades more significant results in a darker shade of grey.
- Shades the remaining bars white.
var first_stat = table.statistics[0];
if (first_stat == 'Column Comparisons')
// The first value in each cell is the column comparisons already.
// Nothing to do here.
return;
var column_comparisons = table.get('Column Comparisons');// Try to get the column comparisons.
var cell_texts = table.cellText;// Get the default text in each cell in the table.
for (var row = 0; row < table.numberRows; row++)// Loop through each cell...
for (var column = 0; column < table.numberColumns; column++) {
// Set the cell text to be the column comparison value for this cell,
// with a space before it.
var comparison_text = column_comparisons[row][column];
// Removing spaces.
var text_without_spaces = comparison_text.replace(/ /g,"");
// Inserting into cell.
cell_texts[row][column] = [' ' + text_without_spaces];
}
// Now store the new cell texts.
table.cellText = cell_texts;
See also
- Rules for simpler ways of achieving similar results.
- 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.