Here are a few ready-to-use widget scripts to reorder or remove elements in your widget.
Replace the variables highlighted in bold with the appropriate values for your use case.
- Hide one or more columns in a table
- Remove pagination limitation in a pivot table
- Rename X-axis labels in charts
Note: Do not forget to refresh the widget page to see the result.
Hide one or more columns in a table
columnsToHide = [2,3] //specify the column(s) to hide
widget.transformPivot(
{},
function (metadata, cell)
{
columnsToHide.forEach(function(col) {
if (metadata.colIndex == col) { // Add a second condition ( && metadata.rowIndex > 0 ) if you want to keep the table header
cell.content = ' '
cell.style = {
maxWidth: '0px',
borderColor: 'white',
color: 'white'
}
}
})
}
);
Remove pagination from a pivot (does not work with tables)
This script lets you go beyond the limitation of 200 rows max per page.
widget.style.pageSize = "450"
Rename X-axis labels in charts
This script is useful if your fiscal year does not match the calendar year. You can rename quarters: 2025 Q1 instead of 2025 Q2, for example.
widget.on('processresult', function(widget,result) {
let dict =
//specify current label names and new label names
{ '2025 Q1':'2024 Q4',
'2025 Q2':'2025 Q1',
'2025 Q3':'2025 Q2',
'2025 Q4':'2025 Q3',
'2026 Q1':'2025 Q4',
'2026 Q2':'2026 Q1'
}
for (let i = 0 ; i < result.result.xAxis.categories.length ; i++) {
result.result.xAxis.categories[i] = dict[result.result.xAxis.categories[i]]
}
})
If the X-axis labels are in the "Break by" section (not in "Categories"), use this script instead:
widget.on('processresult', function(widget,result) {
let dict =
//specify current label names and new label names
{ '2025 Q1':'2024 Q4',
'2025 Q2':'2025 Q1',
'2025 Q3':'2025 Q2',
'2025 Q4':'2025 Q3',
'2026 Q1':'2025 Q4',
'2026 Q2':'2026 Q1'
}
result.result.series.forEach(function(ser) {
ser.name = dict[ser.name]
})
})
Comments
0 comments
Please sign in to leave a comment.