JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
JavaScript
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Decrease the opacity of other Series on hoveing legend"
},
legend: {
cursor: "pointer",
itemmouseover: function(e){
for(var i=0; i<e.chart.data.length; i++) {
if(i != e.dataSeriesIndex)
e.chart.options.data[i].fillOpacity = 0;
}
e.chart.render();
},
itemmouseout: function(e){
for(var i=0; i<e.chart.data.length; i++) {
if(i != e.dataSeriesIndex)
e.chart.options.data[i].fillOpacity = null;
}
e.chart.render();
}
},
data: [{
type: "scatter",
showInLegend: true,
dataPoints: [
{ x: 10000, y: 1100 },
{ x: 11000, y: 1200 },
{ x: 13000, y: 1250 },
]
},{
type: "scatter",
showInLegend: true,
dataPoints: [
{ x: 10000, y: 1100 },
{ x: 11000, y: 1200 },
{ x: 13000, y: 1250 },
]
}]
});
chart.render();
}