[英]Highcharts - How to get a value of a stack in a series?
I was wondering if it is possible to get the value of a stack in a series to use in my tooltip in Highcharts .我想知道是否可以在Highcharts 的工具提示中使用系列中的堆栈值。
I got it using the this.series.stackKey
like the following example:我使用this.series.stackKey
得到它,如下例所示:
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Total fruit consumtion, grouped by gender'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
allowDecimals: false,
min: 0,
title: {
text: 'Number of fruits'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal + ' Stack: ' + this.series.stackKey;
}
},
plotOptions: {
column: {
stacking: 'normal'
}
},
series: [{
name: 'John',
data: [5, 3, 4, 7, 2],
stack: 'male'
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5],
stack: 'male'
}, {
name: 'Jane',
data: [2, 5, 6, 2, 1],
stack: 'female'
}, {
name: 'Janet',
data: [3, 0, 4, 4, 3],
stack: 'female'
}]
});
});
But the tooltip shows me something like "columnfemale"
and I want to see only the stack value: "female"
.但是工具提示向我显示了类似"columnfemale"
,我只想看到堆栈值: "female"
。
Fiddle: http://jsfiddle.net/5nLa3saf/小提琴: http : //jsfiddle.net/5nLa3saf/
The value of the stack
option can be found in Series.options.stack
. stack
选项的值可以在Series.options.stack
找到。
For your code it would look like this ( JSFiddle ):对于您的代码,它看起来像这样( JSFiddle ):
tooltip: {
formatter: function () {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal + ' Stack: ' + this.series.options.stack;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.