Class CanvasChartStyleManager
- All Implemented Interfaces:
Lifecycle
Each style is its own named resource (one directory, one config.json), so the platform
gives create/rename/duplicate/delete, per-style metadata, and per-style validation for free. The
manager registers the resource type — which is what mounts the generic
/data/api/v1/resources/... REST API the Gateway web UI edits through — seeds the bundled styles,
and resolves a requested name to the JSON that gets served.
Styles reach the front-end through CanvasChartStyleRoutes, keyed off a content
hash that rides the project-load response. A running session does not learn about a style edit —
the hash, and the style it resolves to, are fixed for the life of the session; a new value is
only picked up on the next session load.
Lifecycle: call setup() once from the module hook's setup() phase (it must
run before the platform ConfigurationManager mounts the generic resource routes,
otherwise the type's REST routes never mount), then AbstractLifecycle.startup() from startup() and
AbstractLifecycle.shutdown() on module shutdown.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordChart styles for an offline session, which can't fetch from the style route.Nested classes/interfaces inherited from class NamedResourceHandler
NamedResourceHandler.Builder<R> -
Field Summary
Fields inherited from class NamedResourceHandler
configManager, logger, meta -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull StringgetOfflineChartStyles(Collection<String> themeNames) com.inductiveautomation.ignition.common.gson.JsonObjectgetStyleJsonByName(@Nullable String styleName) Returns the ECharts theme JSON for the style stored understyleName— what a page author'schartStyleproperty names.com.inductiveautomation.ignition.common.gson.JsonObjectgetStyleJsonForTheme(@Nullable String themeName) Returns the ECharts theme JSON for the Perspective themethemeName: the first style whoseCanvasChartStyleConfig.themes()claims it, or else the bundled default derived from the name (seeChartStyleUtil.getDefaultStyleJson(String)).static StringReturnstextwith control characters and line breaks replaced, so text taken from a request or a resource name logs as one line.protected voidonResourcesUpdated(List<DecodedResource<CanvasChartStyleConfig>> resources) Called each time the overall set of resources changes in any way.voidsetup()Registers the resource type and seeds the bundled styles.Methods inherited from class NamedResourceHandler
create, create, create, decode, delete, delete, filter, findResource, getResources, isCaseSensitive, isRenameAware, modify, modify, modify, newBuilder, newUuid, onInitialResources, onResourceAdded, onResourceRemoved, onResourceUpdated, onShutdown, onStartup, renameAndModify, renameAndModify, renameAndModify, renameAndModifyMethods inherited from class AbstractLifecycle
isRunning, shutdown, startup
-
Constructor Details
-
CanvasChartStyleManager
-
-
Method Details
-
setup
public void setup()Registers the resource type and seeds the bundled styles. Must run before the platform'sConfigurationManagermounts the generic resource routes in its ownonStartup(). -
onResourcesUpdated
Description copied from class:NamedResourceHandlerCalled each time the overall set of resources changes in any way. Called after added, updated, and removed are called.- Overrides:
onResourcesUpdatedin classNamedResourceHandler<CanvasChartStyleConfig>
-
loggable
-
getStyleJsonByName
public com.inductiveautomation.ignition.common.gson.JsonObject getStyleJsonByName(@Nullable String styleName) Returns the ECharts theme JSON for the style stored understyleName— what a page author'schartStyleproperty names. The name is matched against resource names only, bundled styles included, so"light"always means the bundledlightstyle, even when an authored style claims thelighttheme. A name matching no style falls back to the bundled default derived from the name (seeChartStyleUtil.getDefaultStyleJson(String)) and logs a warning once per name, since the style was most likely renamed or deleted and the session would otherwise switch styles with no sign of why.The returned object is shared — treat it as read-only and deep-copy before mutating.
-
getStyleJsonForTheme
public com.inductiveautomation.ignition.common.gson.JsonObject getStyleJsonForTheme(@Nullable String themeName) Returns the ECharts theme JSON for the Perspective themethemeName: the first style whoseCanvasChartStyleConfig.themes()claims it, or else the bundled default derived from the name (seeChartStyleUtil.getDefaultStyleJson(String)).Resource names play no part here. The bundled styles claim every shipped theme of their mode, and
resolutionOrder()puts authored styles ahead of them, so "copy a bundled style and assign it the theme" makes the copy win.The returned object is shared — treat it as read-only and deep-copy before mutating.
-
getOfflineChartStyles
public CanvasChartStyleManager.OfflineChartStyles getOfflineChartStyles(Collection<String> themeNames) -
getStyleNames
-
getChartStylesHash
- Returns:
- a string identifying the current canvas chart styles, used purely to cache-bust the style route. Built from the platform's per-resource content digests, so it changes whenever a style's content changes and whenever one is added or removed.
-