Forum Discussion

2 Replies

Replies have been turned off for this discussion
  • harikm007's avatar
    harikm007
    Data Warehouse

    cartercjb Here is an alternate solution where you can manually specify list of colors. Update the colorList array with list of colors. Make sure there are enough colors in colorList - if the widget has 5 unique value, there should at least 5 colors in colorList array.

    If the array is empty it will pick colors from dashboard color palette.

    widget.on('processresult', function(se, args){
    
    	colorList = ['#ed6258', '#eda258', '#edcf58', '#58ed91', '#58deed', '#5894ed', '#ed58ed', '#ed5862','#be58ed', '#9ded58']
    	
    	if(colorList.length == 0)
    		colorList = prism.activeDashboard.style.options.palette.colors
    
    	valueList = []
    	
    	$.each(args.result.series[0].data, function(index, value){
    		if(!valueList.includes(value.y))
    			valueList.push(value.y)
    	})
    
    	$.each(valueList, function(index, value){
    		dataList = args.result.series[0].data.filter(el => el.y && el.y == value)
    		
    		$.each(dataList, function(dataIndex, dataValue){
    			dataValue.color = colorList[index]
    		})
    	
    	})
    
    })

    Result:

    Thanks

    -Hari