Highstock Combine line and percentage charts? - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

Highstock Combine line and percentage charts?

Demo Code

ResultView the demo in separate window

<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/stock/highstock.js"></script> 
      <script src="https://code.highcharts.com/stock/modules/exporting.js"></script> 
      <div id="container" style="height: 600px; min-width: 310px"></div> 
      <script type="text/javascript">
var seriesOptions = [],/*from www  .  ja  v  a 2 s.  com*/
  seriesCounter = 0,
  names = ['MSFT', 'AAPL'];
function createChart() {
  Highcharts.stockChart('container', {
    yAxis: [{
       height: 200,
      showLastLabel: true
    }, {
       height: 160,
       top: 325
    }],
    rangeSelector: {
      selected: 1
    },
    series: seriesOptions
  });
}
$.each(names, function(i, name) {
  $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=' + name.toLowerCase() + '-c.json&callback=?', function(data) {
    seriesOptions[i] = {
      name: name,
      data: data,
      yAxis: 1
    };
    seriesOptions[i+2] = {
      name: name,
      type: 'area',
      stacking: "percent",
      data: data,
      yAxis: 0
    };
    seriesCounter += 1;
    if (seriesCounter === names.length) {
      createChart();
    }
  });
});

      </script>  
   </body>
</html>

Related Tutorials