mirror of
https://github.com/dataease/dataease.git
synced 2026-05-16 05:50:45 +08:00
fix(图表): 修复条形图类别轴文本字段有数字时指标排序失效的问题
This commit is contained in:
committed by
jianneng-fit2cloud
parent
9aa37b01e9
commit
7fdafa0be3
@@ -24,6 +24,7 @@ import {
|
||||
qqMapStyleOptions,
|
||||
tdtMapStyleOptions
|
||||
} from '@/views/chart/components/js/panel/charts/map/common'
|
||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||
|
||||
const dvMainStore = dvMainStoreWithOut()
|
||||
const localeStore = useLocaleStoreWithOut()
|
||||
@@ -149,12 +150,6 @@ const init = () => {
|
||||
}
|
||||
}
|
||||
initTableColumnWidth()
|
||||
if (
|
||||
props.chart.type.includes('-stack') &&
|
||||
state.basicStyleForm.radiusColumnBar === 'topRoundAngle'
|
||||
) {
|
||||
state.basicStyleForm.radiusColumnBar = 'roundAngle'
|
||||
}
|
||||
}
|
||||
const debouncedInit = debounce(init, 500)
|
||||
watch(
|
||||
@@ -364,6 +359,15 @@ onMounted(() => {
|
||||
mapType.value = res.mapType
|
||||
}
|
||||
})
|
||||
useEmitt({
|
||||
name: 'chart-type-change',
|
||||
callback: () => {
|
||||
if (['topRoundAngle', 'roundAngle'].includes(state.basicStyleForm.radiusColumnBar)) {
|
||||
state.basicStyleForm.radiusColumnBar = 'roundAngle'
|
||||
changeBasicStyle('radiusColumnBar')
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
|
||||
@@ -2500,24 +2500,34 @@ export const assembleOptionsDataForRoundAngle = (
|
||||
isStack?: boolean
|
||||
) => {
|
||||
// column数据分组
|
||||
const groupedByField = data.reduce((acc, item) => {
|
||||
const groupedByField = new Map<string, Record<string, any>[]>()
|
||||
|
||||
data.forEach(item => {
|
||||
let groupField = item.field
|
||||
if (isGroup || isStack) {
|
||||
groupField = `${item.field}-${isStack ? item.group : item.category}`
|
||||
}
|
||||
if (!acc[groupField]) {
|
||||
acc[groupField] = []
|
||||
if (!groupedByField.has(groupField)) {
|
||||
groupedByField.set(groupField, [])
|
||||
}
|
||||
acc[groupField].push(item)
|
||||
return acc
|
||||
}, {})
|
||||
groupedByField.get(groupField)?.push(item)
|
||||
})
|
||||
|
||||
// 遍历每个分组,添加 isFirst 和 isLast 属性
|
||||
Object.values(groupedByField).forEach(group => {
|
||||
groupedByField.forEach(group => {
|
||||
const firstItem = group[0]
|
||||
const lastItem = group[group.length - 1]
|
||||
firstItem.isFirst = true
|
||||
lastItem.isLast = true
|
||||
if (firstItem) firstItem.isFirst = true
|
||||
if (lastItem) lastItem.isLast = true
|
||||
})
|
||||
|
||||
// 按原始数据顺序重新组装
|
||||
return data.map(item => {
|
||||
let groupField = item.field
|
||||
if (isGroup || isStack) {
|
||||
groupField = `${item.field}-${isStack ? item.group : item.category}`
|
||||
}
|
||||
const group = groupedByField.get(groupField)
|
||||
return group && group.length > 0 ? group.shift() : item
|
||||
})
|
||||
// 将分组后的数据重新展开为一个数组
|
||||
return Object.values(groupedByField).flat()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user