top of page

Dynamic widget title and axis label

There can be situations where we need to display widget title and axis labels based on selected item in filter. Here is a script to achieve it

Here, selected region in filter is displayed in widget title and in X-axis label


Steps:

  1. Create a widget

  2. Add below script to widget. Update the variable 'filterName' with name of filter

  3. Save the script and refresh widget


widget.on('processresult', function(se, ev){
	
	filterName = 'Region' //Name of filter
	
	selectedFilter = widget.dashboard.filters.$$items.find(el=>el.jaql.title == filterName).jaql.filter.members[0]
	ev.result.xAxis.title.text =  selectedFilter + ' Values'
	ev.widget.title = 'Total values by year: ' + selectedFilter 

})

2件のコメント

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

評価を追加
Shnakepup
2024年9月20日
5つ星のうち3と評価されています。

When I tried to use this, it didn't seem to work. I think the issue is with the "selectedFilter" variable. If I replace your code with just static text then the script works just fine; that is, it'll change the widget title to what was defined. However, if I use the original code you had (starting with "widget.dashboard.filters.$$items.find...") then it doesn't work. Is it possible it's a compatibility issue? My company is using an older Windows version of Sisense, not the more modern Linux version.

いいね!

Ebrahim Ghazvini Zadeh
Ebrahim Ghazvini Zadeh
2023年5月11日

how can i change this code to get the date filter from and to into the title?

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