import { formatAbsNum } from './other';
const formatDate = (value: string) => {
if ((value || '').indexOf('~') > -1) {
value = value.split('~')[1];
}
return value;
};
const Base_tooltip_num = {
zIndex: 100,
shared: true,
crosshairs: true,
backgroundColor: null,
borderWidth: 0,
borderColor: 'rgba(31,41,71,.75)',
borderRadius: 8,
shadow: true,
useHTML: true,
formatter: function () {
let s = '
'
+ '
| 时间 | '
+ formatDate(this.x)
+ ' |
';
(this.points || []).forEach((item, ind) => {
if (item.series.userOptions.hiddenTooltip) {
return;
}
let domStr = ''
+ (ind === 0 ? '| ' : ' | ')
+ item.series.name
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ item.y.toLocaleString()
+ ' | ';
domStr += '
';
s += domStr;
});
s += '
';
return s;
},
style: {
color: '#666',
fontSize: '12px',
},
};
// 百分比
const Base_tooltip_Pre = {
zIndex: 100,
shared: true,
crosshairs: true,
backgroundColor: null,
borderWidth: 0,
borderColor: '#1F2947',
borderRadius: 8,
shadow: true,
useHTML: true,
valueDecimals: 2,
valueSuffix: '%',
formatter: function () {
let s = ''
+ '
| 时间 | '
+ formatDate(this.x)
+ ' |
';
(this.points || []).forEach((item, ind) => {
if (item.series.userOptions.hiddenTooltip) {
return;
}
let domStr = ''
+ (ind === 0 ? '| ' : ' | ')
+ item.series.name
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ formatAbsNum(item.y).toLocaleString()
+ '% | ';
domStr += '
';
s += domStr;
});
s += '
';
return s;
},
style: {
color: '#666666',
fontSize: '12px',
},
};
const Base_tooltip_BoxPlot = {
zIndex: 100,
shared: false,
crosshairs: true,
backgroundColor: null,
borderWidth: 0,
borderColor: '#1F2947',
borderRadius: 8,
shadow: true,
useHTML: true,
style: {
color: '#fff',
fontSize: '14px',
},
formatter: function () {
const { point, x } = this;
let s: string = ''
+ '
| 时间 | ';
if ('hightrue' in point) {
s += formatDate(x);
s += ' |
';
let domStr = '| '
+ point.series.name
+ ' | '
+ ''
+ '最大值:' + point.hightrue.toLocaleString() + ' '
+ 'Q3:' + point.q3.toLocaleString() + ' '
+ '中位数:' + point.median.toLocaleString() + ' '
+ 'Q1:' + point.q1.toLocaleString() + ' '
+ '最小值:' + point.low.toLocaleString() + ' '
+ ' | ';
domStr += '
';
s += domStr;
} else if (point.series.userOptions.info) {
const info = point.series.userOptions.info;
s += formatDate(info.x);
s += '';
let domStr = '| '
+ point.series.name
+ ' | '
+ ''
+ '最大值:' + info.hightrue.toLocaleString() + ' '
+ 'Q3\t:' + info.q3.toLocaleString() + ' '
+ '中位数:' + info.median.toLocaleString() + ' '
+ 'Q1\t:' + info.q1.toLocaleString() + ' '
+ '最小值:' + info.low.toLocaleString() + ' '
+ ' | ';
domStr += '
';
s += domStr;
}
s += '
';
return s;
},
};
const Base_tooltip_Bubble = {
zIndex: 100,
shared: true,
crosshairs: true,
backgroundColor: null,
borderWidth: 0,
borderColor: '#1F2947',
borderRadius: 8,
shadow: true,
useHTML: true,
style: {
color: '#fff',
fontSize: '12px',
},
formatter: function () {
let s = ''
+ '
'
+ '';
let domStr = '| '
+ this.point.name
+ ' | '
+ this.point.z.toLocaleString()
+ ' | ';
domStr += '
';
s += domStr;
s += '
';
return s;
},
};
// 环比
const Base_tooltip_Chain = {
zIndex: 100,
shared: true,
crosshairs: true,
backgroundColor: null,
borderWidth: 0,
borderColor: 'rgba(31,41,71,.75)',
borderRadius: 8,
shadow: true,
useHTML: true,
formatter: function () {
let s = ''
+ '
| 时间 | | | '
+ formatDate(this.x)
+ ' |
';
(this.points || []).forEach((item, ind) => {
if (item.series.userOptions.hiddenTooltip) {
return;
}
let domStr = ''
+ (ind === 0 ? '| ' : ' | ')
+ item.series.name
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ item.y.toLocaleString()
+ ','
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ '环比 '
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ (('r' in item.point && item.point.r !== null) ? (item.point.r.toFixed(2) + '%') : '--')
+ ' | ';
domStr += '
';
s += domStr;
});
s += '
';
return s;
},
style: {
color: '#666',
fontSize: '12px',
},
};
// 环比 去% 改文案
const Base_tooltip_Chain_noper = {
zIndex: 100,
shared: true,
crosshairs: true,
backgroundColor: null,
borderWidth: 0,
borderColor: 'rgba(31,41,71,.75)',
borderRadius: 8,
shadow: true,
useHTML: true,
formatter: function () {
let s = ''
+ '
| 时间 | | | '
+ formatDate(this.x)
+ ' |
';
(this.points || []).forEach((item, ind) => {
if (item.series.userOptions.hiddenTooltip) {
return;
}
let domStr = ''
+ (ind === 0 ? '| ' : ' | ')
+ item.series.name
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ item.y.toLocaleString()
+ ','
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ '差值变化 '
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ (('r' in item.point && item.point.r !== null) ? item.point.r : '--')
+ ' | ';
domStr += '
';
s += domStr;
});
s += '
';
return s;
},
style: {
color: '#666',
fontSize: '12px',
},
};
// 百分比 环比
const Base_tooltip_Pre_Chain = {
zIndex: 100,
shared: true,
crosshairs: true,
backgroundColor: null,
borderWidth: 0,
borderColor: '#1F2947',
borderRadius: 8,
shadow: true,
useHTML: true,
valueDecimals: 2,
valueSuffix: '%',
formatter: function () {
let s = ''
+ '
| 时间 | | | '
+ formatDate(this.x)
+ ' |
';
(this.points || []).forEach((item, ind) => {
if (item.series.userOptions.hiddenTooltip) {
return;
}
console.log('mmmm', item);
let domStr = ''
+ (ind === 0 ? '| ' : ' | ')
+ item.series.name
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ formatAbsNum(item.y).toLocaleString()
+ '%, | '
+ ''
+ (ind === 0 ? '' : ' | ')
+ '环比 '
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ (item.point.r !== null ? (Number(item.point.r.toFixed(2)) + '%') : '--')
+ ' | ';;
domStr += '
';
s += domStr;
});
s += '
';
return s;
},
style: {
color: '#666666',
fontSize: '12px',
},
};
// 百分比 差值变化
const Base_tooltip_Pre_Chain_chazhi = {
zIndex: 100,
shared: true,
crosshairs: true,
backgroundColor: null,
borderWidth: 0,
borderColor: '#1F2947',
borderRadius: 8,
shadow: true,
useHTML: true,
valueDecimals: 2,
valueSuffix: '%',
formatter: function () {
let s = ''
+ '
| 时间 | | | '
+ formatDate(this.x)
+ ' |
';
(this.points || []).forEach((item, ind) => {
if (item.series.userOptions.hiddenTooltip) {
return;
}
console.log('mmmm', item);
let domStr = ''
+ (ind === 0 ? '| ' : ' | ')
+ item.series.name
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ formatAbsNum(item.y).toLocaleString()
+ '%, | '
+ ''
+ (ind === 0 ? '' : ' | ')
+ '差值变化 '
+ ' | '
+ (ind === 0 ? '' : ' | ')
+ (item.point.r !== null ? (Number(item.point.r.toFixed(2)) + '%') : '--')
+ ' | ';;
domStr += '
';
s += domStr;
});
s += '
';
return s;
},
style: {
color: '#666666',
fontSize: '12px',
},
};
export { Base_tooltip_num, Base_tooltip_Pre, Base_tooltip_BoxPlot, Base_tooltip_Bubble, Base_tooltip_Chain,Base_tooltip_Chain_noper, Base_tooltip_Pre_Chain,Base_tooltip_Pre_Chain_chazhi };