From 7eb6ad093f52563acab8d82c29675876e6088f44 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Mon, 24 Jun 2024 14:07:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BE=E8=A1=A8-=E5=9C=B0=E5=9B=BE):=20?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E9=A2=9C=E8=89=B2=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B8=90=E5=8F=98=E8=89=B2=E5=8F=8A=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=B8=90=E5=8F=98=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/BasicStyleSelector.vue | 1 + .../components/CustomColorStyleSelect.vue | 107 +++++- .../components/GradientColorSelector.vue | 306 ++++++++++++++++++ .../components/js/panel/charts/map/map.ts | 3 +- .../src/views/chart/components/js/util.ts | 56 ++++ 5 files changed, 455 insertions(+), 18 deletions(-) create mode 100644 core/core-frontend/src/views/chart/components/editor/editor-style/components/GradientColorSelector.vue diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue index d4b03bd09f..f9c6b6bbbe 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue @@ -218,6 +218,7 @@ onMounted(() => { diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/CustomColorStyleSelect.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/CustomColorStyleSelect.vue index 1dad50e0e4..3e49631681 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/CustomColorStyleSelect.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/CustomColorStyleSelect.vue @@ -3,6 +3,9 @@ import { ElColorPicker, ElPopover } from 'element-plus-secondary' import { computed, ref } from 'vue' import { useI18n } from '@/hooks/web/useI18n' import { COLOR_CASES, COLOR_PANEL } from '@/views/chart/components/editor/util/chart' +import GradientColorSelector from '@/views/chart/components/editor/editor-style/components/GradientColorSelector.vue' +import { getMapColorCases, stepsColor } from '@/views/chart/components/js/util' + const { t } = useI18n() const props = withDefaults( @@ -13,6 +16,7 @@ const props = withDefaults( customColor: any colorIndex: number } + propertyInner: Array }>(), { themes: 'light' @@ -41,30 +45,48 @@ const customColorPickerRef = ref>() function selectColorCase(option) { state.value.basicStyleForm.colorScheme = option.value colorCaseSelectorRef.value?.hide() - changeColorOption() -} -const changeColorOption = () => { - const items = colorCases.filter(ele => { - return ele.value === state.value.basicStyleForm.colorScheme - }) - state.value.basicStyleForm.colors = [...items[0].colors] - - state.value.customColor = state.value.basicStyleForm.colors[0] - state.value.colorIndex = 0 - - changeBasicStyle() + changeColorOption(option) } +const changeColorOption = (option?) => { + let isGradient = option?.value?.endsWith('_split_gradient') || isColorGradient.value + const getColorItems = isGradient ? getMapColorCases(colorCases) : colorCases + const items = getColorItems.filter(ele => ele.value === state.value.basicStyleForm.colorScheme) + + if (items.length > 0) { + state.value.basicStyleForm.colors = [...items[0].colors] + state.value.customColor = state.value.basicStyleForm.colors[0] + state.value.colorIndex = 0 + changeBasicStyle() + } +} const resetCustomColor = () => { changeColorOption() } const switchColorCase = () => { - state.value.basicStyleForm.colors[state.value.colorIndex] = state.value.customColor + const { colorIndex, customColor, basicStyleForm } = state.value + const colors = basicStyleForm.colors + + if (isColorGradient.value) { + let startColor = colorIndex === 0 ? customColor : colors[0] + let endColor = colorIndex === 0 ? colors[8] : customColor + basicStyleForm.colors = stepsColor(startColor, endColor, 9, 1) + } else { + colors[colorIndex] = customColor + } changeBasicStyle() } - +const isColorGradient = computed(() => + state.value.basicStyleForm.colorScheme.endsWith('_split_gradient') +) +const showColorGradientIndex = index => { + return index === 0 || index === state.value.basicStyleForm.colors.length - 1 +} const switchColor = (index, c) => { + if (isColorGradient.value && !showColorGradientIndex(index)) { + return + } state.value.colorIndex = index state.value.customColor = c customColorPickerRef.value?.show() @@ -81,6 +103,21 @@ function onPopoverShow() { function onPopoverHide() { _popoverShow.value = false } +const showProperty = prop => props.propertyInner?.includes(prop) +const colorItemBorderColor = (index, state) => { + const isCurrentColorActive = state.colorIndex === index + if (isColorGradient.value) { + if (showColorGradientIndex(index)) { + // 渐变色的第一个和最后一个颜色 + return isCurrentColorActive ? 'var(--ed-color-primary)' : 'rgb(230,230,230)' + } else { + // 渐变色中非边缘的颜色 + return 'rgb(230,230,230,0.01)' + } + } + // 非渐变色情况 + return isCurrentColorActive ? 'var(--ed-color-primary)' : '' +}