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 |
getOrRegisterColor(key) | Gets the color (hex code) associated to the given |
getChartColorPalette() | Gets the color palette with the given By default, there are two color palettes already registered: |
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 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 Returns the color currently registered for the given key. |
registerColorPalette(name, colors) | Registers a new color palette for the given If a color palette already exists for the given name, it is overwritten. |