关于 HighStock 多数据工具提示
About HighStock multiple data tooltip
我想在工具提示中显示多个数据
但是 highstock 的例子只有 tooltip
中的一个数据
我试过查找提问和示例,但我只能找到 highchart 的示例
============================================= =================
我的代码 >(工具提示的 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>';
}
}
在工具提示部分使用选项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。
我想在工具提示中显示多个数据 但是 highstock 的例子只有 tooltip
中的一个数据我试过查找提问和示例,但我只能找到 highchart 的示例
============================================= =================
我的代码 >(工具提示的 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>';
}
}
在工具提示部分使用选项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。