Forum Discussion
Love that and looks like the right idea. Does it matter that I don't have a field on Categories or Break By, because I'm not seeing this have any effect, and throwing a console.log(categoryName) in there doesn't output anything.
The script needs to be adjusted slightly if the Categories or Breakby fields are not present. Here's the updated version.
widget.on('processresult', function(se,ev){
var colorMapping = {
'Level A': 'red',
'Level B': 'green',
'Level C': 'blue',
'Level D': 'yellow'
}
$.each(ev.result.series, function(seriesIndex, seriesValue){
const seriesName = seriesValue.name;
first_part = seriesName.includes('-') ? seriesName.split('-')[0].trim() : seriesName;
second_part = seriesName.includes('-') ? seriesName.split('-')[1].trim() : seriesName;
$.each(seriesValue.data, function(index, value){
value.color = {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, (first_part in colorMapping ? colorMapping[first_part] : 'gray')],
[1, (second_part in colorMapping ? colorMapping[second_part] : 'gray')]
]
}
})
})
})
-Hari
- wallingfordce05-20-2025Data Pipeline
Closer, and really appreciate it. Seems like it's stuck only returning the first seriesName for all series
logging seriesName to console right after it's set each time shows all the different series names, but logging it inside the seriesValue.data loop logs the first series name every time.
- DRay06-04-2025Admin
Hi harikm007,
Thank you for your help so far. You have been great, as always! Are you able to help with this last bit?
- harikm00706-04-2025Data Warehouse
To reproduce the same, can you share a screenshot of the left-side panel of the widget where you added categories and values?
The above script can be applied when there is only Values panel.- wallingfordce06-05-2025Data Pipeline