Highcharts Demo

author(s): Torstein Hønsi

by rizzotto

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container"></div>

CSS

#container {
    height: 400px;
}

JavaScript

Highcharts.chart('container', {
    chart: {
        type: 'line'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    
    tooltip: {
    	// set outside to `true` to see the alignment issue
    	outside: false,
      
    	followPointer: false,
      positioner(labelWidth, labelHeight, point) {
        return {
          x: point.plotX + this.chart.plotLeft - labelWidth / 2,
          y: this.chart.plotTop - 20,
        }
      },
      shape: 'square',
      formatter() {
				return `<span style="padding-left: 4px; padding-right: 4px;">${this.point.y}</span>`
      },
      animation: false,
      borderWidth: 0,
      useHTML: true,
      padding: 0,
    },

    plotOptions: {
        series: {
            fillOpacity: 0.1
        }
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }],
    
  	xAxis: {
      lineWidth: 0,
      crosshair: {
        snap: true,
        width: 2,
        color: 'gray',
      },
  	},
});