Showing Significance Tests by Shading Bars

From Q
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.

SignificantBars.png

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