Automatically Adding a Statistic to a Table
Jump to navigation
Jump to search
Automatically adds the Average to any table (that has this as a possible Statistics in its cells).
if (table.availableStatistics.indexOf('Average') != -1) { // If Average is available on this table
var stats = table.statistics; // Get the existing statistics on the table (selected by the context menu).
if (stats.indexOf('Average') == -1) { // If Average is not already selected
stats.push('Average'); // Add Average.
table.statistics = stats; // Use our new list as the statistics.
}
}
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.