Merge pull request #11077 from dataease/pr@dev-v2@fix_chart

Pr@dev v2@fix chart
This commit is contained in:
wisonic-s 2024-07-22 15:42:53 +08:00 committed by GitHub
commit 6fc305d398
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 17 deletions

View File

@ -21,6 +21,7 @@
"@codemirror/lang-sql": "^6.4.0", "@codemirror/lang-sql": "^6.4.0",
"@npkg/tinymce-plugins": "^0.0.7", "@npkg/tinymce-plugins": "^0.0.7",
"@tinymce/tinymce-vue": "^5.1.0", "@tinymce/tinymce-vue": "^5.1.0",
"@turf/centroid": "^7.0.0",
"@videojs-player/vue": "^1.0.0", "@videojs-player/vue": "^1.0.0",
"@vueuse/core": "^9.13.0", "@vueuse/core": "^9.13.0",
"ace-builds": "^1.15.3", "ace-builds": "^1.15.3",

View File

@ -2,6 +2,7 @@
import { computed, nextTick, onMounted, PropType, reactive, ref, watch } from 'vue' import { computed, nextTick, onMounted, PropType, reactive, ref, watch } from 'vue'
import { getGeoJsonFile, parseJson } from '../../../js/util' import { getGeoJsonFile, parseJson } from '../../../js/util'
import { forEach, debounce } from 'lodash-es' import { forEach, debounce } from 'lodash-es'
import { toRefs } from 'vue'
const props = defineProps({ const props = defineProps({
chart: { chart: {
@ -15,9 +16,9 @@ const props = defineProps({
}) })
const emit = defineEmits(['onMapMappingChange']) const emit = defineEmits(['onMapMappingChange'])
const { chart, themes } = props const { chart, themes } = toRefs(props)
watch( watch(
[() => props.chart.senior.areaMapping, () => chart.customAttr.map.id], [() => chart.value?.senior.areaMapping, () => chart.value?.customAttr.map.id],
() => { () => {
init() init()
}, },
@ -31,7 +32,7 @@ const search = ref('')
const areaNameInput = ref(null) const areaNameInput = ref(null)
const areaData = reactive([]) const areaData = reactive([])
const dynamicAreaId = computed(() => { const dynamicAreaId = computed(() => {
return chart.customAttr.map.id return chart.value?.customAttr.map.id
}) })
const state = reactive({ const state = reactive({
mappingForm: {}, mappingForm: {},
@ -43,8 +44,8 @@ const pageInfo = reactive({
currentPage: 1 currentPage: 1
}) })
const init = async () => { const init = async () => {
const chartObj = JSON.parse(JSON.stringify(chart)) const chartObj = JSON.parse(JSON.stringify(chart.value))
if (chartObj.senior) { if (chartObj?.senior) {
let senior = parseJson(chartObj.senior) let senior = parseJson(chartObj.senior)
state.mappingForm = senior.areaMapping state.mappingForm = senior.areaMapping
let curAreaMapping = state.mappingForm?.[dynamicAreaId.value] let curAreaMapping = state.mappingForm?.[dynamicAreaId.value]
@ -133,7 +134,7 @@ onMounted(() => {
:data="areaData" :data="areaData"
> >
<el-table-column label="图形" prop="originName" width="80" show-overflow-tooltip /> <el-table-column label="图形" prop="originName" width="80" show-overflow-tooltip />
<el-table-column width="144"> <el-table-column width="140">
<template #header> <template #header>
<span>属性</span> <span>属性</span>
<el-input <el-input
@ -153,7 +154,7 @@ onMounted(() => {
:class="'area-edit-btn-' + themes" :class="'area-edit-btn-' + themes"
@click="triggerEdit(scope)" @click="triggerEdit(scope)"
> >
<span>{{ scope.row.mappedName }}</span> <span :title="scope.row.mappedName">{{ scope.row.mappedName }}</span>
<el-icon><Edit /></el-icon> <el-icon><Edit /></el-icon>
</el-button> </el-button>
</template> </template>
@ -192,7 +193,7 @@ onMounted(() => {
margin-left: 8px; margin-left: 8px;
} }
.area-edit-btn { .area-edit-btn {
width: 120px; width: 116px;
padding: 0 4px; padding: 0 4px;
:deep(> span) { :deep(> span) {
display: flex; display: flex;

View File

@ -177,12 +177,7 @@ const changeLabelAttr = prop => {
const init = () => { const init = () => {
const chart = JSON.parse(JSON.stringify(props.chart)) const chart = JSON.parse(JSON.stringify(props.chart))
if (chart.customAttr) { if (chart.customAttr) {
let customAttr = null const customAttr = chart.customAttr
if (Object.prototype.toString.call(chart.customAttr) === '[object Object]') {
customAttr = JSON.parse(JSON.stringify(chart.customAttr))
} else {
customAttr = JSON.parse(chart.customAttr)
}
if (customAttr.label) { if (customAttr.label) {
state.labelForm = defaultsDeep(customAttr.label, cloneDeep(COMPUTED_DEFAULT_LABEL.value)) state.labelForm = defaultsDeep(customAttr.label, cloneDeep(COMPUTED_DEFAULT_LABEL.value))
if (chartType.value === 'liquid' && state.labelForm.fontSize < fontSizeList.value[0].value) { if (chartType.value === 'liquid' && state.labelForm.fontSize < fontSizeList.value[0].value) {

View File

@ -277,7 +277,7 @@ export const DEFAULT_LABEL: ChartLabelAttr = {
show: false, show: false,
position: 'top', position: 'top',
color: '#909399', color: '#909399',
fontSize: 10, fontSize: 12,
formatter: '', formatter: '',
labelLine: { labelLine: {
show: true show: true

View File

@ -28,6 +28,7 @@ import { DOM } from '@antv/l7-utils'
import { Scene } from '@antv/l7-scene' import { Scene } from '@antv/l7-scene'
import { type IZoomControlOption } from '@antv/l7-component' import { type IZoomControlOption } from '@antv/l7-component'
import { PositionType } from '@antv/l7-core' import { PositionType } from '@antv/l7-core'
import { centroid } from '@turf/centroid'
export function getPadding(chart: Chart): number[] { export function getPadding(chart: Chart): number[] {
if (chart.drill) { if (chart.drill) {
@ -890,8 +891,13 @@ export function configL7Tooltip(chart: Chart): TooltipOptions {
export function handleGeoJson(geoJson: FeatureCollection, nameMapping?: Record<string, string>) { export function handleGeoJson(geoJson: FeatureCollection, nameMapping?: Record<string, string>) {
geoJson.features.forEach(item => { geoJson.features.forEach(item => {
if (!item.properties['centroid'] && item.properties['center']) { if (!item.properties['centroid']) {
item.properties['centroid'] = item.properties['center'] 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'] let name = item.properties['name']
if (nameMapping?.[name]) { if (nameMapping?.[name]) {