harikm007
03-22-2022Data Warehouse
Display widget in tooltip
By default values and labels are displayed in tooltip. Also its possible to add additional information to tooltip by using script . Sometimes it would be more helpful to display a widget as tooltip (Reference)
Steps:
-
Create base chart - the chart in which we need to add tooltip.
-
Create a dashboard and add a widget that needs to be displayed as tooltip. Size of widget in this dashboard should be small enough to fit in to the tooltip.
- Add below script to base chart and update the variable 'dashboaardurl' with URL of dashboard we created for tooltip.
var category
widget.on('beforedatapointtooltip', function(se, ev){
dashboardurl = 'https://XXXX.sisense.com/app/main#/dashboards/6612346ac77683002ea37645'
redrawYN = category != ev.context.category
category = ev.context.category
filterPanel = ev.widget.metadata.panels[0].items[0].jaql
filterPanel.filter = {
explicit: true,
members: [category],
multiSelection: true
}
filterjaql = {jaql: filterPanel}
var filtersArray = [filterjaql];
var filterString = JSON.stringify(filtersArray);
var uriEncoded = encodeURIComponent(filterString);
ev.template = `<iframe width="100%" frameborder="0"
src="${dashboardurl}?embed=true&r=false&filter=${uriEncoded}"></iframe>`
if(redrawYN)
se.redraw()
})
Note:
-
Supported widget - Line chart, Column chart, Bar chart, Pie chart
-
Currently this script doesn't support widget with 'breakby' panel.
-
Tooltip may take few seconds to load as it is actually a dashboard.
-Hari