Javascript examples for highcharts:Chart Series
Remove series from chart when user clicks on legend?
<html> <head> <title>Highcharts Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(function () {/*ww w . j a va 2s . com*/ $('#container').highcharts({ plotOptions: { line: { events: { legendItemClick: function () { this.remove(true); return false; } } } }, series: [{ data: [1, 2, 3, 4, 5, 6, 7] }, { data: [3, 4, 5, 6, 7] }, { data: [2, 3, 4, 5, 6, 7] }, { data: [4, 5, 6, 7, 8, 9] }] }); var i = 5, chart = $('#container').highcharts(); $('#button').click(function () { chart.addSeries({ data: [i, i + 2, i + 4], index: i, name: 'Series ' + i }); i++; }); }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="container" style="height: 400px"></div> <button id="button">add series</button> </body> </html>