top of page

Switchable Measure Buttons

Here is a script to add buttons to switch between different measures/calculation.

For example, in below screenshot, each button represent different calculations and when we click on it, chart will show corresponding calculated values in Y-Axis. (The X-axis won't change)



Steps:


  1. Create a bar/column/line/are chart

  2. Widget should contain only one category(dimension). You can create as many Values panels as required and enable only one panel. The script will generate one button per Value panel and will be able to switch between panels by clicking on buttons.

3. Add below script to widget

4. Save the script and refresh widget



widget.on('processresult', function(se, ev){	
	ev.result.chart.marginTop= 60
});

widget.on("domready", function(w){
		
	chart = w.chart[0][Object.keys(w.chart[0])[0]].hc
	
	$.each(w.metadata.panels[1].items, function(index, value){
		chart.renderer.button(value.jaql.title, 10 + (index * 70), 10)
			.attr({
				zIndex : 10,
				height: 15,
				width: 50,
				'text-align': 'center'
			})
			.on('click', function() {						
				value.disable = false
				$.each(w.metadata.panels[1].items, function(itemIndex, itemValue){
					if(itemIndex == index)
						itemValue.disabled = false
					else
						itemValue.disabled = true
					
				})
				widget.refresh();
			})
			.add();

	})	
	
});

399 views2 comments

2件のコメント

5つ星のうち0と評価されています。
まだ評価がありません

評価を追加
Ryan Brownlee
Ryan Brownlee
2023年10月12日

Is there any way to add an all button?

いいね!

garrett
2023年6月28日

Is there anyway to give the ability to enable multiple values at once using 1 button? I have 4 values and want to display 2 of them using 1 button, and then the other 2 using a different button. Thanks.

いいね!
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