//温度、湿度、风速、风向、气压、照度单位
let getUnitType = (type,value) => {
type = Number(type);
var unit = '';
switch (type) {
case 209033:
unit = '℃';
break;
case 209034:
unit = '%';
break;
case 209035:
unit = 'm/s';
break;
case 209036:
unit = getWindDirection(value);
break;
case 209037:
unit = 'HPa';
break;
case 200088:
unit = 'Lux';
break;
}
return unit;
};
法1:
tooltip: {
trigger: 'axis',
formatter: function (params) {
var relVal = params[0].name
for (var i = 0, l = params.length; i < l; i++) {
relVal += '<br/>' + params[i].marker + params[i].value + getUnitType(pollutionTypeMap1New[pltKey],params[i].value)
}
return relVal
}
},
法2:
tooltip: {
trigger: 'axis',
formatter: function (obj) {
let arr = obj.map((item, i) => {
return (
item.marker +
item.value +
'(' +
getUnitType(pollutionTypeMap1New[pltKey],item.value) +
')' +
'<br>'
);
});
return obj[0].name + '<br>' + arr.join(' ');
},
},