Adds Spans (i.e., sub-headings) to the headers in a table. Note that this does not change the data reduction of the underlying variable set - whereas if modifying a table by selecting headings, right-clicking and selecting Create Span the change would be made wherever the variable set is used.
Technical detail
Add column spans
// Span the Coke brands in the columns to create a span of "Coke Brands" table.spanColumns([table.columnIndex('Coca Cola'), table.columnIndex('Diet Coke'), table.columnIndex('Coke Zero')], 'Coke Brands'); // Span the Pepsi brands in the columns to create a span of "Pepsi Brands" table.spanColumns([table.columnIndex('Pepsi Light'), table.columnIndex('Pepsi Max'), table.columnIndex('Pepsi')], 'Pepsi Brands');
Add row spans
// Span the Coke brands in the rows to create a span of "Coke Brands"
table.spanRows([table.rowIndex('Coca-Cola'),
table.rowIndex('Diet Coke'),
table.rowIndex('Coke Zero')],
'Coke Brands');
// Span the Pepsi brands in the columns to create a span of "Pepsi Brands"
table.spanRows([table.rowIndex('Diet Pepsi'),
table.rowIndex('Pepsi Max'),
table.rowIndex('Pepsi')],
'Pepsi Brands');
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 using JavaScript.