How to show percentage in pie chart?
LilC
New Altair Community Member
I have 2 different groups in the pie chart and the results are aggregated.
I want to show the percentage of each group's sales, instead of the sum of the sales.
Also, if I use Marco to calculate the percentage of each store, how can I display both the sales and the percentage in the result (not the chart)?
Can anyone help me with it?
I want to show the percentage of each group's sales, instead of the sum of the sales.
Also, if I use Marco to calculate the percentage of each store, how can I display both the sales and the percentage in the result (not the chart)?
Can anyone help me with it?
Tagged:
0
Best Answers
-
Hi,
I'm afraid it's not obvious, but it is doable!
You have to go to Plot style -> Labels style -> and enter "<b>{point.name}</b>: {point.percentage:.1f}%" as the Label value format.
For the tooltip, you can add something like " => {point.percentage:.1f}%" as the tooltip Value suffix.
Regards,
Marco-1 -
Hi, Marco, if it is for Sunburst chart, will it work as well?
Also, since some are less than 0.9% of the total, if there any way to display them as well?
0 -
Hi,
No, Sunburst does not support %. I suppose because it is usually very crowded with dozens of elements..
Regarding your other question, the available space is determined by the library. I would assume it thinks there is not enough space and therefore does not show those anymore. You have too many small elements in the same space for the labels to be shown properly in a pie chart, if you ask me. Those would make the chart not very nice, even if they did fit on the screen.
Regards,
Marco1
Answers
-
Hi,
I'm afraid it's not obvious, but it is doable!
You have to go to Plot style -> Labels style -> and enter "<b>{point.name}</b>: {point.percentage:.1f}%" as the Label value format.
For the tooltip, you can add something like " => {point.percentage:.1f}%" as the tooltip Value suffix.
Regards,
Marco-1 -
Hi, Marco, if it is for Sunburst chart, will it work as well?
Also, since some are less than 0.9% of the total, if there any way to display them as well?
0 -
Hi,
No, Sunburst does not support %. I suppose because it is usually very crowded with dozens of elements..
Regarding your other question, the available space is determined by the library. I would assume it thinks there is not enough space and therefore does not show those anymore. You have too many small elements in the same space for the labels to be shown properly in a pie chart, if you ask me. Those would make the chart not very nice, even if they did fit on the screen.
Regards,
Marco1 -
Thanks, Marco, you are awesome.
Because I really need to show those top 10 stores' individual percentage.
Is there a way to display them on the side of the bar chart?
If not I'll just use macro to add a column.0 -
I want to show that in Rapid, please hep me. Thanks.
0 -
Hi @Marco_Boeck, is there a way to specify pie chart colors using hex codes? And can you specify the font (not just the size) for the labels?0
-
Hi @ksgenzer,
Yes, you can specify the colors via hex code. You need to manually modify the configuration file, though. See the attached configuration for the Iris sample data set. It uses a simple red/green/blue color array in line #119 for the colors element of the styleConfiguration of the plotConfiguration."colors" : ["#ff0000", "#00ff00", "#0000ff"],
The font itself however cannot be specified unfortunately.
Kind regards,
Marco-1 -
That worked great--thank you @Marco_Boeck !0