Legacy Mode#

Legacy mode emulates the global webvis object as it worked before webvis 3.6.0. It was introduced in 3.6.0 to give existing apps time to migrate, and it will be removed with webvis 3.15.0. From then on there is no way to turn it back on, so apps that depend on it have to migrate before they upgrade. This page explains what legacy mode does, how to tell whether your app depends on it, and how to migrate.

webvis version Mode ?next ?legacy
before 3.6.0 — — —
3.6.0 to 3.14.x Legacy mode by default Turns legacy mode off Forces legacy mode
from 3.15.0 Regular mode only Removed, no longer needed Removed, has no effect

webvis 3.15.0 is planned for release in Q2 2027.

Both parameters are set on the URL of the webvis script, not on the URL of your page:

<script src="https://your-hub.example.com/repo/webvis/webvis.js?next"></script>

There is no fallback in 3.15.0. An app that depends on legacy mode and has not been migrated will not work after the upgrade. Until it is migrated, it has to stay on webvis 3.14.x.

Since 3.6.0, the global webvis object is a pure namespace: it groups types, enums and events, and offers functions such as requestContext to create and retrieve contexts. Your app creates a context explicitly and calls the API on that context.

In legacy mode, webvis additionally does the following as soon as the script has loaded:

  • It creates a context named "default_context" and initializes it with the settings from the config files, the <webvis-config> element, the page's URL parameters and the browser's local storage.
  • It copies all functions and properties of that context onto the global webvis object, so that calls like webvis.add(...) or webvis.setProperty(...) keep working.
  • It defines the deprecated global functions webvisContext(id) and webvisViewer(id).

On a webvis version before 3.15.0, your app runs in legacy mode if it loads webvis.js without ?next or with ?legacy. In that case:

  • The browser console shows the message "Your webvis library is running in legacy mode" when webvis loads.
  • The <webvis-viewer> element shows a Legacy Mode warning.

Your app depends on legacy mode if it does at least one of the following:

  • It calls context functions directly on the global object, for example webvis.add(...), webvis.registerListener(...) or webvis.getViewer().
  • It calls webvisContext() or webvisViewer().
  • It expects a context to exist without creating one and without using a webvis UI element.

The quickest check on a version before 3.15.0 is to add ?next to the script URL and test your app. Everything that still works is unaffected by the removal.

The hub serves a ready-made webvis app at <hubURL>/repo/webvis/webvis-app.html. Before 3.15.0, this app loads webvis.js without ?next. It therefore runs in legacy mode and shows the Legacy Mode warning.

If you use the default app as it is, for example embedded in an <iframe>, switch to webvis-app-next.html. It is the same app, but loads webvis.js with ?next, so it runs in regular mode and shows no warning:

https://your-hub.example.com/repo/webvis/webvis-app-next.html

If your code calls the API of the default app from outside, for example via the contentWindow of the <iframe>, it has to follow the migration steps below, as the context functions are no longer available on the global webvis object.

From 3.15.0 on, webvis-app.html runs in regular mode as well, and webvis-app-next.html stays available as an alias. Embeds that switch now keep working after the upgrade.

How you get the context depends on whether your app uses the webvis UI elements.

With <webvis-full> or <webvis-viewer>: the element creates the context for you and collects the same settings as legacy mode did. Request the context and the viewer from the element:

const element = document.querySelector("webvis-viewer");
const context = await element.requestContext();
const viewer  = await element.requestViewer();

Without UI elements: create the context and the viewer yourself.

const context = await webvis.requestContext("my-context");
const viewer  = context.createViewer("my-viewer", document.getElementById("my-canvas"));

A context created via requestContext does not read the page's URL parameters, the <webvis-config> element or the browser's local storage. See Startup Configuration for the sources it does read.

Legacy mode Replacement
webvis.add(...) context.add(...)
webvis.<any ContextAPI function>() context.<function>()
webvis.getViewer() context.getViewer()
webvisContext(id) webvis.getContext(id)
webvisViewer(id) webvis.getContext(name).getViewer(id)

Enums, events and types stay on the namespace and need no change, for example webvis.EventType.NODE_CHANGED or webvis.Property.ENABLED.

Note that webvisContext(id) created a missing context on the fly, while getContext returns undefined if no context with that name exists. Use requestContext to create one.

Once your app runs without legacy mode, update the script URL:

  • Before 3.15.0: load webvis.js with ?next. If the URL contains ?legacy, replace it with ?next. Without ?next, webvis still starts in legacy mode.
  • From 3.15.0 on: remove ?next and ?legacy, as neither has an effect anymore.
  • Migration Guide 3.6.0: the release that introduced the context-based API and legacy mode, including the full list of API changes. It is not part of the public documentation portal anymore, but it ships with webvis on your hub at <hubURL>/repo/webvis/doc/migration-guides/migration-guide-360.html.
  • Development Setup: how to load webvis and use it with TypeScript.