Forum Discussion

Camantea's avatar
Camantea
Cloud Apps
12-14-2022

Automated Widget Titles

Hi All,

I am wondering if anyone has had any success in automating the title of a widget within a dash using the widget script. I am trying to have the title update the month automatically when a filter is applied. For example, trying to show "November Sales Trend" and have this title update when a new filter for the month of sale is selected. I found the below script would work for adjusting the title, but just need the script to grab the Current Month now.


widget.on('ready', function(w,e){
prism.activeWidget.title= 'November Venue Sales' /* this changes the title
})

Thanks in advance for any suggestions!

3 Replies

Replies have been turned off for this discussion
  • HamzaJ's avatar
    HamzaJ
    Data Integration

    Hey Camantea ,

    I am using the following script to achieve that. I think you need to adjust it a little bit to suit your needs:

    widget.on('ready', function(w,e){ 
    var currentDate = new Date();
    var date = currentDate.getDate();
    var month = currentDate.getMonth(); 
    var year = currentDate.getFullYear();
    var monthDateYear  = date + "-" + (month+1) + "-" + year;
    prism.activeWidget.title='Current Date: ' + monthDateYear;
    });
  • Hi, I'd like to do something similar based on which value has been enabled. This is on a line chart with multiple values and a break by. Unfortunately, the Title of the Y-Axis doesn't reflect the name of the enabled value automatically. I'd like to update the Y-Axis Title and the widget title with the title of the enabled value. Can you point me in the right direction? Thanks in advance.