A Rule governs how an output in Displayr, such as a chart or table, appears. The simplest rules are essentially identical to Conditional Formatting in Excel. For example, the chart below shades the cells proportional to the values.
Rules can also be used to manipulate the contents of outputs. In the example below, the sample size is inserted into each column heading.
JavaScript within Rules runs at the end of the process of calculating a table or chart and generating the output. The process for charts is similar to tables - in the background, Displayr is actually generating a table to construct the data to chart, including the series labels.
Manipulations of data performed by Rules using JavaScript can be very different to when changing the data elsewhere. For example, if you apply a filter to a table using Table JavaScript it will not automatically be applied in the statistics shown below and to the right of the table. To change these requires additional code.
The process is as follows:
- The main table output is generated, which incorporates:
- Statistics selected by using the table context menu and the toolbar
- Any changes to the row or column question's categories, including re-ordering, renaming, merging, etc. - any operation done via the table context menu and the toolbar
- If there are any STATISTICS > Right selected, another table output is generated for the table on the right, which is merged with the main table output later.
- If there are any STATISTICS > Below selected, another table output is generated for the table below, which is merged with the main table output later.
- The multiple comparison correction is performed, generating the Corrected p and Multiple Comparison Adjustment statistics (which affect displays of significance).
- Cell significance is calculated, determining arrow length and font color.
- The sample size description (shown in the table's footer) is calculated from the table's cell statistics (Count, Sample Size, etc.).
- The JavaScript is run.
- The same table outputs which were given to your JavaScript, and modified by your JavaScript, are used to display on the screen, or exported to PDF/Office.
- If you apply a Rule to a basic non-R-based chart in Displayr, or convert a table to this type of chart, the changes are effectively applied to the underlying table first and then carried over to the chart where applicable. The following chart types are the most compatible with Rules:
- Bar/Column/Line charts
- Stacked column/bar charts
- Grid of bars charts
Please note these steps require a Displayr license.
Next