cancel
Showing results for 
Search instead for 
Did you mean: 
JeremyFriedel
Sisense Team Member
Sisense Team Member
Using the Color Palette Parameter of Sisense Dashboards in Scripts and Plugins

Like many other dashboard parameters, the color palette of a Sisense dashboard can be accessed and modified in scripts and plugins for customization and additional use cases.

Sisense plugins, especially those creating new widget types, commonly utilize the dashboard palette attribute to ensure visual consistency with other widgets on the dashboard. Native Sisense widgets also employ the dashboard palette color attribute for uniform default coloring throughout the dashboard.

Sisense dashboards and widgets scrips can access or modify the palette attribute. In the past, many plugins and scripts referred to the dashboard color palette using the object path:

 

 

prism.activeDashboard.style.options.palette.colors

 

 

However, in newer versions of Sisense (post-2023.5), the palette is accessed using a modified object path:

 

 

prism.activeDashboard.style.$$palette.colors

 


Screen Shot 2024-01-10 at 9.20.12 PM.png


To prevent errors in scripts and plugins caused by an undefined palette variable, updating the object path from the older version to the new one will fix the issue in most cases. A console error indicating that the palette variable is undefined likely indicates the object path to the palette should be updated.

The Sisense dashboard palette.colors attribute is an array of HTML colors.

Here's an example of programmatically using the palette parameter:

 

function processCategory(curCategory, ord) {
    var curColor = getColor(curCategory);
    if (curColor == null) {
        localColorDictionary[curCategory] = palette[ord % palette.length];
    }
};

 


The provided code assigns a color to a category in a chart based on the existing dashboard color palette. This code can be incorporated into a plugin or script.

Palette modification can also be done programmatically, where the palette is reassigned in a script or plugin:

 

var palette = [
    "#82C341",
    "#709C96",
    "#A7E8E0",
    "#95A4B9",
    "#23A871",
    "#E67630"
];

 


Standard HTML color codes can be used for the palette.

The Sisense dashboard palette attribute serves the dual purpose of accessing and modifying the current dashboard color set. This functionality allows widgets, including those created through custom plugins, to maintain consistent coloring.

Sisense palettes can also be edited and accessed via the API.

 

Share your experience in the comments! 

Rate this article:
Version history
Last update:
‎01-11-2024 11:37 AM
Updated by: