Highcharts Demo

author(s): Torstein Hønsi

by Black Label

HTML

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

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

JavaScript

Highcharts.chart('container', {
	chart: {
		events: {
			load() {
				const chart = this;
				chart.series.forEach(series => {
					series.points.forEach(point => {
						point.update({
							dataLabels: {
								color: point.x > 2 ? 'red' : 'blue',
								x: point.x * Math.random() * 25,
							}
							
							// for performace reason, I am not redrawing the chart after each update
						}, false)
					})
				});
				
				// instead I am redrawing it once, after all updates.
				chart.redraw();
			}
		}
	},
  plotOptions: {
    series: {
      dataLabels: {
        enabled: true
      },
    }
  },
  series: [{
    data: [4, 3, 5, 6, 2, 3]
  },{
    data: [4, 3, 5, 6, 2, 3].reverse()
  }]

});