msiqueira9

Format Labels on pie chart

Recommended Posts

Hi,

 

The Pie chart by default displays the label and the percentage value separated by (,) comma.

You can set your custom string to be displayed instead of the default one, by setting the "displayValue" attribute in each of the "data" objects with the custom string.

 

Check the modified fiddle for reference to set your required format : "labelName (percentageValue%)" : http://jsfiddle.net/g97kgn3L/

Please note : For any change in the values you need to modify the "displayValue" attribute accordingly with your custom text.

 

Thanks,

Akash.

Share this post


Link to post
Share on other sites

Hi Akash,

Thank you for your reply, 

in the example that you sent me you are using something like  "displayValue": "Adult (34.4%)" that means that I have to calculate the percentage  when setting the displayValue property.

Is it possible to use variables like $label ($value %) in the displayValue or I do I have to set this manually?

Regards,

Share this post


Link to post
Share on other sites

Hi,

 

Natively it is not possible. But you can achieve it by storing the dataSource in a variable and the using the FusionCharts "rendered" events to calculate the percentage dynamically in the event function.

Then set the calculated value in the JSON variable and use "setJSONData()" by passing the modified JSON variable.

 

Please check the sample implementing the above technique : http://jsfiddle.net/fpa38rpf/

Reference to "rendered" event : http://www.fusioncharts.com/dev/api/fusioncharts/fusioncharts-events.html#event-rendered

Reference  to "setJSONData()" : http://www.fusioncharts.com/dev/api/fusioncharts/fusioncharts-methods.html#setJSONData

 

Thanks,

Akash.

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