我希望在工具提示中显示多个数据 但是highstock的例子只是工具提示中的一个数据
我试过找问和例子,但我只能找到高亮度图的例子
=============================================== ===============
我的代码> (工具提示的abc和toto显示未定义)
series: [{
name: '',
data: [{
x:1452870000000,
y: 56.33,
abc: 'Microsoft Internet Explorer',
toto:'op'
}, {
x:1453870000000,
y: 24.03,
abc: 'Chrome',
toto:'uo'
}, {
x:1455870000000,
y: 10.38,
abc: 'Firefox',
toto:'fq'
}
],
marker: {
enabled: true,
radius: 3
},
shadow: true
}],
tooltip: {
formatter: function() {
return '<span>'+this.point.abc+this.point.toto+'</span>';
}
}
答案 0 :(得分:1)
使用工具提示部分中的shared:true选项在工具提示中同时显示所有系列的数据:
tooltip: {
shared:true
},
检查jsfiddle
$(function () {
var seriesOptions = [],
seriesCounter = 0,
names = ['MSFT', 'AAPL', 'GOOG'];
/**
* Create the chart when all data is loaded
* @returns {undefined}
*/
function createChart() {
$('#container').highcharts('StockChart', {
rangeSelector: {
selected: 4
},
yAxis: {
labels: {
formatter: function () {
return (this.value > 0 ? ' + ' : '') + this.value + '%';
}
},
plotLines: [{
value: 0,
width: 2,
color: 'silver'
}]
},
plotOptions: {
series: {
compare: 'percent',
showInNavigator: true
}
},
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
valueDecimals: 2,
//split: true,
shared:true
},
series: seriesOptions
});
}
$.each(names, function (i, name) {
$.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=' + name.toLowerCase() + '-c.json&callback=?', function (data) {
seriesOptions[i] = {
name: name,
data: data
};
// As we're loading the data asynchronously, we don't know what order it will arrive. So
// we keep a counter and create the chart when all the data is loaded.
seriesCounter += 1;
if (seriesCounter === names.length) {
createChart();
}
});
});
});
您可以获得有关如何使用工具提示选项here的更多信息。