MarkZither
03-10-2023Data Storage
Pivot Table 2: Center The Pivot Inside The Dashboard Widget
Building on the article Pivot Table 1: Center The Pivot Inside The Dashboard Widget (sisense.com) by Vitalii Veremeiev
This script is created to center the Pivot table inside the dashboard widget.
Instead of Pivot Table being anchored to the top left, you can use this script to make the pivot centered both vertically and horizontally.
Please note, this working only for "Pivot Table widget" with version 2.
Step-by-step guide:
- Open a pivot widget in Sisense dashboard and go to 'Edit Script'
- Copypaste the below script and press save button
- Test the results, see how a Pivot table is centered in your screen
- Feel free to modify values in the script "margin-left" and "margin-top" to make the Pivot in the right position
- prism.$ngscope.appstate === "dashboard" applies the change on the dashboard view while prism.$ngscope.appstate === "widget" applies the change in the widget editor view which has different markup to change.
widget.on('ready', function(widget) {
var widgetContainer = $('[widgetid="' + widget.oid + '"]')
console.log(prism.$ngscope.appstate);
if (prism.$ngscope.appstate === "dashboard") {
$('[widgetid="' + widget.oid + '"]').find(document.getElementsByClassName('pivot-container')).css('margin-left', '25%').css('margin-top', '25%')
} else if (prism.$ngscope.appstate === "widget") {
$(document.getElementsByClassName('pivot-container')).css('margin-left', '25%').css('margin-top', '25%')
}
})
This is what it looks like