Startup Configuration#
When webvis creates a context, it collects the context's initial settings from several sources. This page explains where those sources live and which one wins when they disagree. Once the context exists, you can read and change settings via the SettingsAPI.
Who creates the context?
The initial settings of a webvis context depend on who creates it:
-
Your code calls requestContext: webvis reads the settings object you pass in, plus the hub's and the app's
webvis.config.jsonfiles. It does not look at URL parameters,<webvis-config>elements or the browser's local storage. -
A webvis UI element creates it: UI elements like
<webvis-full>and<webvis-viewer>use the context named by theircontextattribute ("default_context"by default) and create it if it does not exist yet. In that case, the element collects the settings itself, and the rules described below do not apply:- Besides the config files, it also reads the
<webvis-config>element, the page's URL parameters and the settings stored in the browser's local storage. The stored settings are applied last and override all other sources. - It loads the hub's config file from next to
webvis.js, not from the finalhubURL.
If your code has already created a context with that name, the element uses it as it is and applies none of these sources.
- Besides the config files, it also reads the
With requestContext
This section applies only to contexts that your code creates via requestContext.
Sources and precedence
Sources of initial context settings, from lowest to highest priority. A later source overrides an earlier one:
- Built-in defaults, documented in SettingStrings and ViewerSettingStrings.
- The hub's config file:
<hubURL>/repo/webvis/webvis.config.json. - Your app's config file:
webvis.config.jsonin the same directory as the page that runs webvis. - The settings object passed to
requestContext.
A config file that is missing, unreachable or not valid JSON is skipped silently, and startup continues with the remaining sources.
Which hub's config file is used
The hub config file comes from the hub that the context connects to, i.e. from
the final hubURL. webvis takes that from the first of these that is set:
hubURLin the settings objecthubURLin your app'swebvis.config.json- If the URL of the loaded
webvis.jsscript contains/repo/webvis/, everything before that is used as hub URL.
So if you pass a custom hubURL, the config file of that hub is loaded, not
the one of the hub that served webvis.js.
Turning config files off
Pass loadRemoteConfigFile: false in the settings object to skip both config
files. Only the settings object counts here: setting loadRemoteConfigFile inside
a config file does not stop the files from being loaded.
const context = await webvis.requestContext("my-context", {
hubURL: "https://your-hub.example.com/",
loadRemoteConfigFile: false
});