0👍
✅
Instead of hard coding the boolean value for display property of legend I passed its value as a parameter each time the draw function is called.
$scope.drawFunc = function( legendBoolValue)
{
new Chart(document.getElementById("pie-chart"), {
type: 'pie',
data: {
labels: ["Africa", "Asia", "Europe", "Latin America", "North America"],
datasets: [{
label: "Population (millions)",
backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
data: [2478,5267,734,784,433]
}]
},
options: {
title: {
display: true,
text: 'Predicted world population (millions) in 2050'
},
legend: {
display: legendBoolValue
}
}
});
}
Source:stackexchange.com