align columns to gridlines when using series timestamps - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

align columns to gridlines when using series timestamps

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 {//  w  w w .  j  a va 2 s  .c  o m
   min-width: 300px;
   max-width: 800px;
   height: 400px;
   margin: 0 auto;
}
.my-label .highcharts-data-label-box {
   fill: green;
   stroke-width: 1px;
   stroke: black;
   border-radius: 50px;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
const data = [{
  "type": "column",
  "name": "Foo",
  "data": [2, 3, 1, 2, 1, 1, 3, 1],
  "canDeleteSeries": false,
  "colorByPoint": true,
  "colors": ["rgba(0,116,205,0.40)", "rgba(139,166,0,0.40)"]
}]
Highcharts.chart('container', {
  chart: {
    type: 'column',
  },
  time: {
    useUTC: true
  },
  xAxis: {
    type: 'datetime',
    dateTimeLabelFormats: {
      month: '%B',
    },
    gridLineWidth: 1,
    crosshair: true,
  },
  yAxis: {
    gridLineWidth: 1
  },
  plotOptions: {
    series: {
      label: {
        connectorAllowed: false
      },
      pointPadding: 0,
      groupPadding: 0,
    }
  },
  series: [{
    data: [
      [1540450800000 + 5 * 3600 * 1000, 2],
      [1540537200000 + 5 * 3600 * 1000, 3],
      [1540623600000 + 5 * 3600 * 1000, 1],
      [1540710000000 + 5 * 3600 * 1000, 2],
      [1540796400000 + 5 * 3600 * 1000, 1],
      [1540882800000 + 5 * 3600 * 1000, 1],
      [1540969200000 + 5 * 3600 * 1000, 3],
      [1541055600000 + 5 * 3600 * 1000, 1]
    ]
  }],
  credits: {
    enabled: false
  },
  borderWidth: 1,
});
    }

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

Related Tutorials