Set chart colours based on row values

Pat VachonPat Vachon Member ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
edited June 25 in Ideas
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.ย
1 votes

Awaiting Review ยท Last Updated


  • Pat VachonPat Vachon Member ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited June 25
    Figured it out. :D

    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([

    ]+/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 }); }); }
Sign In or Register to comment.