top of page

Pivot2 - Spread color from one column to entire row

Updated: Nov 27, 2024

Currently, in pivot, we can set colors to a column based on its value. In that case color will get applied to only that column. Below script will spread color from a column to entire row


ree


widget.on('ready', function(se, ev) {
	
	panelName = 'Value 1' //Update your panel name from which color needs to spread to entire row
	
	 if (prism.activeWidget == null)
	   widgetelement = $('[widgetid="'+ se.oid + '"] pivot2 .pivot-scroller table tbody tr')
	 else
	   widgetelement = $('.pivot-scroller table tbody tr', element)
	   
	var colIndex = -1
	$(widgetelement).each(function(index, trElement){ 
		if(index == 0)
		{
			$(trElement).find('td .table-grid__content .table-grid__content__inner').each(function(tdIndex, tdElement){
				if ($(tdElement).text() == panelName){
					colIndex = tdIndex
				}
			})
		}
		else{
			if(colIndex >= 0){
				bgColor = $(trElement).find('.table-grid__cell--col-' + colIndex).css('backgroundColor')
				$(trElement).find('td').each(function(tdIndex, tdElement){
					 $(tdElement).css('backgroundColor', bgColor)
				})

				$(widgetelement).each(function(rowIndex, rowElement){
					if(rowIndex > 0 && index == rowIndex){
						$(rowElement).find('td').css('backgroundColor', bgColor)
					}
				})
			}
		}

	})
})




Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

BI Next Level is your trusted resource for BI customization, data solutions, and expert insights. Explore practical tips, scripts, and tutorials for tools like Sisense, Python, and SQL. Let’s transform your data into impactful insights together.

Quick Links
Connect with us
bottom of page