Javascript examples for highcharts:Bar Chart
plotting series in Bar chart
<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"> $(function () {//from w w w. j ava 2s .c o m $('#container').highcharts({ chart: { type: 'bar', events: { load: function () { var s1900 = this.series[0].data; var s2008 = this.series[1].data; var newData = []; if (s1900.length == s2008.length) { for (var i = 0; i < s1900.length; i++) { newData.push(s1900[i].y + s2008[i].y); } } this.addSeries({ name: 'Cumulative', xAxis: 0, type: "spline", data: newData }); } } }, title: { text: 'Historic World Population by Region' }, subtitle: { text: 'Source: Wikipedia.org' }, xAxis: [{ categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'], title: { text: null } }], yAxis: { min: 0, title: { text: 'Population (millions)', align: 'high' } }, tooltip: { valueSuffix: ' millions' }, plotOptions: { bar: { dataLabels: { enabled: true } } }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', x: -40, y: 100, floating: true, borderWidth: 1, backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'), shadow: true }, credits: { enabled: false }, series: [{ name: 'Year 1900', data: [133, 156, 947, 408, 6] }, { name: 'Year 2008', data: [973, 914, 4054, 732, 34] }] }); }); </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: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div> </body> </html>