admin管理员组文章数量:1405343
I have a multiple series of Highchart which I want to display the tooltip in a fixed position. I followed this highcharts demo based on this documentation. Unfortunately, based on the configuration code that I wrote, the tooltip did not display in the fixed position.
The chart has a crosshair
that is set to true
and, displays the y-axis points as I move the mouse along the x-axis (screenshot below).
On the screenshot above, I want to display the tooltip CDT158: 188.84 and CDEP158: 151.00 on the green box (top left fixed position).
This is my sample configuration code
function plotChartData(dataSeries, xaxisTitle)
{
myChart = new Highcharts.Chart({
chart: {
renderTo: 'chartSpace',
type: 'line',
zoomType: 'xy',
panning: true,
panKey: 'shift',
plotBorderWidth: 1,
events: {
dblclick: function (e) {
window.alert('Hello Chart!')
}
}
},
title: {
text: 'Fixed Tooltip'
},
legend: {
layout: 'horizontal',
align: 'left',
itemDistance: 10,
borderWidth: 0,
itemMarginTop: 0,
itemMarginBottom: 0,
padding: 20
},
plotOptions: {
series: {
states: {
hover: {
enabled: false
}
},
dataLabels: {
enabled: false,
format: '{y}'
},
allowPointSelect: false
}
},
xAxis: {
type: 'datetime',
labels: {
rotation: -65,
style: {
fontSize: '9px',
fontFamily: 'Verdana, sans-serif'
}
},
crosshair: true
},
yAxis: {
gridLineColor: '#DDDDDD',
gridLineWidth: 0.5
},
tooltip: {
positioner: function () {
return { x: 80, y: 10 };
},
pointFormat: '{series.name}: <b>{point.y}</b><br/>',
split: true,
valueDecimals: 2,
shadow: false,
borderWidth: 0,
backgroundColor: 'rgba(255,255,255,0.8)'
},
series: [{
name: xaxisTitle,
data: dataSeries
}]
});
}
I can't seem to find any solution out there that is similar to my requirement. I looked in the Highcharts API documentation but, I'm confused of which property or object to use.
Any help is greatly appreciated.
I have a multiple series of Highchart which I want to display the tooltip in a fixed position. I followed this highcharts demo based on this documentation. Unfortunately, based on the configuration code that I wrote, the tooltip did not display in the fixed position.
The chart has a crosshair
that is set to true
and, displays the y-axis points as I move the mouse along the x-axis (screenshot below).
On the screenshot above, I want to display the tooltip CDT158: 188.84 and CDEP158: 151.00 on the green box (top left fixed position).
This is my sample configuration code
function plotChartData(dataSeries, xaxisTitle)
{
myChart = new Highcharts.Chart({
chart: {
renderTo: 'chartSpace',
type: 'line',
zoomType: 'xy',
panning: true,
panKey: 'shift',
plotBorderWidth: 1,
events: {
dblclick: function (e) {
window.alert('Hello Chart!')
}
}
},
title: {
text: 'Fixed Tooltip'
},
legend: {
layout: 'horizontal',
align: 'left',
itemDistance: 10,
borderWidth: 0,
itemMarginTop: 0,
itemMarginBottom: 0,
padding: 20
},
plotOptions: {
series: {
states: {
hover: {
enabled: false
}
},
dataLabels: {
enabled: false,
format: '{y}'
},
allowPointSelect: false
}
},
xAxis: {
type: 'datetime',
labels: {
rotation: -65,
style: {
fontSize: '9px',
fontFamily: 'Verdana, sans-serif'
}
},
crosshair: true
},
yAxis: {
gridLineColor: '#DDDDDD',
gridLineWidth: 0.5
},
tooltip: {
positioner: function () {
return { x: 80, y: 10 };
},
pointFormat: '{series.name}: <b>{point.y}</b><br/>',
split: true,
valueDecimals: 2,
shadow: false,
borderWidth: 0,
backgroundColor: 'rgba(255,255,255,0.8)'
},
series: [{
name: xaxisTitle,
data: dataSeries
}]
});
}
I can't seem to find any solution out there that is similar to my requirement. I looked in the Highcharts API documentation but, I'm confused of which property or object to use.
Any help is greatly appreciated.
Share Improve this question edited May 9, 2017 at 9:43 Junius asked May 9, 2017 at 4:53 JuniusJunius 6272 gold badges14 silver badges43 bronze badges1 Answer
Reset to default 6A split tooltip is positioned automatically, so it means that a positioner option will not work. You can use a shared tooltip to achieve the result you want.
tooltip: {
positioner: function() {
return {
x: this.chart.plotLeft,
y: this.chart.plotTop
};
},
shared: true,
headerFormat: '',
pointFormat: '{series.name}: <b>{point.y}</b><br/>',
example: http://jsfiddle/ydwLkyfe/1/
本文标签: javascriptHow to display fixed tooltip position in a multiple series highchartStack Overflow
版权声明:本文标题:javascript - How to display fixed tooltip position in a multiple series highchart? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744893503a2630923.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论