我想自定义工具提示。我想将某些系列放在某些地方。就像顶部的2系列和底部的2系列。我希望它看起来像这样
此外,如何在工具提示中添加箭头?现在,它只是作为一个盒子出现。
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Efficiency Optimization by Branch'
},
xAxis: {
categories: [
'Seattle HQ',
'San Francisco',
'Tokyo'
]
},
yAxis: [{
min: 0,
title: {
text: 'Employees'
}
}, {
title: {
text: 'Profit (millions)'
},
opposite: true
}],
legend: {
shadow: false
},
tooltip: {
shared: true
},
plotOptions: {
column: {
grouping: false,
shadow: false,
borderWidth: 0
}
},
series: [{
name: 'Employees',
color: 'rgba(165,170,217,1)',
data: [150, 73, 20],
pointPadding: 0.3,
pointPlacement: -0.2
}, {
name: 'Employees Optimized',
color: 'rgba(126,86,134,.9)',
data: [140, 90, 40],
pointPadding: 0.4,
pointPlacement: -0.2
}, {
name: 'Profit',
color: 'rgba(248,161,63,1)',
data: [183.6, 178.8, 198.5],
tooltip: {
valuePrefix: '$',
valueSuffix: ' M'
},
pointPadding: 0.3,
pointPlacement: 0.2,
yAxis: 1
}, {
name: 'Profit Optimized',
color: 'rgba(186,60,61,.9)',
data: [203.6, 198.8, 208.5],
tooltip: {
valuePrefix: '$',
valueSuffix: ' M'
},
pointPadding: 0.4,
pointPlacement: 0.2,
yAxis: 1
}]
});
答案 0 :(得分:1)
要执行类似的操作,您将需要使用int indexOfMax =list.indexOf(Collections.max(list));
Api doc和一些CSS。
JS
tooltip.formatter
CSS
tooltip: {
shared: true,
useHTML:true,
formatter: function(){
var text = this.x + '<br>';
text+= '<span class="number"><span style="color:' + this.points[0].color + '">\u25CF</span>' + this.points[0].series.name + '</span><span class="number">' + '<span style="color:' + this.points[1].color + '">\u25CF</span>' + this.points[1].series.name + '</span><br>';
text+= '<span class="number">' + this.points[0].y+ '</span><span class="number">' +this.points[1].y+ '</span></br>'
text+= '<span class="number"><span style="color:' + this.points[2].color + '">\u25CF</span>' + this.points[2].series.name + '</span><span class="number">' + '<span style="color:' + this.points[3].color + '">\u25CF</span>' + this.points[3].series.name + '</span><br>';
text+= '<span class="number">' + this.points[2].y+ '</span><span class="number">' +this.points[3].y+ '</span></br>'
return text;
}
},