cancel
Showing results for 
Search instead for 
Did you mean: 
TriAnthony
Sisense Team Member
Sisense Team Member

This dashboard script allows you to add subtitles/description right under the widget title. To add a subtitle/description add ' - ' after the widget title, followed by the subtitle text. Long text will automatically wrap. To add another line break within the subtitle, add another ' - '. For example:

"Revenue over time - This widget shows revenue over time, this is useful for predicting future revenue - Data is available from 2009 to 2013"

The script will convert the text above into:

"Revenue over time

This widget shows revenue over time, this is useful for predicting future revenue

Data is available from 2009 to 2013"

Note:

You'll only see the changes in View mode, not in Edit mode.

Limitation:

This doesn't work on PDF export.

TriAnthony_0-1651175924930.png

 

 

 

//Change widget title height to Auto
dashboard.on('widgetready',function(d) {

	$('.widget-header--title-edited').css('height', 'auto');

});


//Convert widget title into title and description
dashboard.on('widgetinitialized', function (dash_ev, dash_se) {
    dash_se.widget.on('ready', function (ev, se) {
        let widgetID = dash_se.widget.oid
        let selectorString = `[widgetid='${widgetID}']`
        let widgetParent = $(selectorString).parent()
        let titleElement = widgetParent.find('.widget-title__holder > widget-title');
        let titleParentElement = titleElement.parent()
        let titleAttribute = titleElement.attr('title');

        str = titleAttribute;

        strArray = str.split(' - ')

		if (strArray.length <= 1) {
			return;
		}

        strNew = '<span style=\"font-size:14px;\">' + strArray[0] + '</span>';

        for (i = 1; i < strArray.length; i++) {
            strNew = strNew + '<p style=\"font-size:10px;word-break:normal;white-space:normal;padding: 11px 0 0 0;line-height: 11px;\">' + strArray[i] + '</p>'
        }

        strHTML = jQuery.parseHTML(strNew);
        
        titleParentElement.empty().append(strHTML);

    })
});

 

 

 

 

Comments
HamzaJ
10 - ETL
10 - ETL

Amazing. Thanks @TriAnthony 

I have added the following:

 

let desc= dash_se.widget.desc

 

to automatically get the widget description and changed the strNew to 

 

        for (i = 1; i < strArray.length; i++) {
            strNew = strNew + '<p style=\"font-size:10px;word-break:normal;white-space:normal;padding: 11px 0 0 0;line-height: 11px;\">' + desc + '</p>'
        }

it now auto-adds the widget-description (we have all of our widgets described)

Hamza

 

Version history
Last update:
‎05-04-2022 01:07 PM
Updated by:
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Need additional support?:

Community Support Request