ColorManager

Prev Next

To manage colors in a centralized way, you can leverage the ColorManager, which is available in the JavaScript context under the variable colorManager.

It provides methods to manage color palettes that can be used by components like widgets and filters.

// registers a new color to be used when the HEATING string must printed out.
colorManager.registerColor("HEATING", "#DD4B39");

// retrieves a registered color.
colorManager.getColor("HEATING");

// registers a new color palette.
colorManager.registerColorPalette("my-colors", ["#DD4B39", "FFD800", "#08B05B"]);

Methods

getColor(key)

Gets the color (hex code) associated to the given key (case-insensitive).

getOrRegisterColor(key)

Gets the color (hex code) associated to the given key (case-insensitive).
In case the color is missing, a new one is registered by using the values color palette.

getChartColorPalette()

Gets the color palette with the given name.

By default, there are two color palettes already registered: values, chart

getColorPalette(name)

Gets the color palette (chart) used by chart-based widget to draw lines, columns and other graphic elements.

registerColor(key, color)

Registers a new color for the given key (case-insensitive) and color (hex code).

If the key is already present, the registered color is overwritten.

In case the given color in null, a color not already used is picked up from the values color palette and assigned to the given key.

Returns the color currently registered for the given key.

registerColorPalette(name, colors)

Registers a new color palette for the given name.
The colors parameter is an array of hex codes.
["#DD4B39", "FFD800", "#08B05B"]

If a color palette already exists for the given name, it is overwritten.