I would like to disable chart.js Spider chart legend click because when I click on the legend the data series is hiding the associated set of values as shown in the below images.
My requirement is that I do not want to disable the dataset. I have tried the preventDefault(); on the chart click but it is not working.
My code sample is attached below. Please check..
<!doctype html> <html> <head> <title>Radar Chart</title> <script src="../dist/Chart.bundle.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> </head> <body> <div style="width:75%"> <canvas id="canvas"></canvas> </div> <script> var randomScalingFactor = function() { return Math.round(Math.random() * 100); }; var randomColorFactor = function() { return Math.round(Math.random() * 255); }; var randomColor = function(opacity) { return 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',' + (opacity || '.3') + ')'; }; var config = { type: 'radar', data: { labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"], datasets: [{ label: "My First dataset", backgroundColor: "rgba(0,0,0,0.5)", pointBackgroundColor: "rgba(220,220,220,1)", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] }, { label: "My Second dataset", backgroundColor: "rgba(0,120,0,0.5)", pointBackgroundColor: "rgba(151,187,205,1)", hoverPointBackgroundColor: "#fff", pointHighlightStroke: "rgba(151,187,205,1)", data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()] },] }, options: { legend: { position: 'top', onClick: (e) => e.stopPropagation() }, title: { display: true, text: '' }, scale: { reverse: false, gridLines: { color: ['black'] }, ticks: { beginAtZero: true } } } }; window.onload = function() { window.myRadar = new Chart(document.getElementById("canvas"), config); }; </script> </body> </html>