I have a radar chart from chart.js. Currently it loads in all the data which works great and the supporting legend behaves by clicking on the legend label which toggles off the data associated to the legend able. I want to be able to click on the legend label, it then toggles all the other off and maybe introduce an 'all' option? Is this doable with chart.js?
Here is how my chart looks now:
var chartata = {
labels: [
"Strategic Development and Ownership",
"Driving change through others",
"Exec Disposition",
"Commercial Acumen",
"Develops High Performance Teams",
"Innovation and risk taking",
"Global Leadership",
"Industry Leader"
]};
var ctx = $("#allRadarData");
var config = {
type: 'radar',
data: chartata,
animationEasing: 'linear',
options: {
legend: {
fontSize: 10,
display: true,
itemWidth: 150,
position: 'bottom',
fullWidth: true,
labels: {
fontColor: 'rgb(0,0,0)',
boxWidth: 10,
padding: 20
},
},
tooltips: {
enabled: true
},
scale: {
ticks: {
fontSize: 15,
beginAtZero: true,
stepSize: 1,
max: 5
}
}
},
},
LineGraph = new Chart(ctx, config);
var colorArray = [
["#f44336", false],
["#E91E63", false],
["#9C27B0", false],
["#673AB7", false],
['#3F51B5', false],
["#607D8B", false]
];
for (var i in data) {
tmpscore=[];
tmpscore.push(data[i].score1);
tmpscore.push(data[i].score2);
tmpscore.push(data[i].score3);
tmpscore.push(data[i].score4);
tmpscore.push(data[i].score5);
tmpscore.push(data[i].score6);
tmpscore.push(data[i].score7);
tmpscore.push(data[i].score8);
var color, done = false;
while (!done) {
var test = colorArray[parseInt(Math.random() * 10)];
if (!test[1]) {
color = test[0];
colorArray[colorArray.indexOf(test)][1] = true;
done = !done;
}
}
newDataset = {
label: data[i].firstName+' '+data[i].lastName,
borderColor: color,
backgroundColor: "rgba(0,0,0,0)",
data: tmpscore,
};
config.data.datasets.push(newDataset);
}
LineGraph.update();
},
});
});