数据提示框指的当鼠标悬停在某点上时,以框的形式提示该点的数据,比如该点的值,数据单位等。数据提示框内提示的信息完全可以通过格式化函数动态指定;通过设置 tooltip.enabled = false 即可不启用提示框。
tooltip : {
shared: true, // 提示框是否共享
backgroundColor : 'red', // 提示框背景色
enabled : true, // 是否启用提示框, 默认启用
formatter : function (){ // 提示框格式化字符串
var s = '<b>'+this.x+'</b>';
$.each(this.points ,function(){
s += '<br />' + this.series.name + ':' + this.y;
});
return s;
},
pointFormatter : function () { // 格式化提示框字符串,更灵活,优先使用
// 函数中的 this 代表着 Point 对象。
}
positioner: function () { // 固定提示框
return { x: 80, y: 50 };
},
valueSuffix: ' cm', // 数值后缀
valuePrefix : '数据前缀' // 数值前缀
valueDecimals : 2, // 保留小数位数
xDateFormat : '%Y-%m-%d', // shared: true,
backgroundColor : 'red',
enabled : true,
formatter : function (){
var s = '<b>'+this.x+'</b>';
$.each(this.points ,function(){
s += '<br />' + this.series.name + ':' + this.y;
});
return s;
},
pointFormatter : function () {
// 函数中的 this 代表着 Point 对象。
}
positioner: function () {
return { x: 80, y: 50 };
},
valueSuffix: ' cm',
valuePrefix : '数据前缀'
valueDecimals : 2,
xDateFormat : '%Y-%m-%d', // 如果 X轴是时间轴,格式化提示框标题中的日期
}