iep-ui
Version:
An enterprise-class UI design language and Vue-based implementation
201 lines (184 loc) • 5.44 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _vueTypes = require('../_util/vue-types');
var _vueTypes2 = _interopRequireDefault(_vueTypes);
var _chartTemplate = require('../chart-template');
var _chartTemplate2 = _interopRequireDefault(_chartTemplate);
var _propsUtil = require('../_util/props-util');
var _lodash = require('lodash');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
exports['default'] = {
name: 'IepScatterChart',
props: (0, _propsUtil.mergeProps)({
data: _vueTypes2['default'].object.def(function () {}),
axis: _vueTypes2['default'].array.def(function () {
return [];
}),
unit: _vueTypes2['default'].array.def(function () {
return [];
}),
theme: _vueTypes2['default'].oneOf(['dark', 'light']).def('dark'),
mixinOptions: _vueTypes2['default'].object.def(function () {}),
paramsName: _vueTypes2['default'].array.def(function () {
return [];
})
}, _chartTemplate2['default'].props),
data: function data() {
return {
chartOptions: {},
themeColor: ['#0F6EFF', '#34D59B', '#FF9540', '#A36AFF', '#FFD240', '#80D8FF', '#FB4848', '#B8C32C', '#FF7BB8', '#82A8FF']
};
},
computed: {
factor: function factor() {
var _$props = this.$props,
data = _$props.data,
axis = _$props.axis,
loading = _$props.loading,
theme = _$props.theme,
paramsName = _$props.paramsName;
return {
data: data,
axis: axis,
loading: loading,
theme: theme,
paramsName: paramsName
};
}
},
watch: {
factor: {
handler: function handler(e) {
var _this = this;
var _$props2 = this.$props,
theme = _$props2.theme,
mixinOptions = _$props2.mixinOptions;
this.chartOptions = (0, _extends3['default'])({}, (0, _lodash.omit)(this.$props, ['data', 'axis', 'mixinOptions', 'theme']), {
theme: theme,
loading: e.loading,
options: (0, _extends3['default'])({
color: this.themeColor,
grid: [{
top: '16%',
bottom: '6%',
left: '6%',
right: '6%',
containLabel: true
}],
tooltip: {
trigger: 'axis',
// show:false,
axisPointer: {
type: 'cross'
},
formatter: function formatter(e) {
return '';
},
borderColor: '#ccc'
},
xAxis: {
type: 'value',
name: this.formatName(this.paramsName[0]),
nameLocation: 'end',
nameTextStyle: {
color: this.theme === 'light' ? '#000' : '#fff',
fontSize: 14
},
axisLabel: {
formatter: function formatter(e) {
return e + (_this.paramsName[0] === 'co' ? 'mg/m3' : 'ug/m3');
}
}
},
yAxis: {
type: 'value',
name: this.formatName(this.paramsName[1]),
nameTextStyle: {
color: this.theme === 'light' ? '#000' : '#fff',
fontSize: 14
},
axisLabel: {
formatter: function formatter(e) {
return e + (_this.paramsName[1] === 'co' ? 'mg/m3' : 'ug/m3');
}
}
},
series: [{
name: e.data.name,
symbolSize: 16,
data: e.data.value,
itemStyle: e.data.itemStyle,
type: 'scatter',
emphasis: {
itemStyle: {
borderWidth: 16,
borderColor: 'rgba(255,0,0, 0.2)'
}
},
markLine: e.data.markLineOpt
}]
}, mixinOptions)
});
},
immediate: true,
deep: true
}
},
methods: {
formatName: function formatName(e) {
var enumSixParams = [{
key: 'PM2.5',
code: 'pm25'
}, {
key: 'PM10',
code: 'pm10'
}, {
key: 'SO2',
code: 'so2'
}, {
key: 'NO2',
code: 'no2'
}, {
key: 'CO',
code: 'co'
}, {
key: 'O3',
code: 'o3'
}, {
key: 'VOC',
code: 'voc'
}, {
key: 'TSP',
code: 'tsp'
}, {
key: '温度',
code: 'temperature'
}, {
key: '湿度',
code: 'humidity'
}, {
key: '风向',
code: 'windDirection'
}];
var index = enumSixParams.findIndex(function (item) {
return item.code === (e === 'winddirection' ? 'windDirection' : e);
});
if (index > -1) {
return enumSixParams[index].key;
}
}
},
render: function render() {
var h = arguments[0];
var chartOptions = this.chartOptions;
if (!(0, _lodash.isEmpty)(chartOptions)) {
return h(_chartTemplate2['default'], { props: (0, _extends3['default'])({}, chartOptions) });
} else {
return h(_chartTemplate2['default']);
}
}
};
;