Charts using multiple series from JSON - Javascript highcharts

Javascript examples for highcharts:Chart Json Data

Description

Charts using multiple series from JSON

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
var JSON = [// www  .  j  ava2  s  .  com
  { name: 'Pay Off',
    data: [ [2850,0],
            [3135,0],
            [3420,0],
            [3705,0],
            [3990,0],
            [4275,0],
            [4560,0],
            [4845,0],
            [5130,0],
            [5415,0],
            [5700,0],
            [5985,285],
            [6270,570],
            [6555,855],
            [6840,1140],
            [7125,1425],
            [7410,1710],
            [7695,1995],
            [7980,2280],
            [8265,2565],
            [8550,2850]
        ]
},
{
    name: 'Profit',
    data: [ [2850,-250],
            [3135,-250],
            [3420,-250],
            [3705,-250],
            [3990,-250],
            [4275,-250],
            [4560,-250],
            [4845,-250],
            [5130,-250],
            [5415,-250],
            [5700,-250],
            [5985,35],
            [6270,320],
            [6555,605],
            [6840,890],
            [7125,1175],
            [7410,1460],
            [7695,1745],
            [7980,2030],
            [8265,2315],
            [8550,2600]
        ]
    }
];
$(document).ready(function() {
  var options = {
      chart: {
          renderTo: 'container',
          type: 'line'
          },
    title: {
        text: 'PayOff Curve'
    },
    legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
    },
    series: []
  };
    options.series = JSON;
           // Create the chart
    var chart = new Highcharts.Chart(options);
  });

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials