https://www.cnblogs.com/zhilu/p/14047105.html
tooltip: {
trigger: 'axis',
// position: ['50%', '50%'],
position: function(point, params, dom, rect, size) {
var x = 0;
var y = 0;
var pointX = point[0];
var pointY = point[1];
var boxWidth = size.contentSize[0];
var boxHeight = size.contentSize[1];
if (boxWidth > pointX) {
x = 5;
} else {
x = pointX - boxWidth;
}
if (boxHeight > pointY) {
y = 5;
} else {
y = pointY - boxHeight;
}
return [x, y];
},
axisPointer: {
type: 'shadow'
},
textStyle: {
color: '#fff'
},
formatter: function(datas) {
let res = datas[0].name + '<br/>';
let val;
const length = datas.length;
for (let i = 0; i < length; i++) {
val = datas[i].value.toFixed(num).replace(/\d(?=(\d{3})+\.)/g, '$&,');
// console.log(val);
res +=
'<span style="display:inline-block;margin-right:0.05rem;border-radius:0.05rem;width:0.1rem;height:0.1rem;background-color:' +
datas[i].color +
';"></span>' +
datas[i].seriesName +
':' +
val +
'<br/>';
}
return res;
}
},