From 7867d0541d180d07dbdab8fb56a60cd1dbd87ff2 Mon Sep 17 00:00:00 2001 From: wisonic Date: Mon, 22 Jul 2024 15:36:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor(=E5=9B=BE=E8=A1=A8):=20=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E4=B8=BA12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/editor-style/components/LabelSelector.vue | 7 +------ .../src/views/chart/components/editor/util/chart.ts | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/LabelSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/LabelSelector.vue index 599226dca5..993b5c3065 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/LabelSelector.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/LabelSelector.vue @@ -177,12 +177,7 @@ const changeLabelAttr = prop => { const init = () => { const chart = JSON.parse(JSON.stringify(props.chart)) if (chart.customAttr) { - let customAttr = null - if (Object.prototype.toString.call(chart.customAttr) === '[object Object]') { - customAttr = JSON.parse(JSON.stringify(chart.customAttr)) - } else { - customAttr = JSON.parse(chart.customAttr) - } + const customAttr = chart.customAttr if (customAttr.label) { state.labelForm = defaultsDeep(customAttr.label, cloneDeep(COMPUTED_DEFAULT_LABEL.value)) if (chartType.value === 'liquid' && state.labelForm.fontSize < fontSizeList.value[0].value) { diff --git a/core/core-frontend/src/views/chart/components/editor/util/chart.ts b/core/core-frontend/src/views/chart/components/editor/util/chart.ts index e8a168dc59..e194499235 100644 --- a/core/core-frontend/src/views/chart/components/editor/util/chart.ts +++ b/core/core-frontend/src/views/chart/components/editor/util/chart.ts @@ -277,7 +277,7 @@ export const DEFAULT_LABEL: ChartLabelAttr = { show: false, position: 'top', color: '#909399', - fontSize: 10, + fontSize: 12, formatter: '', labelLine: { show: true From 3996eebb89a0813cc00ae457f110297d2de6edca Mon Sep 17 00:00:00 2001 From: wisonic Date: Mon, 22 Jul 2024 15:40:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E5=9B=BE=E8=A1=A8=E5=88=87=E6=8D=A2=E5=90=8E=E5=9C=B0?= =?UTF-8?q?=E5=90=8D=E6=98=A0=E5=B0=84=E5=88=97=E8=A1=A8=E6=9C=AA=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor-senior/components/MapMapping.vue | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/editor/editor-senior/components/MapMapping.vue b/core/core-frontend/src/views/chart/components/editor/editor-senior/components/MapMapping.vue index 00d2bb1e38..98755de092 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-senior/components/MapMapping.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-senior/components/MapMapping.vue @@ -2,6 +2,7 @@ import { computed, nextTick, onMounted, PropType, reactive, ref, watch } from 'vue' import { getGeoJsonFile, parseJson } from '../../../js/util' import { forEach, debounce } from 'lodash-es' +import { toRefs } from 'vue' const props = defineProps({ chart: { @@ -15,9 +16,9 @@ const props = defineProps({ }) const emit = defineEmits(['onMapMappingChange']) -const { chart, themes } = props +const { chart, themes } = toRefs(props) watch( - [() => props.chart.senior.areaMapping, () => chart.customAttr.map.id], + [() => chart.value?.senior.areaMapping, () => chart.value?.customAttr.map.id], () => { init() }, @@ -31,7 +32,7 @@ const search = ref('') const areaNameInput = ref(null) const areaData = reactive([]) const dynamicAreaId = computed(() => { - return chart.customAttr.map.id + return chart.value?.customAttr.map.id }) const state = reactive({ mappingForm: {}, @@ -43,8 +44,8 @@ const pageInfo = reactive({ currentPage: 1 }) const init = async () => { - const chartObj = JSON.parse(JSON.stringify(chart)) - if (chartObj.senior) { + const chartObj = JSON.parse(JSON.stringify(chart.value)) + if (chartObj?.senior) { let senior = parseJson(chartObj.senior) state.mappingForm = senior.areaMapping let curAreaMapping = state.mappingForm?.[dynamicAreaId.value] @@ -133,7 +134,7 @@ onMounted(() => { :data="areaData" > - + @@ -192,7 +193,7 @@ onMounted(() => { margin-left: 8px; } .area-edit-btn { - width: 120px; + width: 116px; padding: 0 4px; :deep(> span) { display: flex; From 977519d7d8202305f3c763d20eec1b0664755d4c Mon Sep 17 00:00:00 2001 From: wisonic Date: Mon, 22 Jul 2024 15:41:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=B8=96?= =?UTF-8?q?=E7=95=8C=E5=9C=B0=E5=9B=BE=E6=A0=87=E7=AD=BE=E6=9C=AA=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=20#9890?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/package.json | 1 + .../chart/components/js/panel/common/common_antv.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/core-frontend/package.json b/core/core-frontend/package.json index 90a12fe687..dc6233168c 100644 --- a/core/core-frontend/package.json +++ b/core/core-frontend/package.json @@ -21,6 +21,7 @@ "@codemirror/lang-sql": "^6.4.0", "@npkg/tinymce-plugins": "^0.0.7", "@tinymce/tinymce-vue": "^5.1.0", + "@turf/centroid": "^7.0.0", "@videojs-player/vue": "^1.0.0", "@vueuse/core": "^9.13.0", "ace-builds": "^1.15.3", diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts index 5bc9e3f96f..050b56e31c 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts @@ -28,6 +28,7 @@ import { DOM } from '@antv/l7-utils' import { Scene } from '@antv/l7-scene' import { type IZoomControlOption } from '@antv/l7-component' import { PositionType } from '@antv/l7-core' +import { centroid } from '@turf/centroid' export function getPadding(chart: Chart): number[] { if (chart.drill) { @@ -890,8 +891,13 @@ export function configL7Tooltip(chart: Chart): TooltipOptions { export function handleGeoJson(geoJson: FeatureCollection, nameMapping?: Record) { geoJson.features.forEach(item => { - if (!item.properties['centroid'] && item.properties['center']) { - item.properties['centroid'] = item.properties['center'] + if (!item.properties['centroid']) { + if (item.properties['center']) { + item.properties['centroid'] = item.properties['center'] + } else { + const tmp = centroid(item.geometry) + item.properties['centroid'] = tmp.geometry.coordinates + } } let name = item.properties['name'] if (nameMapping?.[name]) {