Forum Discussion

merinsverghese's avatar
merinsverghese
Cloud Apps
08-12-2024
Solved

how to change the color of Tree map

I would like to change the default color of the tree map. 

  • rapidbisupport's avatar
    rapidbisupport
    08-13-2024

    Hey merinsverghese ,

    If you wanted to use a widget script to change individual item colors, you could use the following:

    let colorConfig = [
    	{
    		name: 'Alabama',
    		color: '#ff0000'
        },
    	{
    		name: 'Alaska',
    		color: '#ff0000'
        },
    	{
    		name: 'Arizona',
    		color: '#ff0000'
        }
    ]
    
    widget.on('processresult', (w, args) => {
      let l = args.result.children.length
      for (let i = 0; i < l; i++) {
        let datum = args.result.children[i]
    	let rule = colorConfig.find((rule) => { return datum.name === rule.name })
    	if (rule === undefined) { continue }
    	datum.color = rule.color
      }
    })
    

    with result:

    Let me know how you go?

    Thanks,

    Daniel

    RAPID BI

    [email protected]

    RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons

5 Replies