Preliminary Project Setup - Summary Plots
Jump to navigation
Jump to search
Displayr - Anything Menu
Displayr - New Page Menu
Displayr - Table Menu
Preliminary Project Setup
Q Technical Reference
Q Technical Reference
Q Technical Reference
Q Technical Reference
Q Technical Reference > Setting Up Data > Creating New Variables
Q Technical Reference > Setting Up Data > Creating New Variables
Q Technical Reference > Updating and Automation > Automation Online Library
Q Technical Reference > Updating and Automation > JavaScript > QScript > QScript Examples Library
Q Technical Reference > Updating and Automation > JavaScript > QScript > QScript Examples Library > QScript Online Library
R Online Library
User Interface > Create Charts
Create a chart for every variable set in the data set (excluding hidden and text variable sets)
This QScript creates a chart for every question in the data file (excluding hidden questions and questions that are Text or Text - Multi).
Example
How to apply this QScript
- Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
- Click on the QScript when it appears in the QScripts and Rules section of the search results.
OR
- Select Automate > Browse Online Library.
- Select this QScript from the list.
Customizing the QScript
This QScript is written in JavaScript and can be customized by copying and modifying the JavaScript.
Customizing QScripts in Q4.11 and more recent versions
- Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
- Hover your mouse over the QScript when it appears in the QScripts and Rules section of the search results.
- Press Edit a Copy (bottom-left corner of the preview).
- Modify the JavaScript (see QScripts for more detail on this).
- Either:
- Run the QScript, by pressing the blue triangle button.
- Save the QScript and run it at a later time, using Automate > Run QScript (Macro) from File.
Customizing QScripts in older versions
JavaScript
includeWeb('QScript Value Attributes Functions');
includeWeb('QScript Selection Functions');
var is_displayr = (!!Q.isOnTheWeb && Q.isOnTheWeb());
var data_file = requestOneDataFileFromProject(true, true, is_displayr);
// From here a user will have selected a file or only have one possible file in the document.
var summary_group = project.report.appendGroup();
summary_group.name = 'Summary Plots';
for (var i = 0; i < data_file.questions.length; i++) {
var q = data_file.questions[i];
if (!q.isHidden) {
var plot_type;
var q_type = q.questionType;
if (q_type == "Text" || q_type == "Text - Multi")
continue;
// Choose the appropriate plot type
if (q_type == 'Pick One') {
var non_missing_value_labels = nonMissingValueLabels(q);
var num_categories = non_missing_value_labels.length;
if (num_categories > 7)
plot_type = "Column plot";
else
plot_type = "Pie plot";
}
else if (q_type == 'Pick Any' || q_type == 'Pick Any - Compact' || q_type == 'Number - Multi' || q_type == 'Ranking')
plot_type = "Column plot";
else if (q_type == 'Experiment')
plot_type = "Bar plot";
else if (q_type == 'Number' )
plot_type = "Histogram";
else if (q_type == 'Pick One - Multi')
plot_type = "Stacked column plot";
else if (q_type == 'Pick Any - Grid' || q_type == 'Number - Grid')
plot_type = "Grid of bars plot";
else
plot_type = 'Column plot';
// Generate the plot
if (is_displayr) {
var page = summary_group.appendPage("Item");
var plot = page.appendPlot(plot_type);
page.name = q.name;
var titleText = page.subItems[0];
titleText.text = page.name;
} else
var plot = summary_group.appendPlot(plot_type);
plot.primary = q;
}
}
if (!is_displayr)
log('A group of summary plots has been added to the project.');
else
log('A group of summary plots has been added to the end of the Report Tree.');
See also
- QScript for more general information about QScripts.
- QScript Examples Library for other examples.
- Online JavaScript Libraries for the libraries of functions that can be used when writing QScripts.
- QScript Reference for information about how QScript can manipulate the different elements of a project.
- JavaScript for information about the JavaScript programming language.
- Table JavaScript and Plot JavaScript for tools for using JavaScript to modify the appearance of tables and charts.
Displayr - Anything Menu
Displayr - New Page Menu
Displayr - Table Menu
Preliminary Project Setup
Q Technical Reference
Q Technical Reference
Q Technical Reference
Q Technical Reference
Q Technical Reference > Setting Up Data > Creating New Variables
Q Technical Reference > Setting Up Data > Creating New Variables
Q Technical Reference > Updating and Automation > Automation Online Library
Q Technical Reference > Updating and Automation > JavaScript > QScript > QScript Examples Library
Q Technical Reference > Updating and Automation > JavaScript > QScript > QScript Examples Library > QScript Online Library
R Online Library
User Interface > Create Charts