MWB
MWB

Reputation: 1879

How do I control the decimals precision in a plotly/anychart pie chart

I am trying to create a pie chart in which the absolute values are displayed rather than the percentages. I do this using:

"textinfo": "value"

In that case, however, how do I control the number of decimals?


For example, when my values are 0.111111, 0.22222 and 0.0333, I want to show in my graph the numbers 0.1, 0.2 and 0.0.

One thing I tried was to actually format the number before providing them to the graph. However, in that case, the graph is only showing two sections (one for 0.1 and one for 0.2) and it is not showing the part that has a value of 0.0 (which makes sense, but is not desired).

So this is what I would like

enter image description here

But this is what I get

enter image description here

Upvotes: 1

Views: 1565

Answers (2)

AnyChart Support
AnyChart Support

Reputation: 3905

In AnyChart you can use string tokens to format values. Here is the sample. You can learn more about string tokens in the documentation article.

Upvotes: 1

MWB
MWB

Reputation: 1879

To achieve this, you need to add:

"texttemplate": "%{value:.1f}"

Upvotes: 3

Related Questions