Package com.inductiveautomation.perspective.gateway.charts
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
- The project-load response carries the manager's content hash. The client keeps it for the life of the session.
- The front-end's
useChartStylehook picks a name — the session'schartStyleproperty if set, otherwise itstheme— and fetches that name plus the hash fromCanvasChartStyleRoutes, on thestyleorthemeroute respectively. - 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 intosystem. - Serving belongs to
CanvasChartStyleRoutesin thecommpackage. - 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().
-
ClassDescriptionOwns the gateway-scoped canvas chart style resources that supply ECharts theme JSON for Perspective canvas charts across every project on the gateway.Chart styles for an offline session, which can't fetch from the style route.