效果图如下:
代码:
$(function () {
$('#container').highcharts({
xAxis:{
type: 'category',
categories: ['Foo', 'Bar', 'Foobar'],
labels : {
formatter: function () {
if (this.value === 'Foo') {
let res = '<span style="color:#DD3B51">' + this.value + '</span>';
return res;
} else {
let res = '<span style="color:#40A176">' + this.value + '</span>';
return res;
}
}
}
},
yAxis:{
labels:{
gridZIndex: 2,
gridLineDashStyle: 'Dash',
gridLineWidth: 0,
lineWidth: 0,
title: {text: ''},
tickPositions:[-10 , -5 , 0 , 5 ,10],
formatter: function () {
if (this.value > 0) {