jQuery addClass example
Change class name on click in jQuery
by core972
HTML
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<div id="container" class="chart"></div>
JavaScript
/*(function (H) {
var localVar, // local variable
Series = H.Series; // shortcut to Highcharts prototype
doSomething();
}(Highcharts));*/
var char = new Highcharts.chart('container', {
chart: {
zoomType: 'x',
events:{
load:function(){
chartObj = this;
$.each(chartObj.series[0].data, function(i, point) {
if(point.y > 100) {
point.dataLabel.attr({x:20});
}
});
}
}
},
title: {
text: 'Title'
},
subtitle: {
text: 'Subtitle'
},
xAxis: {
title: {
text: 'Title'
}
},
yAxis: {
title: {
text: 'Subtitle'
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
spline: {
dataLabels: {
enabled: true,
formatter: function() {},
}
},
series: {
label: {
connectorAllowed: false
},
dataLabels: {
enabled: true,
formatter: function() {
var color = '';
var serie = this.series.name;
if (serie == '2017') {
color = 'blue';
} else if (serie == '2018') {
color = 'orange';
} else {
if (this.x == 0) {
//console.log(serie);
color = 'red';
} else {
color = 'white';
}
}
//console.log(serie);
//console.log(this.point.y);
//this.point.attr({x:40});
//this.point.y.plotY =50;
//this.point.plotY =-30;
return '<span style="color:' + color + '">' + this.y + '</span>';
},
align: 'center',
color: 'black',
rotation: -90, //set label position vertical
y: -30 // position point
//if value point is > 267, set label position with Y = 30, else Y = -30
}
}
},
series: [{
name: '2017',
data: [275, 270, 276, 265, 271,...