QScript ProjectSettings

From Q
Jump to navigation Jump to search

ProjectSettings

The settings that apply to the whole document.

customColors

Get/set the user's custom colours — the extra colours the colour picker offers, under Custom in Project Settings. White cannot be one of them, because the document drops every white as it stores the list. An empty list leaves the colour picker with no custom colours.
Example:
project.settings.customColors = ['rgb(0, 114, 188)', '#FF6600'];

equals(obj)

Whether two objects are the same.
objThe object to compare against.
Returns:true or false
Example:
data_file.getQuestionByName('Q2').equals(data_file.questions()[0])

type

Returns "ProjectSettings".

visualizationColors

Get/set the colours a visualization uses for its series, as shown under Colors in Project Settings. A visualization takes its colours from this list unless it sets its own. The list must hold at least one colour. A fully transparent white is refused, because No Fill in Project Settings writes that value to remove a colour.
Example:
 // Read the current palette:
 log(project.settings.visualizationColors.join(', '));

 // Use a two-colour palette:
 project.settings.visualizationColors = ['rgb(0, 114, 188)', 'rgb(255, 102, 0)'];

visualizationFont

Get/set the font a visualization uses unless it sets its own, as shown under Font in Project Settings. The font is split into parts: family, size, bold, italic, underline and strikeout. Reading gives every part. Writing accepts any subset of the parts and leaves the parts it is not given alone, so { bold: true } bolds the font and keeps its family and size. Reading gives a copy, so change its parts and write it back; changing them in place does nothing. A family this document cannot resolve is replaced by the default font as the font is stored.
Example:
 // Read the current font:
 log(project.settings.visualizationFont.family + ' ' + project.settings.visualizationFont.size);

 // Change the family and size, and leave the rest alone:
 project.settings.visualizationFont = { family: 'Open Sans', size: 12 };