Javascript examples for highcharts:Chart Legend
Hiding items in chart legend
<html> <head> <title>Highcharts Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="container" style="height: 400px"></div> <button id="legend">Toggle legend</button> <script type="text/javascript"> var chart = Highcharts.chart('container', { xAxis: {/*from w ww . j a v a2 s. c o m*/ categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], showEmpty: false }, yAxis: { showEmpty: false }, series: [{ name: 'First series', data: [15,41,13,31,104,124,29,55,63,71], }, { name: 'Second series', data: [14,51,123,31,134,123,23,5,6,7] }] }); $('#container').ready(function() { $('#container').highcharts().series[0].update({ showInLegend: false }, true, false); }) // Toggle names let toggle = false; $('#legend').click(function () { if(toggle) { chart.series[0].update({ showInLegend: false }, true, false); toggle = false; } else { chart.series[0].update({ showInLegend: true }, true, false); toggle = true; } }); </script> </body> </html>