programatically change the color of chart's spline series? - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

programatically change the color of chart's spline series?

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Series Color on Button Click</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() {//from   w w  w .  ja v  a 2  s  .  co m
    var chart = new Highcharts.StockChart({
        chart: {
            renderTo: 'container'
        },
        scrollbar: {
            enabled: true
        },
        navigator: {
            enabled: true
        },
        rangeSelector: {
            selected: 1
        },
        series: [{
            name: 'Sample',
            data: MSFT
        }]
    });
    $('#button').click(function() {
       chart.series[0].graph.attr('stroke', 'green');
    });
});

      </script> 
   </head> 
   <body> 
      <div id="container" style="height: 400px; min-width: 600px"></div> 
      <button id="button">Change Color</button> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script> 
      <script type="text/javascript" src="https://www.highcharts.com/samples/data/three-series-1000-points.js"></script>  
   </body>
</html>

Related Tutorials