Reputation: 3503
I have a lovely pie rendered with Plotly.js. On hover I show percentages + absolute number. My absolute number should have a suffix which is the entity. I can't seem to add it to the hover state?
In the screenshot is my current hover shown.
So next to 343,630.5728 I want my entity to render. Also formatting the thousand and decimal separator would be nice.
Upvotes: 0
Views: 365
Reputation: 1340
You can use customdata
+ hovertemplate
for the tooltip info and layout.separators
for the separators.
var data = [{
values: [1023.4, 500, 600],
labels: ['Residential', 'Non-Residential', 'Utility'],
customdata: ['A', 'B', 'C'],
hovertemplate: '%{label}<br>%{value} %{customdata}<br>%{percent}<extra></extra>',
type: 'pie'
}];
var layout = {
height: 400,
width: 500,
separators: ',.'
};
Plotly.newPlot('chart', data, layout);
<script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.51.1/plotly.min.js"></script>
<div id="chart"></div>
Upvotes: 1