Knowledge Base Article

Add a color for the chart legend with conditional value [Linux]

Add a color for the chart legend with conditional value | Linux L2025

Step-by-Step Guide: 

If you created a chart with a value that has a conditional color, the legend for it by default will be grey. 

 

This is sometimes not very convenient.

 

 

To improve this, press a pencil to edit the widget. Press 3 dots - Edit script.

In the new window, paste the following code:

const colorsSet = {

1: '#ff0000'

};


widget.on('beforeviewloaded', (scope, args) => {

args.options.series.forEach((seria, index) => {

seria.color = colorsSet[index];

})

})

Here, the #ff0000 is a new color of the legend.

Press the Save button to save the changes and then refresh the dashboard to view them.

 

If you have more than one conditional value, f.e 2

 

 

Just add one more line to the JavaScript code:

const colorsSet = {
1: '#ff0000',
2: '#d108f5'

};


widget.on('beforeviewloaded', (scope, args) => {
args.options.series.forEach((seria, index) => {
seria.color = colorsSet[index];

})
})

The result is that both of them have a color.

Conclusion: 

This easy step can help you make your dashboard look better.


Disclaimer: This post outlines a potential custom workaround for a specific use case or provides instructions regarding a specific task. The solution may not work in all scenarios or Sisense versions, so we strongly recommend testing it in your environment before deployment. If you need further assistance with this, please let us know.

Published 08-15-2025
No CommentsBe the first to comment