Switching Values In Pivot Table Widget With Text Strings

Comments

2 comments

  • Avatar
    Justin Bowen

    Dima, did you ever find resolution to your issue?

    Thank you for posting your code. I'm going to try it today on a pivot.

    0
    Comment actions Permalink
  • Avatar
    Dima Kruchenetsky (Edited )

    Hi Justin,

    Acctually yes, you just need to specify the widget id in the script and in that way it won't affect other widgets.

    This the script i use curently:
    it change the values in the 5th column to text based on the criterias.


    /***********************************************************************/
    /********Chnage values to Text based on criteria for column 5 (LEVEL) ***********/
    /**********************************************************************/
    widget.on('ready', function(w, args){
    var widgetId = $('widget[widgetid="'+w.oid+'"] td.p-value[fidx= 5] div ');
    widgetId.map(function(i, cell) {

    var x = parseInt(cell.innerHTML.replace(",", ""));
    if (x<20) {
    cell.innerHTML='L1';
    cell.style="color:#D73027;font-weight:bold;font-size:16px"

    }else
    if (x<50) {
    cell.innerHTML='L2';
    cell.style="color:#F88454;font-weight:bold;font-size:16px"
    }else
    if(x<100){
    cell.innerHTML='L3';
    cell.style="color:#A0D569;font-weight:bold;font-size:16px"

    }else
    if(x>=100){
    cell.innerHTML='L4';
    cell.style="color:#1A9850;font-weight:bold;font-size:16px"
    }else{
    cell.innerHTML='';
    }})


    0
    Comment actions Permalink

Please sign in to leave a comment.