datetime label for column chart - Javascript highcharts

Javascript examples for highcharts:Column Chart

Description

datetime label for column 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">
$(function () {//from  w  w w  . j  a v a 2s  .  co m
    $('#container').highcharts({
        chart: {
            type:'column'
        },
        title: {
            text: 'Inventory remaining'
        },
        subtitle: {
            text: 'grams'
        },
        xAxis: {
            tickPositioner: function () {
                var positions = [],
                    tick =  Date.UTC(2011, 2, 1, 5, 0),
                    increment = 3 * 3600 * 1000;
                for (tick; tick - increment <= this.dataMax; tick += increment) {
                    positions.push(tick);
                }
                return positions;
            },
            type: 'datetime',
            startOnTick:true,
            //tickInterval: 3 * 3600 * 1000,
            //min: Date.UTC(2011, 2, 1, 5, 01),
            dateTimeLabelFormats: {
                hour: '%l%P',
                day: '%b%e',
                minute: '%H:%M'
            },
            labels: {
                align: 'left',
                formatter:function(){
                    return Highcharts.dateFormat('%H:%M', this.value);
                }
            },
        },
        yAxis: {
            labels: {
                format: '{value} grams'
            }
        },
        plotOptions: {
            series: {
                pointPadding: 0,
                //groupPadding: 0.03,
                pointRange: 3 * 3600 * 1000
            },
            column: {
                pointPlacement: 'between'
            },
        },
        series: [{
            data: [10, 70, 46, 142, 25, 75, 100, 85],
            pointStart: Date.UTC(2011, 2, 1, 5, 01),
            pointInterval: 3 * 3600 * 1000
        }]
    });
  });

      </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; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials