cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
In some cases, it may be desirable to define the default location of a widget's navigation scroll bar. Users will still have the ability to expand and move the navigation scroller, but anytime the dashboard is reloaded, the scroller will default to the pre-defined position. 
The following widget script will default the navigation scroller to the maximum position. 
Configure the script via the displayBars variable. This is the number of bars that will be displayed. 
//======================= Configuration =======================
//Number of bars you would like to display, starting from the last bar
var displayBars = 10;
//================================================================

widget.on('processresult',function(widget,args){

     //define the maximum bar count to be the series length, minus 1 because the below is zero indexed. 
     var maxBarCount = (args.result.series[0].data.length - 1);

     args.widget.options.previousScrollerLocation.min = maxBarCount - displayBars + 1;
     args.widget.options.previousScrollerLocation.max = maxBarCount;
});
NAVIGATOR TO MINIMUM POSITION
The following widget script will default the navigation scroller to the maximum position. 
Configure the script via the displayBars variable. This is the number of bars that will be displayed. 
//======================= Configuration =======================
//Number of bars you would like to display, starting from the last bar
var displayBars = 10;
//================================================================

widget.on('processresult',function(widget,args){

     args.widget.options.previousScrollerLocation.min = 0;
     args.widget.options.previousScrollerLocation.max = displayBars - 1;
});
Rate this article:
Comments
JamesDavis
8 - Cloud Apps
8 - Cloud Apps

@intapiuser - The above is really useful, I don't suppose you or someone else may know how to adapt this to also include forecasts?  The script also seems to work for a line chart with dates across the x-axis, in that this will show me the last 14 days:

//======================= Configuration =======================
//Number of bars you would like to display, starting from the last bar
var displayBars = 14;
//================================================================

widget.on('processresult',function(widget,args){

     //define the maximum bar count to be the series length, minus 1 because the below is zero indexed. 
     var maxBarCount = (args.result.series[0].data.length - 1);

     args.widget.options.previousScrollerLocation.min = maxBarCount - displayBars + 1;
     args.widget.options.previousScrollerLocation.max = maxBarCount;
});

However, it doesn't show me the forecast period, just the actual data points:

JamesDavis_0-1705593582986.png

Ideally, I am looking for something that shows the last 14 days, and also the forecast period, like this:

JamesDavis_1-1705593629161.png

Thanks,
James

Version history
Last update:
‎03-02-2023 09:20 AM
Updated by:
Contributors