PA WoW Chart – Show Week Date Range Instead of “W3 2026” on X‑Axis

pradyumnach
Tera Contributor
I’m working with Performance Analytics weekly (WoW) trend charts and looking for guidance.

Requirement

In PA widgets, the X‑axis currently shows week labels like:

W3 2026, W4 2026

Instead, I’d like to show the actual calendar date range for the week, including year, for example:

13 Jan 2026 – 19 Jan 2026

This is mainly for executive / audit‑ready dashboards, where week numbers are not intuitive.

1 REPLY 1

Naveen20
ServiceNow Employee

You may try this

Clone the  widget and overriding the Highcharts X-axis formatter, since it preserves all OOB PA functionality while giving you full label control.

Server Script — build a week-label → date-range map from pa_bucket:

var gr = new GlideRecord('pa_bucket');
gr.addQuery('bucket_group.frequency', 'Weekly');
gr.addQuery('start_date', '>=', options.start_range);
gr.orderBy('start_date');
gr.query();

var map = {};
while (gr.next()) {
    var sd = new GlideDateTime(gr.getValue('start_date'));
    var ed = new GlideDateTime(gr.getValue('end_date'));
    map[gr.getDisplayValue('name')] = 
        sd.getDisplayValueInternal().substring(0, 10) + '|' + 
        ed.getDisplayValueInternal().substring(0, 10);
}
data.bucketMap = map;

Client Script — after the chart config is assembled, inject the formatter:

var bMap = c.data.bucketMap;

chartConfig.xAxis.labels.formatter = function () {
    var range = bMap[this.value];
    if (range) {
        var parts = range.split('|');
        return formatDate(parts[0]) + ' – ' + formatDate(parts[1]);
    }
    return this.value;
};

function formatDate(ymd) {
    var d = new Date(ymd);
    var months = ['Jan','Feb','Mar','Apr','May','Jun',
                  'Jul','Aug','Sep','Oct','Nov','Dec'];
    return d.getDate() + ' ' + months[d.getMonth()] + ' ' + d.getFullYear();
}

This turns W3 2026 into 13 Jan 2026 – 19 Jan 2026 on the axis while keeping all PA drill-down, scoring, and breakdown behavior intact.