Class ChartStyleUtil

java.lang.Object
com.inductiveautomation.perspective.common.config.charts.util.ChartStyleUtil

public final class ChartStyleUtil extends Object
The canvas chart styles that ship with the module, and the fallback used when nothing else matches.

The source of truth for bundled style content, read two ways:

  • CanvasChartStyleManager seeds BUNDLED_STYLE_NAMES into the platform's system collection at startup via bundledConfig(String), making each one an ordinary resource the Gateway web UI and REST API can read.
  • getDefaultStyleJson(String) answers a request for a theme no configured style claims, so a custom Perspective theme still renders sensibly before anyone authors a style for it.

Resolving a name against the configured styles needs the resource collection, which only the gateway has; see CanvasChartStyleManager#getStyleJsonByName and CanvasChartStyleManager#getStyleJsonForTheme.

DEFAULT_LIGHT and DEFAULT_DARK are mutable process-wide statics: treat what getDefaultStyleJson(String) returns as read-only. bundledConfig(String) deep-copies for you.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final List<String>
    Resource names of the styles bundled with the module, in the order they should be seeded.
    static final String
     
    static final com.inductiveautomation.ignition.common.gson.JsonObject
    Bundled dark ECharts theme JSON, read once from the classpath at class init.
    static final com.inductiveautomation.ignition.common.gson.JsonObject
    Bundled light ECharts theme JSON, read once from the classpath at class init.
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Builds the full config for a bundled style, ready to be encoded into a resource.
    static String
    Author-facing description for a bundled style, stored as the resource's documentation rather than in its config.
    static com.inductiveautomation.ignition.common.gson.JsonObject
    getDefaultStyleJson(@Nullable String themeName)
    Returns the bundled default for themeName: the dark style when the name contains "dark", the light style otherwise.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LIGHT

      public static final String LIGHT
      See Also:
    • DARK

      public static final String DARK
      See Also:
    • BUNDLED_STYLE_NAMES

      public static final List<String> BUNDLED_STYLE_NAMES
      Resource names of the styles bundled with the module, in the order they should be seeded.
    • DEFAULT_LIGHT

      public static final com.inductiveautomation.ignition.common.gson.JsonObject DEFAULT_LIGHT
      Bundled light ECharts theme JSON, read once from the classpath at class init.
    • DEFAULT_DARK

      public static final com.inductiveautomation.ignition.common.gson.JsonObject DEFAULT_DARK
      Bundled dark ECharts theme JSON, read once from the classpath at class init.
  • Method Details

    • bundledConfig

      public static CanvasChartStyleConfig bundledConfig(String name)
      Builds the full config for a bundled style, ready to be encoded into a resource.
      Parameters:
      name - one of BUNDLED_STYLE_NAMES.
      Throws:
      IllegalArgumentException - if name is not a bundled style.
    • bundledDescription

      public static String bundledDescription(String name)
      Author-facing description for a bundled style, stored as the resource's documentation rather than in its config.
      Parameters:
      name - one of BUNDLED_STYLE_NAMES.
      Throws:
      IllegalArgumentException - if name is not a bundled style.
    • getDefaultStyleJson

      public static com.inductiveautomation.ignition.common.gson.JsonObject getDefaultStyleJson(@Nullable String themeName)
      Returns the bundled default for themeName: the dark style when the name contains "dark", the light style otherwise. The returned object is shared — treat it as read-only.