diff --git a/extensions/dataease-extensions-view/view-chartmix/view-chartmix-frontend/src/views/antv/chartmix/data.vue b/extensions/dataease-extensions-view/view-chartmix/view-chartmix-frontend/src/views/antv/chartmix/data.vue index 116b222248..e2173d0fe6 100644 --- a/extensions/dataease-extensions-view/view-chartmix/view-chartmix-frontend/src/views/antv/chartmix/data.vue +++ b/extensions/dataease-extensions-view/view-chartmix/view-chartmix-frontend/src/views/antv/chartmix/data.vue @@ -6,30 +6,30 @@ {{ $t('plugin_view_chartmix.source') }}/{{ $t('chart.dimension') }} @@ -43,28 +43,28 @@ {{ $t('plugin_view_chartmix.mark_size') }}/{{ $t('chart.quota') }} @@ -78,28 +78,28 @@ {{ $t('plugin_view_chartmix.mark_size') }}/{{ $t('chart.quota') }} @@ -114,27 +114,27 @@ {{ $t('chart.result_filter') }} @@ -152,6 +152,7 @@ import QuotaItem from '../../../components/views/QuotaItem' import QuotaExtItem from '../../../components/views/QuotaExtItem' import FilterItem from '../../../components/views/FilterItem' import messages from '@/de-base/lang/messages' +import {defaultTo} from "lodash-es" export default { props: { @@ -174,6 +175,8 @@ export default { }, data() { return { + yChartType: undefined, + yExtChartType: undefined, widgets: [], places: [], moveId: -1, @@ -229,6 +232,17 @@ export default { created() { this.$emit('on-add-languages', messages) }, + mounted() { + if (this.view.yaxis && this.view.yaxis[0]) { + this.yChartType = this.view.yaxis[0].chartType + } + if (this.view.yaxisExt && this.view.yaxisExt[0]) { + this.yExtChartType = this.view.yaxisExt[0].chartType + } + this.yChartType = defaultTo(this.yChartType, 'bar'); + this.yExtChartType = defaultTo(this.yExtChartType, 'line'); + + }, watch: { /*listenLists: function(val) { if (this.listenLists[0] <= 1 && this.listenLists[1] <= 1) { @@ -285,14 +299,8 @@ export default { this.dragMoveDuplicate(this.view.yaxis, e) this.dragCheckType(this.view.yaxis, 'q') - if (this.view.yaxis.length > 1) { - for (let i = 0; i < this.view.yaxis.length; i++) { - if (i === e.newDraggableIndex) { - continue - } - this.view.yaxis[e.newDraggableIndex].chartType = this.view.yaxis[i].chartType; - break - } + for (let i = 0; i < this.view.yaxis.length; i++) { + this.view.yaxis[i].chartType = this.yChartType } //if (this.view.yaxis.length <= 1) { @@ -304,14 +312,8 @@ export default { this.dragMoveDuplicate(this.view.yaxisExt, e) this.dragCheckType(this.view.yaxisExt, 'q') - if (this.view.yaxisExt.length > 1) { - for (let i = 0; i < this.view.yaxisExt.length; i++) { - if (i === e.newDraggableIndex) { - continue - } - this.view.yaxisExt[e.newDraggableIndex].chartType = this.view.yaxisExt[i].chartType; - break - } + for (let i = 0; i < this.view.yaxisExt.length; i++) { + this.view.yaxisExt[i].chartType = this.yExtChartType; } //if (this.view.yaxisExt.length <= 1) { @@ -360,14 +362,16 @@ export default { }, quotaItemChange(item) { + this.yChartType = item.chartType; for (let i = 0; i < this.view.yaxis.length; i++) { - this.view.yaxis[i].chartType = item.chartType + this.view.yaxis[i].chartType = this.yChartType } this.calcData(true) }, quotaExtItemChange(item) { + this.yExtChartType = item.chartType; for (let i = 0; i < this.view.yaxisExt.length; i++) { - this.view.yaxisExt[i].chartType = item.chartType + this.view.yaxisExt[i].chartType = this.yExtChartType } this.calcData(true) }, @@ -421,8 +425,8 @@ export default { newItems = groupDie ? this.selectedDimension : this.selectedQuota } const preIds = list - .filter((_, i) => i < e.newDraggableIndex || i >= e.newDraggableIndex + newItems.length) - .map(i => i.id) + .filter((_, i) => i < e.newDraggableIndex || i >= e.newDraggableIndex + newItems.length) + .map(i => i.id) // 倒序删除 for (let i = e.newDraggableIndex + newItems.length - 1; i >= e.newDraggableIndex; i--) { if (preIds.includes(list[i].id)) { diff --git a/extensions/dataease-extensions-view/view-chartmix/view-chartmix-frontend/src/views/antv/chartmix/index.vue b/extensions/dataease-extensions-view/view-chartmix/view-chartmix-frontend/src/views/antv/chartmix/index.vue index 07aba04106..ba7bc6ec09 100644 --- a/extensions/dataease-extensions-view/view-chartmix/view-chartmix-frontend/src/views/antv/chartmix/index.vue +++ b/extensions/dataease-extensions-view/view-chartmix/view-chartmix-frontend/src/views/antv/chartmix/index.vue @@ -6,23 +6,23 @@ @trackClick="trackClick"/>
@@ -43,7 +43,7 @@ import { getLineDash, DEFAULT_COLOR_CASE, formatterItem, DEFAULT_YAXIS_EXT_STYLE } from '../../../utils/map'; import ChartTitleUpdate from '../../../components/views/ChartTitleUpdate'; -import _ from 'lodash'; +import {map, filter, join, flatten, cloneDeep} from 'lodash-es'; import {clear} from 'size-sensor' import {valueFormatter} from '../../../utils/formatter' @@ -310,47 +310,47 @@ export default { const names = []; - const yChartData = this.chart.data && this.chart.data.data && this.chart.data.data.length > 0 ? _.map(_.filter(this.chart.data.data, (c, _index) => { - return _index < yaxisCount; - }), (t, _index) => { - names.push(t.name); + const yChartData = this.chart.data && this.chart.data.data && this.chart.data.data.length > 0 ? map(filter(this.chart.data.data, (c, _index) => { + return _index < yaxisCount; + }), (t, _index) => { + names.push(t.name); - return _.map(t.data, (v) => { - return { - quotaList: v.quotaList, - dimensionList: v.dimensionList, - key: _.join(_.map(v.dimensionList, (d) => d.value), "\n"), - value: v.value, - name: t.name, - i: _index, - t: 'yaxis' - } - }); - } + return map(t.data, (v) => { + return { + quotaList: v.quotaList, + dimensionList: v.dimensionList, + key: join(map(v.dimensionList, (d) => d.value), "\n"), + value: v.value, + name: t.name, + i: _index, + t: 'yaxis' + } + }); + } ) : []; - const yData = [this.getYData(_.flatten(yChartData), labelSetting, labelPosition, yaxisList, colors, gradient, alpha, xAxis, yAxis, yaxisExtList.length)]; + const yData = [this.getYData(flatten(yChartData), labelSetting, labelPosition, yaxisList, colors, gradient, alpha, xAxis, yAxis, yaxisExtList.length)]; - const yExtChartData = this.chart.data && this.chart.data.data && this.chart.data.data.length > 0 ? _.map(_.filter(this.chart.data.data, (c, _index) => { - return _index >= yaxisCount; - }), (t, _index) => { - names.push(t.name); + const yExtChartData = this.chart.data && this.chart.data.data && this.chart.data.data.length > 0 ? map(filter(this.chart.data.data, (c, _index) => { + return _index >= yaxisCount; + }), (t, _index) => { + names.push(t.name); - return _.map(t.data, (v) => { - return { - quotaList: v.quotaList, - dimensionList: v.dimensionList, - key: _.join(_.map(v.dimensionList, (d) => d.value), "\n"), - value: v.value, - name: t.name, - i: _index, - t: 'yaxisExt' - } - }) - } + return map(t.data, (v) => { + return { + quotaList: v.quotaList, + dimensionList: v.dimensionList, + key: join(map(v.dimensionList, (d) => d.value), "\n"), + value: v.value, + name: t.name, + i: _index, + t: 'yaxisExt' + } + }) + } ) : []; - const yExtData = [this.getYExtData(_.flatten(yExtChartData), labelSetting, labelPosition, yaxisExtList, colors, gradient, alpha, xAxis, yAxisExt, yaxisCount)]; + const yExtData = [this.getYExtData(flatten(yExtChartData), labelSetting, labelPosition, yaxisExtList, colors, gradient, alpha, xAxis, yAxisExt, yaxisCount)]; const params = { tooltip: false, @@ -390,7 +390,7 @@ export default { item.value = valueFormatter(item.data.value, yaxisExtList[item.data.i].formatterCfg) } }) - return _.filter(originalItems, (item) => { + return filter(originalItems, (item) => { const v = item.data.key; if (item.title === v && item.title === item.value && item.name === "key" || !names.includes(item.name)) { return false; @@ -677,7 +677,7 @@ export default { getYData(data, labelSetting, labelPosition, yaxisList, colors, gradient, alpha, xAxis, yAxis, yaxisExtCount) { - const _labelSetting = _.cloneDeep(labelSetting); + const _labelSetting = cloneDeep(labelSetting); if (_labelSetting) { _labelSetting.formatter = function (x) { for (let i = 0; i < yaxisList.length; i++) { @@ -732,7 +732,7 @@ export default { }, getYExtData(data, labelSetting, labelPosition, yaxisExtList, colors, gradient, alpha, xAxis, yAxisExt, yaxisCount) { - const _labelSetting = _.cloneDeep(labelSetting); + const _labelSetting = cloneDeep(labelSetting); if (_labelSetting) { _labelSetting.formatter = function (x) { for (let i = 0; i < yaxisExtList.length; i++) { @@ -1074,7 +1074,7 @@ export default { }, checkSelected(param) { return (this.linkageActiveParam.name === param.name || (this.linkageActiveParam.name === 'NO_DATA' && !param.name)) && - (this.linkageActiveParam.category === param.category) + (this.linkageActiveParam.category === param.category) }, trackClick(trackAction) {