Jun*_*iuz 1 javascript jquery highcharts
我有多个系列的 Highchart,我想在固定位置显示工具提示。我根据此文档跟踪了这个highcharts 演示。不幸的是,根据我编写的配置代码,工具提示没有显示在固定位置。
该图表的 acrosshair设置为true,当我沿 x 轴移动鼠标时显示 y 轴点(下面的屏幕截图)。
在上面的屏幕截图中,我想在绿色框(左上角固定位置)上显示工具提示 CDT158: 188.84和 CDEP158: 151.00 。
这是我的示例配置代码
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
}]
});
}
Run Code Online (Sandbox Code Playgroud)
我似乎找不到任何与我的要求类似的解决方案。我查看了 Highcharts API 文档,但是我对使用哪个属性或对象感到困惑。
任何帮助是极大的赞赏。
分割工具提示会自动定位,因此这意味着定位器选项将不起作用。您可以使用共享工具提示来实现您想要的结果。
tooltip: {
positioner: function() {
return {
x: this.chart.plotLeft,
y: this.chart.plotTop
};
},
shared: true,
headerFormat: '',
pointFormat: '{series.name}: <b>{point.y}</b><br/>',
Run Code Online (Sandbox Code Playgroud)
示例: http: //jsfiddle.net/ydwLkyfe/1/