Package com.inductiveautomation.perspective.gateway.charts


package com.inductiveautomation.perspective.gateway.charts
Gateway-scoped management of Perspective canvas chart styles.

Canvas charts render through ECharts, which takes its colors, fonts, and axis styling from a theme JSON object. Each style is a CanvasChartStyleConfig resource, shared by every project on the gateway. CanvasChartStyleManager registers the resource type, seeds the bundled styles, and resolves a requested name to the JSON to serve.

Bundled styles

The light and dark styles are published into the platform's system collection during setup() and marked non-overridable, so nothing written to core can replace them. They are rebuilt from the classpath on every startup and never persisted, so a new build ships new content without a migration.

Data flow

  1. The project-load response carries the manager's content hash. The client keeps it for the life of the session.
  2. The front-end's useChartStyle hook picks a name — the session's chartStyle property if set, otherwise its theme — and fetches that name plus the hash from CanvasChartStyleRoutes, on the style or theme route respectively.
  3. The route asks the manager to resolve the name — by resource name for a style, by theme assignment for a theme — and returns the ECharts JSON, which the hook registers with ECharts. The hook fetches again whenever the chosen name changes.

The hash only busts the HTTP cache: responses are immutable, and any style edit yields a new hash and a new URL. Because a session's hash never changes, edits reach only sessions started after them. Project style classes and symbol styles differ: their hashes arrive with project updates and are applied immediately.

Runtime boundaries

  • Editing and persistence belong to the platform configuration framework, through the generic /data/api/v1/resources/... REST API and the Gateway web UI. The manager never writes authored styles; it only writes the bundled styles into system.
  • Serving belongs to CanvasChartStyleRoutes in the comm package.
  • Bundled style content lives in common-scoped ChartStyleUtil.

Ownership

The manager is the only source of truth for the styles and their hash; don't cache either elsewhere. GatewayHook.PerspectiveGatewayContext constructs it and exposes it through getChartStyleManager(). GatewayHook drives its setup(), startup(), and shutdown().