Compare one month of two year in column chart - Javascript highcharts

Javascript examples for highcharts:Column Chart

Description

Compare one month of two year in column chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <style id="compiled-css" type="text/css">

#container {/*from w  w  w  . j  a v a  2  s  .  co m*/
   min-width: 300px;
   max-width: 800px;
   height: 300px;
   margin: 1em auto;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
myData = []
myData[0] = {
  data1: "0.00",
  data2: "0.00",
  data3: "2211.00",
  month: "november",
  numMonth: "11",
  data4: "mydata4",
  year: "2015"
}
myData[1] = {
  data1: "0.00",
  data2: "0.00",
  data3: "2211.00",
  month: "november",
  numMonth: "11",
  data4: "mydata4",
  year: "2016"
}
const series = myData.map((o) => {
   return {
     type: 'column',
     name: o.year,
    data: [{x: Number(o.numMonth), y: Number(o.data3)}]
  }
})
console.log(series)
const options = {
  xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] },
  series: series
}
const chart = Highcharts.chart('container', 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"></div>  
   </body>
</html>

Related Tutorials