Skip to main content
Nintex Community Menu Bar

Set chart colours based on row values

  • July 8, 2024
  • 1 reply
  • 4 views

Forum|alt.badge.img+20

I’ve seen some use a snippet to set the colour index after setting the colours in the chart. I’d like to set the colours dynamically based on colour values stored on the record. Anybody done this so far?

Embarking on it right now. I’ll post here if I find a solution.

Starting here. https://api.highcharts.com/highcharts/series.column.colors

This topic has been closed for replies.

1 reply

Forum|alt.badge.img+20

Figured it out. 😃



function setChartSplitColours (chartObj,color_model,color_index,color_field){ var chartcolors = [], colorIndex = [], ind, series = chartObj.series; $.each(color_model.getRows(), function(r,row){ index = row[color_index].replace(/[

]+/g, ''); if (typeof row[color_field] !== 'undefined'){ chartcolors.push('#' + row[color_field]); colorIndex.push({index: index,color: row[color_field]}); } else { chartcolors.push('#000000'); colorIndex.push({index: index,color: '000000'}); } }); $.extend(true,chartObj,{ colors: chartcolors }); $.each(series, function (i, s_point){ $.each(colorIndex, function (c,cIndex){ if(s_point.id.replace(/[

]+/g, '') == cIndex.index){ ind = c; return false; } }); // update series index number and color index with ind variable. $.extend(true, series[i],{ index: ind, _colorIndex: ind }, { index: ind, _colorIndex: ind }); }); }<br>