Rahul Kumar

How to show both percentage and value in the label for Pie chart?

Recommended Posts

showValues='1'

 

 

 

if I add

 

 showPercentValues='1' 

 

then It show percentage only

 

 

 

 

 

How to show both percentage and value in the label for Pie chart?

Edited by Guest

Share this post


Link to post
Share on other sites

Hi,

 

You can show value on label and percentage on tool tip.

showPercentageValues='0'  showPercentInToolTip='1'

You can show percentage on label and value on tool tip.

showPercentageValues='1'  showPercentInToolTip='0'

Share this post


Link to post
Share on other sites

Hi,

 

 

You can show value on label and percentage on tool tip.

 

showPercentageValues='0' showPercentInToolTip='1'

 

You can show percentage on label and value on tool tip.

 

showPercentageValues='1' showPercentInToolTip='0'

 

Hi Arindam,

 

I am using Fusionchart module (fusioncharts-6.x-1.0.) for creating Pie-charts and other metrics , could you please help me where can I found these values i.e:showPercentageValues='0' showPercentInToolTip='1' . Plese help .

Edited by Hitisme

Share this post


Link to post
Share on other sites

Using Jquery or Javascript you can update label after it load .

STEPS :

1.  creating setTimeout function that run after 2 seconds.

2. Loop through all the label and calculate total (to percentage generate) 

3. Loop Through Again and replace label value with your value.

 

window.setTimeout(function(){

var getTotal = 0;
var selector = "#revenue-block tspan"
document.querySelectorAll(selector).forEach(function(ele){
    if(ele && ele.innerHTML && ele.innerHTML.split(',').length > 1){
        var arr = ele.innerHTML.split(','); // paid, 2000k or pend,3000k
        var value = +arr[1].replace(/[a-zA-z, ]/g,''); // 2000k => 2000  
        if(value > 0){
            getTotal += value;
        }
    }
});

document.querySelectorAll(selector).forEach(function(ele){
    if(ele && ele.innerHTML && ele.innerHTML.split(',').length > 1){
        var arr = ele.innerHTML.split(','); // paid, 2000k or pend,3000k
        var value = +arr[1].replace(/[a-zA-z ]/g,'');  // 2000k => 2000  
        var per = Math.round(((value/getTotal)*100)     * 100) / 100; // 34.556788 => 34.55 (you can also used number.toFixed(2) )
        if(per > 0){
            ele.innerHTML = ele.innerHTML + ' (' + per + '%)';
        }
    }
});

},2000);

Edited by Jhamman Sharma

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now