我使用highchart jquery插件绘制面积图。 需要传递 3 个数组才能通过 AJAX 调用绘制图表。 x 轴的第一个数组数据。 Y 轴的第二个数组数据。第三个数组具有字符串值,需要与 y 轴值一起传递到 hover(max) 中。每个数组有 90 个值。是否可以在悬停中显示第三个数组?你能请任何人帮我吗?
$('#divcontainer').highcharts({
chart: {
type: 'area'
},
credits: {
enabled: false },plotOptions: {
area: {
events: {
legendItemClick: function () {
return false; // <== returning false will cancel the default action
}
}
,
showInLegend: true
}
}, title: {
text: 'Chart',
x: -20 //center
},
subtitle: {
text: '',
x: -20
},
xAxis: {
labels:{rotation: rot, x:-20},
categories: data[0]
},
yAxis: {
title: {
text: 'Status'
},
plotLines: [{
value:0,
width: 1,
color: '#808080'
}]
},
tooltip:{
enabled: true,
formatter: function() {
return '<b>' + this.x + '</b><br/><b>' + 'Status: ' + this.y + '</b>';}},
series: [{
name: 'Status',
data: data[1]
}]
});
data[0] is 1st array, data[1] is 2nd array, and data[2] is 3rd array
.这些是来自 ajax 调用的数组。
也许你可以尝试这样的事情:
tooltip:{
enabled: true,
formatter: function() {
return '<b>' + this.x + '</b><br/><b>' + 'Status: ' + this.y + '</b>' + data[2][this.series.data.indexOf( this.point )];
}
},
请注意带有 data[2][this.series.data.indexOf( this.point )]
的部分。