UNPKG

iep-ui

Version:

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

129 lines (123 loc) 3.54 kB
import _extends from 'babel-runtime/helpers/extends'; import PropTypes from '../_util/vue-types'; import ChartTemplate from '../chart-template'; import { mergeProps } from '../_util/props-util'; import { isEmpty, omit } from 'lodash'; export default { name: 'IepRadarChart', props: mergeProps({ data: PropTypes.object.def(function () {}), axis: PropTypes.array.def(function () { return []; }), unit: PropTypes.array.def(function () { return []; }), theme: PropTypes.oneOf(['dark', 'light']).def('dark'), mixinOptions: PropTypes.object.def(function () {}) }, ChartTemplate.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; return { data: data, axis: axis, loading: loading, theme: theme }; } }, watch: { factor: { handler: function handler(e) { var _$props2 = this.$props, theme = _$props2.theme, mixinOptions = _$props2.mixinOptions; var tooltip = isEmpty(e.data) ? {} : { trigger: 'item', confine: true, className: 'iep-chart-tooltip-' + theme }; this.chartOptions = _extends({}, omit(this.$props, ['data', 'axis', 'mixinOptions', 'theme']), { theme: theme, loading: e.loading, options: _extends({ tooltip: tooltip, visualMap: { show: false, top: 'middle', right: 10, color: ['red', 'yellow'], calculable: true }, grid: { left: 0, right: 0, top: 0, bottom: 0 }, radar: { indicator: isEmpty(e.data) ? [''] : e.data.indicatorData, shape: 'circle', splitNumber: 4, axisName: { show: true, color: theme === 'light' ? '#333' : '#fff' }, axisLine: { lineStyle: { color: '#e5e5e5' } }, splitLine: { show: true, lineStyle: { type: 'dashed' } } }, series: isEmpty(e.data) ? [] : e.data.seriesData.map(function (item) { return { type: 'radar', symbol: 'none', lineStyle: { width: 1 }, emphasis: { areaStyle: { color: 'rgba(0,250,0,0.3)' } }, data: [_extends({ value: item.data, name: item.name }, item)] }; }) }, mixinOptions) }); }, immediate: true, deep: true } }, render: function render() { var h = arguments[0]; var chartOptions = this.chartOptions; if (!isEmpty(chartOptions)) { return h(ChartTemplate, { props: _extends({}, chartOptions) }); } else { return h(ChartTemplate); } } };