series option for stock chart - Javascript highcharts

Javascript examples for highcharts:Chart Series

Description

series option for stock chart

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">
    $(window).load(function(){/* w w w. j  a v a 2  s .c o m*/
var timeArr = [1427846400000, 1427932800000, 1428019200000, 1428278400000, 1428364800000, 1428451200000, 1428537600000, 1428624000000, 1428883200000, 1428969600000, 1429056000000, 1429142400000, 1429228800000, 1429488000000, 1429574400000, 1429660800000, 1429747200000, 1429833600000, 1430092800000, 1430179200000, 1430265600000, 1430352000000, 1430438400000, 1430697600000, 1430784000000, 1430870400000, 1430956800000, 1431043200000, 1431302400000, 1431388800000, 1431475200000, 1431561600000, 1431648000000, 1433116800000, 1433203200000, 1433289600000, 1433376000000, 1433462400000, 1433721600000, 1433808000000, 1433894400000, 1435017600000, 1435104000000, 1435190400000, 1435276800000, 1435536000000, 1435622400000, 1435708800000, 1435795200000, 1435881600000, 1436140800000, 1437004800000, 1437091200000, 1437350400000, 1437436800000, 1437523200000, 1437609600000, 1437696000000, 1437955200000, 1431907200000, 1431993600000, 1432080000000, 1432166400000, 1432252800000, 1432512000000, 1432598400000, 1432684800000, 1432771200000, 1432857600000, 1433980800000, 1434067200000, 1434412800000, 1434326400000, 1434499200000, 1434585600000, 1434672000000, 1434931200000, 1436227200000, 1436354762000, 1436400000000, 1436486400000, 1436745600000, 1436869762000, 1436918400000, 1436572800000, 1438041600000, 1438128000000, 1438214400000, 1438300800000, 1438560000000, 1438646400000, 1438732800000, 1438819200000, 1438905600000, 1439164800000, 1439251200000, 1439337600000, 1439424000000]
timeArr.sort();
data1 = [];
data2 = [];
seriesOptions = [];
for (var i = 0, l = timeArr.length; i < l; i++) {
    var arr1 = [timeArr[i], Math.random() * 15];
    var arr2 = [timeArr[i], 10];
    data1.push(arr1);
    data2.push(arr2);
}
var obj = {
    name: 'app1',
    type: 'column',
    data: data1
};
var obj1 = {
    name: 'app2',
    type: 'column',
    data: data2
};
seriesOptions.push(obj);
seriesOptions.push(obj1);
console.log(seriesOptions);
$('#chartdiv').highcharts('StockChart', {
    rangeSelector: {
        selected: 2
    },
    legend: {
        enabled: true
    },
    credits: {
        enabled: false
    },
    chart: {
        zoomType: 'x'
    },
    title: {
        text: 'test highchart'
    },
    series: seriesOptions
});
    });

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script> 
      <div id="chartdiv" style="height: 400px"></div>  
   </body>
</html>

Related Tutorials