Reputation: 335
I'm using google charts, and I want to show the pie slice text for the small slices without rotating the pie chart (chart should not be rotated).
Is it possible to show pie slice text outside the pie only for small slices(similar to charts in MS Excel as shown in below image), remaining should display the slice text within the slice itself.
Thanks in advance :)
Upvotes: 1
Views: 6935
Reputation: 11
I have same issue and my solution is put the number at the end of each legend.
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work (11)', 11],
['Eat (2)', 2],
['Commute (2)', 2],
['Watch TV (2)', 2],
['Sleep (7)', 7]
]);
var options = {
title: 'Activities',
legend: {position: 'right'}
};
Upvotes: 1
Reputation: 867
Are you looking for this: fiddler Here
use legend property legend: {position: 'labeled'}
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'Activities',
legend: {position: 'labeled'}
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
Upvotes: 2