From f57ae108dcecdd5f2fffe9e05bf9fcffad2b05e5 Mon Sep 17 00:00:00 2001
From: wisonic-s <51065359+wisonic-s@users.noreply.github.com>
Date: Mon, 31 Mar 2025 18:37:18 +0800
Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BE=E8=A1=A8):=20=E6=8A=98=E7=BA=BF?=
=?UTF-8?q?=E5=9B=BE=E5=9B=BE=E4=BE=8B=E6=94=AF=E6=8C=81=E6=8E=92=E5=BA=8F?=
=?UTF-8?q?=20#13256?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
core/core-frontend/src/locales/en.ts | 3 +-
core/core-frontend/src/locales/tw.ts | 3 +-
core/core-frontend/src/locales/zh-CN.ts | 4 +-
.../src/models/chart/chart-style.d.ts | 11 +++
.../drag-item/components/CustomSortEdit.vue | 16 ++++
.../components/LegendSelector.vue | 77 ++++++++++++++++++-
.../chart/components/editor/util/chart.ts | 30 ++++----
.../components/js/panel/charts/line/line.ts | 55 ++++++++++++-
8 files changed, 180 insertions(+), 19 deletions(-)
diff --git a/core/core-frontend/src/locales/en.ts b/core/core-frontend/src/locales/en.ts
index d4f12cbc1e..3c6e08ffbc 100644
--- a/core/core-frontend/src/locales/en.ts
+++ b/core/core-frontend/src/locales/en.ts
@@ -2075,7 +2075,8 @@ export default {
threshold_value: 'Threshold Value',
range_num: 'Number of Range',
show_range_bg: 'Show Range Background',
- last_item: 'Last item'
+ last_item: 'Last item',
+ legend_sort: 'Legend sort'
},
dataset: {
field_value: 'Field Value',
diff --git a/core/core-frontend/src/locales/tw.ts b/core/core-frontend/src/locales/tw.ts
index da374abeb0..04f9bd18b6 100644
--- a/core/core-frontend/src/locales/tw.ts
+++ b/core/core-frontend/src/locales/tw.ts
@@ -2018,7 +2018,8 @@ export default {
threshold_value: '分界值',
range_num: '區間背景個數',
show_range_bg: '顯示區間背景',
- last_item: '最後一項'
+ last_item: '最後一項',
+ legend_sort: '圖例排序'
},
dataset: {
field_value: '欄位值',
diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts
index dc7e0944a2..abea2125c4 100644
--- a/core/core-frontend/src/locales/zh-CN.ts
+++ b/core/core-frontend/src/locales/zh-CN.ts
@@ -2024,7 +2024,8 @@ export default {
threshold_value: '分界值',
range_num: '区间背景个数',
show_range_bg: '显示区间背景',
- last_item: '最后一项'
+ last_item: '最后一项',
+ legend_sort: '图例排序'
},
dataset: {
field_value: '字段值',
@@ -3324,7 +3325,6 @@ export default {
template: '模板',
category: '分类',
all_org: '所有组织',
- custom: '自定义',
import_template: '导入模板',
copy_template: '复用模板',
upload_template: '上传模板',
diff --git a/core/core-frontend/src/models/chart/chart-style.d.ts b/core/core-frontend/src/models/chart/chart-style.d.ts
index d95b48a538..b84823319e 100644
--- a/core/core-frontend/src/models/chart/chart-style.d.ts
+++ b/core/core-frontend/src/models/chart/chart-style.d.ts
@@ -122,11 +122,22 @@ declare interface ChartLegendStyle {
* 字体大小
*/
fontSize: number
+ /**
+ * 图例大小
+ */
size: number
/**
* 子弹图显示区间背景
*/
showRange: true
+ /**
+ * 排序方式
+ */
+ sort: 'none' | 'asc' | 'desc' | 'custom'
+ /**
+ * 自定义排序
+ */
+ customSort: string[]
}
/**
diff --git a/core/core-frontend/src/views/chart/components/editor/drag-item/components/CustomSortEdit.vue b/core/core-frontend/src/views/chart/components/editor/drag-item/components/CustomSortEdit.vue
index f1c24ac957..47570e3455 100644
--- a/core/core-frontend/src/views/chart/components/editor/drag-item/components/CustomSortEdit.vue
+++ b/core/core-frontend/src/views/chart/components/editor/drag-item/components/CustomSortEdit.vue
@@ -24,6 +24,11 @@ const props = defineProps({
fieldType: {
type: String,
required: true
+ },
+ originSortList: {
+ type: Array,
+ default: () => [],
+ required: false
}
})
@@ -54,6 +59,17 @@ const init = () => {
reqMethod(param)
.then(response => {
const strArr = response.data
+ if (props.originSortList?.length) {
+ const tmp = []
+ props.originSortList.forEach(ele => {
+ const index = strArr.findIndex(item => item === ele)
+ if (index !== -1) {
+ tmp.push(strArr[index])
+ strArr.splice(index, 1)
+ }
+ })
+ strArr.unshift(...tmp)
+ }
state.sortList = strArr.map(ele => {
return transStr2Obj(ele)
})
diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/LegendSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/LegendSelector.vue
index 5e28b30df5..bcc153968b 100644
--- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/LegendSelector.vue
+++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/LegendSelector.vue
@@ -16,6 +16,7 @@ import { ElCol, ElFormItem, ElRow, ElSpace } from 'element-plus-secondary'
import { cloneDeep } from 'lodash-es'
import { useEmitt } from '@/hooks/web/useEmitt'
import { getDynamicColorScale } from '@/views/chart/components/js/util'
+import CustomSortEdit from '@/views/chart/components/editor/drag-item/components/CustomSortEdit.vue'
const { t } = useI18n()
@@ -55,7 +56,9 @@ const state = reactive({
legendForm: {
...JSON.parse(JSON.stringify(DEFAULT_LEGEND_STYLE)),
miscForm: JSON.parse(JSON.stringify(DEFAULT_MISC)) as ChartMiscAttr
- }
+ },
+ showCustomSort: false,
+ customSortField: null
})
const chartType = computed(() => {
@@ -226,6 +229,31 @@ const getMapCustomRange = index => {
if (index === state.legendForm.miscForm.mapLegendNumber) return t('chart.max')
return ''
}
+const customSort = []
+const changeLegendSort = sort => {
+ if (sort === 'custom') {
+ state.customSortField = cloneDeep(props.chart.xAxisExt?.[0])
+ if (!state.customSortField) {
+ return
+ }
+ state.showCustomSort = true
+ } else {
+ state.showCustomSort = false
+ state.legendForm.sort = sort
+ }
+ changeLegendStyle('sort')
+}
+const closeCustomSort = () => {
+ state.showCustomSort = false
+}
+const saveCustomSort = () => {
+ state.showCustomSort = false
+ state.legendForm.customSort = customSort
+ changeLegendStyle('customSort')
+}
+const customSortChange = list => {
+ customSort.splice(0, customSort.length, ...list)
+}
onMounted(() => {
init()
})
@@ -674,7 +702,54 @@ onMounted(() => {
+
+
+
+
+
+
+
+
+
+
+
+
+
+