Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: CDE - piechart percentage, bug ?!

  1. #1
    Join Date
    Mar 2011
    Posts
    140

    Lightbulb CDE - piechart percentage, bug ?!

    Hello all,

    When I create a piechart I don't get to see the percentage. Instead of the value I get a 'NaN' %.

    Here is a screenshot of my problem: http://i53.tinypic.com/rlmkn8.jpg

    Now I don't know javascript, but I did look in the code. I noticed a variable 'sum' that isn't being used except for logging. I'm probably wrong about this though


    Any suggestions ?

  2. #2
    Join Date
    May 2011
    Posts
    6

    Default

    I'm getting the same behaviour as well.
    I have also noticed that this does not happen all the time: if the values involved are rather small the percentage is shown correctly; it displays 'NaN %' when the value is greater than 1000 (more or less).

    I have no clue why this happens, anybody got a hint on this?

  3. #3
    Join Date
    Jul 2007
    Posts
    2,498

    Default

    when the value is greater than 1000 (more or less)
    This is an interesting info. Need to take a look, sounds like a bug
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  4. #4
    Join Date
    May 2011
    Posts
    6

    Default

    Thanks for the reply!

    I attached two captions as proof.
    Just FYI, I've been able to reproduce the issue on several different browsers (I mainly use firefox 4, but I've tried with Chrome and IE as well), so it's not some kind of browser-specific problem.

    Another minor issue i have noticed is that, if there are zeros to the right of the number, these are not displayed in the CCC charts' tooltips (e.g. 1000 is displayed as 1 and 1200 as 12), but the number is shown correctly in table components etc...
    Is this a bug as well?
    Attached Images Attached Images   

  5. #5

    Default

    Actually i had the same problem, and what i did is to edit the "value format" property in a manual way, this was the function that i used :

    function(d)
    {
    return "" + parseFloat(d).toFixed(2) + " (" + (d / render_PieX.chart.pieChartPanel.sum*100).toFixed(2) + "%)";
    }

    Where PieX is the name of my Pie.

    And by the way, the percentage problem is with numbers with 4 or more digits, and im pretty sure that the reason is because is trying to parse a number with commas , ej (1,234)

    Greetings
    Last edited by jegordon; 06-10-2011 at 12:18 PM.

  6. #6
    Join Date
    Jan 2010
    Posts
    9

    Default Another solution

    I solved editing the "Value format" on the advance properties for the PieChart the follow code:

    Code:
    function(d)
    {
        return d.toFixed(2);
    }
    Hope it helps.

  7. #7
    Join Date
    Apr 2011
    Posts
    8

    Default

    We fixed this setting tooltip format to:
    function(s,c,v) {
    return c+": " + v + " (" + Math.round(v.replace(',','')/this.sum*100,1) + "%)";
    }

  8. #8
    Join Date
    Mar 2011
    Posts
    140

    Default

    Hello everyone,

    great, thanks for the support.

    This will help me out a lot. I tried stuff with "this.sum", but that didn't do anything for me. It just gave me "undefined" errors.

    I'll try the solutions posted, thanks !!


    Cheers !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.