UNPKG

iep-ui

Version:

An enterprise-class UI design language and Vue-based implementation

124 lines (113 loc) 3.49 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _toolkits = require('../toolkits'); var _toolkits2 = _interopRequireDefault(_toolkits); var _vueTypes = require('../_util/vue-types'); var _vueTypes2 = _interopRequireDefault(_vueTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } exports['default'] = { name: 'Tooltip', props: { chartData: { type: Array, 'default': function _default() { return []; } }, gap: _vueTypes2['default'].string.def('160px'), theme: _vueTypes2['default'].oneOf(['dark', 'light']).def('dark') }, data: function data() { return { topLegend: ['AQI', 'PM2.5', 'PM10', 'SO2', 'NO2', 'CO', 'O3', 'VOC'], bottomLegend: ['温度', '湿度', '风速', '风级'], endData: { top: [], bottom: [] } }; }, watch: { chartData: { handler: function handler(e) { var _this = this; e.forEach(function (item) { if (_this.topLegend.includes(item.value1)) { _this.endData.top.push(item); } if (_this.bottomLegend.includes(item.value1)) { _this.endData.bottom.push(item); } }); }, deep: true, immediate: true } }, render: function render() { var h = arguments[0]; var childTopNodes = this.endData.top.map(function (item) { return h( 'span', { 'class': 'tooltip-sub-cell' }, [h( 'span', { 'class': 'tooltip-sub-cell-item' }, [h('span', { style: { background: item.color } }), h('span', [item.value1])] ), h( 'span', { 'class': 'tooltip-sub-cell-item' }, [h('span', [item.value]), h('span', [_toolkits2['default'].pollutionFactors.factorDict.factor[item.value1.toLocaleLowerCase().replace('.', '')].unit || ''])] )] ); }); var childBottomNodes = this.endData.bottom.map(function (item) { return h( 'span', { 'class': 'tooltip-sub-cell' }, [h( 'span', { 'class': 'tooltip-sub-cell-item' }, [h('span', { style: { background: item.color } }), h('span', [item.value1])] ), h( 'span', { 'class': 'tooltip-sub-cell-item' }, [h('span', [item.value]), h('span', [item.value1 === '温度' ? '°C' : item.value1 === '湿度' ? '%' : item.value1 === '风速' ? 'm/s' : item.value1 === '风级' ? '级' : '']), h('span', [item.windVal && '(' + item.windVal + ')'])] )] ); }); var topNodes = this.endData.top.length > 0 ? h( 'span', { 'class': 'tooltip-header tooltip-item', style: { '--gap': this.$props.gap } }, [h( 'span', { 'class': 'tooltip-title' }, [h('span', [this.endData.top[0].date])] ), h( 'span', { 'class': 'tooltip-sub' }, [childTopNodes] )] ) : null; var bottomNodes = this.endData.bottom.length > 0 ? h( 'span', { 'class': 'tooltip-footer tooltip-item' }, [h( 'span', { 'class': 'tooltip-title' }, [h('span', [this.endData.top[0].date])] ), h( 'span', { 'class': 'tooltip-sub' }, [childBottomNodes] )] ) : null; return h( 'span', { 'class': ['tooltip', 'tooltip-inner-' + this.theme] }, [topNodes, bottomNodes] ); } };