fix(图表): 修复指标卡批量设置颜色后不生效的问题 #14321

This commit is contained in:
jianneng-fit2cloud 2025-01-07 20:52:44 +08:00 committed by jianneng-fit2cloud
parent 47303bfc00
commit 8851c23c69
6 changed files with 13 additions and 34 deletions

View File

@ -12,7 +12,6 @@ import {
DEFAULT_INDICATOR_STYLE
} from '@/views/chart/components/editor/util/chart'
import { valueFormatter } from '@/views/chart/components/js/formatter'
import { hexColorToRGBA } from '@/views/chart/components/js/util'
import { storeToRefs } from 'pinia'
const props = defineProps({
@ -292,11 +291,6 @@ const renderChart = async view => {
indicatorColor.value = indicator.color
let suffixColor = indicator.suffixColor
if (basicStyle?.alpha !== undefined && !batchOptStatus.value) {
indicatorColor.value = hexColorToRGBA(basicStyle.colors[0], basicStyle.alpha)
suffixColor = hexColorToRGBA(basicStyle.colors[1], basicStyle.alpha)
}
indicatorClass.value = {
color: thresholdColor.value.color,
'font-size': indicator.fontSize + 'px',
@ -332,10 +326,6 @@ const renderChart = async view => {
if (indicatorName?.show) {
let nameColor = indicatorName.color
if (basicStyle?.alpha !== undefined && !batchOptStatus.value) {
nameColor = hexColorToRGBA(basicStyle.colors[2], basicStyle.alpha)
}
indicatorNameShow.value = true
indicatorNameClass.value = {
color: nameColor,

View File

@ -286,8 +286,7 @@ export const THEME_ATTR_TRANS_MAIN = {
color: 'color',
proportionSeriesFormatter: ['color']
},
tooltip: ['color'],
indicatorName: ['color']
tooltip: ['color']
}
export const THEME_ATTR_TRANS_MAIN_SYMBOL = {

View File

@ -85,12 +85,6 @@ const init = () => {
cloneDeep(DEFAULT_INDICATOR_NAME_STYLE)
)
if (state.basicStyleForm.alpha !== undefined) {
const color = hexColorToRGBA(state.basicStyleForm.colors[2], state.basicStyleForm.alpha)
customText.color = color
}
state.indicatorNameForm = cloneDeep(customText)
//
@ -106,9 +100,7 @@ onMounted(() => {
watch(
() => props.chart?.customAttr?.indicatorName,
() => {
if (!batchOptStatus.value) {
init()
}
init()
},
{ deep: true }
)

View File

@ -12,7 +12,6 @@ import { PropType, computed, onMounted, reactive, watch, nextTick } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import {
COLOR_PANEL,
CHART_FONT_FAMILY,
CHART_FONT_LETTER_SPACE,
DEFAULT_INDICATOR_STYLE,
DEFAULT_BASIC_STYLE,
@ -92,14 +91,6 @@ const init = () => {
cloneDeep(DEFAULT_INDICATOR_STYLE)
)
if (state.basicStyleForm.alpha !== undefined) {
const color = hexColorToRGBA(state.basicStyleForm.colors[0], state.basicStyleForm.alpha)
const suffixColor = hexColorToRGBA(state.basicStyleForm.colors[1], state.basicStyleForm.alpha)
customText.color = color
customText.suffixColor = suffixColor
}
state.indicatorValueForm = cloneDeep(customText)
//
@ -116,9 +107,7 @@ onMounted(() => {
watch(
() => props.chart?.customAttr?.indicator,
() => {
if (!batchOptStatus.value) {
init()
}
init()
},
{ deep: true }
)

View File

@ -1,5 +1,6 @@
import { AbstractChartView, ChartLibraryType, ChartRenderType } from '../../types'
import { useI18n } from '@/hooks/web/useI18n'
import { COLOR_CASES } from '@/views/chart/components/editor/util/chart'
const { t } = useI18n()
/**
@ -61,6 +62,14 @@ export class IndicatorChartView extends AbstractChartView {
limit: 1
}
}
setupDefaultOptions(chart: ChartObj): ChartObj {
const basicColors = COLOR_CASES[0].colors
chart.customAttr.basicStyle.colors = basicColors
chart.customAttr.indicator.color = basicColors[0]
chart.customAttr.indicatorName.color = basicColors[1]
return chart
}
constructor() {
super(ChartRenderType.CUSTOM, ChartLibraryType.INDICATOR, 'indicator')
}

@ -1 +1 @@
Subproject commit fddde0d9ef360bf525232f06e144ab28fd45e6bd
Subproject commit b639016fddd096a861d592a6a3740fcb921dec0e