Highcharts Demo

author(s): Torstein Hønsi

by Murali Kaliappan

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/js/customEvents.js"></script>


<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

JavaScript

Highcharts.chart('container', {
    chart: {
        type: 'line'
    },
    title: {
        text: 'Monthly Average Temperature'
    },
    subtitle: {
        text: 'Source: WorldClimate.com'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    yAxis: {
        title: {
            text: 'Temperature (°C)'
        }
    },
    plotOptions: {
    		series : {
        	dataLabels :{
          	enabled : false,            
          },
          point :{
          	events : {
            	contextmenu : function(){
              	var isDataLabelEnabled = !this.dataLabels;
                console.log(isDataLabelEnabled)
                this.update({
                  dataLabels :{
                    enabled: isDataLabelEnabled,
                    formatter : function(){
                      return this.y.toFixed(2)+" hey yee yee";
                    }
                  }
                	
                })
              }
            }
          }
        }
    },
    series: [{
        name: 'Tokyo',
        data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
    }]
});