Creating a Column Plot
Jump to navigation
Jump to search
Charts are created in the same way as tables, except that appendPlot replaces appendTable, and the required chart-type needs to be specified:
This example uses C:\Program Files\Q\Examples\Phone.sav (this may be located on a different place on your computer depending upon how Q was installed).
// Working on Phone.sav, this creates a new column plot of Age broken down by Gender.
var p = project.report.appendPlot("Bar/column/line plot");
p.primary = project.dataFiles[0].getQuestionByName('Age');
p.secondary = project.dataFiles[0].getQuestionByName('Gender');
See also
- Next worked example.
- Preliminary Project Setup - Summary Plots for a script that generates summary charts for each question in your project.
- QScript for an explanation of how to run this code.
- QScript Examples Library for other examples.
- QScript Reference for technical information.
- 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.
- JavaScript Variables for detail on how to create new variables in the Variables and Questions tab using JavaScript.