| framework.shinylightFrameworkStart {shinylight} | R Documentation |
JavaScript function: Starts the Shinylight Framework, if you want to use it.
Description
The Shinylight Framework allows you to declare all your functions in R and have a nice-looking web front end for your code without having to write any JavaScript.
You should never need to call this function yourself; if you do not
provide your own index.html, the default Shinylight one
will be used that will call this function on page load.
Using the Shinylight Framework entails calling the slServer
function with the interface argument set to
list(getSchema=schema), where
schema is defined in the following section.
Arguments
options |
|
options.createFileInput |
|
The Schema
It is a list with the following members:
functionsa list of functions (keyed by their names), each of which is a list with the following members:
paramsa list of the main parameters the function accepts. The keys are the parameter names and the values are keys into the schema's
paramslist.optiongroupsa vector of keys into the schema's
optiongroupslist giving other parameters to this function.
functiongroupsoptional: the menu structure for the functions menu. Each item in the list is either a function name (a string referencing a key in the
functionslist) or a list representing a submenu. Submenu keys are the name to be displayed in the list, which can be overridden in the app.json file'sfunctionsobject, just like providing localized names for functions.paramsa list of the parameters the functions take, each of which is a list with the following members:
typeeither a key into the schema's
typeslist, giving the type of this parameter or the values it can take, or one of a set of standard types:'b'Boolean
'f'Floating point
'u8'8-bit unsigned integer
'color'Colour
'subheader'Vector of settings the user can choose for each column using selectors in the subheader row. This is usually used to select units (for example percent-by-weight versus parts-per-million) for the columns.
dataa key into the schema's
datalist, giving initial or example data for this parameter.
typesa list of types with keys referened from the schema's
paramslists'stypevalues. The values are a list with the following members:kindMandatory; one of:
'enum'Enumeration type
'column'A column from the input grid
valuesA vector of permitted values (only if
kind='enum')factorsOnly if
kind='enum'and this enum is used as the unit type for some column; a vector of factors to multiply column data by if the unit is changed by the user. Must have the same number of elements as thevaluesvector. For every n,factors[[n]]of unitvalues[[n]]must be equal. For example, ifvalues=c('mm', 'cm', 'inch')thenfactorscould bec(25.4, 2.54, 1.0).subtypeOnly if
kind='column'. The type of data that can be entered into the column. Currenly only'f'works well.unittypeOptional and only if
kind='column'. The name of an enum type defining the units that the data in this column can be expressed in.
dataA list of initial data with which table columns and controls will be populated. Can be a single value or vector (or list) as appropriate.
optiongroupsA list of option groups. Each one is a set of parameters that can be added as a block to functions that want them. Each element is a list with the following keys:
typeThe same as for
param'stype: either a key into the schema'stypeslist or one of the standard types ('b','u8','f'or'color').initialThe initial value for this option.
There is one special key in the
optiongroupslist; this is theframeworkkey. This is reserved for options that apply to the framework itself, not to any of your functions. So far, the only option it has isautorefresh=list(type="b", initial=FALSE). You can set its initial value toTRUEif you prefer. If you add this option, it controls whether the GUI has a "Calculate" button (FALSE) or whether the output should refresh a second or two after the user finishes changing parameters (TRUE).
Localization
To display human-friendly text on the controls and to get tooltip
help text, you need one or more localization files. These files
are named inst/www/locales/XX/app.json where
XX is replaced with the appropriate ISO language code.
These files are JSON files containing an object with the following keys:
titleText for the link to put in the top left
homepageDestination for the link to put in the top left
functionsOne pair of translations for each function in the schema.
paramsOne pair of translations for each parameter in the schema.
optiongroupsEach of the
optiongroupsin the schema gets a key which maps to an object which has the following keys:@titleA translation pair for the option group itself.
- ...
One translation pair for each option in the group.
typesOne object for each
'enum'type in the schema. Each value is an object with one key per possible enum value. Each value in this object is that enum value's translation pair.
A "translation pair" is an object with the following keys:
nameA short name
helpTooltip text
See Also
toolkit.loadFileButton