top of page

Display values in legend - Pie chart


The script below displays value of each items along with legend



Steps:

  1. Create a pie chart

  2. Add below script to widget

  3. Save the script and refresh widget


widget.on('processresult', function(se, ev){
	ev.result.legend.labelFormatter = function(){
		console.log(this)
		legendData = ev.result.series[0].data.find(el=>el.name == this.name).y
			
		myItem = se.metadata.panels[1].items[0]
		myMask = $$get(myItem, "format.mask", {})

		var numberFormatter = prism.$injector.get('$filter')('numeric');
		formattesValue = numberFormatter(legendData, myMask);
		
		return this.name + '<span style="color:#838584; font-size:12.5px"> <b> (' + formattesValue + ')</b></span>'
	}
})

1 commento

Valutazione 0 stelle su 5.
Non ci sono ancora valutazioni

Aggiungi una valutazione
Anne Springfield
Anne Springfield
15 mag 2024

Can I use this to remove a series label from a legend? The other solution posted doesn't work for pie charts.

Mi piace
BI Next Level white logo

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
Copyright © 2024. All Rights Reserved. Designed, Developed & Maintained  by Intertoons
bottom of page