Knowledge Base Article

Pivot Table 1: Center The Pivot Inside The Dashboard Widget

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 1.

STEP-BY-STEP GUIDE:

  1. Open a pivot widget in Sisense dashboard and go to 'Edit Script'
  2. Copypaste the below script and press save button
  3. Test the results, see how a Pivot table is centered in your screen
  4. Feel free to modify values in the script "margin-left" and "margin-top" to make the Pivot in the right position
Script:
widget.on('ready', function(widget) {
var widgetContainer = $('[widgetid="'+ widget.oid + '"]')
if (prism.$ngscope.appstate === "dashboard") {
$('[widgetid="'+ widget.oid + '"]').find(document.getElementsByClassName('p-container')).css('margin-left', '25%') .css('margin-top', '10%')
} else if (prism.$ngscope.appstate === "widget") {
$(document.getElementsByClassName('p-container')).css('margin-left', '25%').css('margin-top', '10%')
}
})

widget.on('domready', function(widget) {
var widgetContainer = $('[widgetid="'+ widget.oid + '"]')
if (prism.$ngscope.appstate === "dashboard") {
$('[widgetid="'+ widget.oid + '"]').find(document.getElementsByClassName('phantom')).remove()
} else if (prism.$ngscope.appstate === "widget") {
$(document.getElementsByClassName('phantom')).remove()
}
})

THIS IS HOW IT LOOKS LIKE:

Updated 03-02-2023

3 Comments

  • If you are looking for this for Pivot Table 2 change the lines with getElementsByClassName('p-container') such as

    $('[widgetid="'+ widget.oid + '"]').find(document.getElementsByClassName('p-container')).css('margin-left', '25%') .css('margin-top', '10%')

    to use pivot-container

    $('[widgetid="'+ widget.oid + '"]').find(document.getElementsByClassName('pivot-container')).css('margin-left', '25%') .css('margin-top', '10%')

     

  • Liliia_DevX's avatar
    Liliia_DevX
    Sisense Employee

    SiftHealthcare hi!

    Please note that this script was designed for Pivot running on Windows based version. I've checked it form our side and it seems to be working:

    For the Sisense application running on Linux, please try to use a script below:

    widget.on('ready', function(widget) {
    var widgetContainer = $('[widgetid="'+ widget.oid + '"]')
    if (prism.$ngscope.appstate === "dashboard") {
    $('[widgetid="'+ widget.oid + '"]').find(document.getElementsByClassName('pivot-container')).css('margin-left', '25%') .css('margin-top', '10%')
    } else if (prism.$ngscope.appstate === "widget") {
    $(document.getElementsByClassName('p-container')).css('margin-left', '25%').css('margin-top', '10%')
    }
    })
    
    widget.on('domready', function(widget) {
    var widgetContainer = $('[widgetid="'+ widget.oid + '"]')
    if (prism.$ngscope.appstate === "dashboard") {
    $('[widgetid="'+ widget.oid + '"]').find(document.getElementsByClassName('phantom')).remove()
    } else if (prism.$ngscope.appstate === "widget") {
    $(document.getElementsByClassName('phantom')).remove()
    }
    })

    Hope that helps to achieve your goal!