Javascript examples for highcharts:Line Chart
change particular line chart series colour dynamically in line charts
<html> <head> <title>Highcharts Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <script type="text/javascript" src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="height: 400px; max-width: 800px; margin: 0 auto"></div> <script type="text/javascript"> function zones(colors) {//from w ww .jav a2 s.c o m return [{ value: 3, dashStyle: 'solid', color: colors[0], fillColor: '#7cb5ec' }, { value: 8, dashStyle: 'dot', color: colors[1] }, { value: 11, dashStyle: 'solid', color: colors[2], fillColor: colors[2] }] } const colors = [ ['#7cb5ec', '#FFA262', '#7cb5ec'], ['#7cb5ec', '#8bbc21', '#7cb5ec'] ] const chart = Highcharts.chart('container', { xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov'] }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6], zoneAxis: 'x', zones: zones(colors[0]) }] }); (() => { let i = 0 setInterval(() => { chart.series[0].update({ zones: zones(colors[++i % 2]) }) }, 2000) })() </script> </body> </html>