refactor(图表): 标签跟随主体自动适配

This commit is contained in:
wangjiahao 2024-07-21 20:57:45 +08:00
parent 790dfe98c0
commit c28c7dd405
2 changed files with 20 additions and 1 deletions

View File

@ -296,6 +296,23 @@ export function getScaleValue(propValue, scale) {
const propValueTemp = Math.round(propValue * scale)
return propValueTemp > 1 ? propValueTemp : 1
}
export const THEME_ATTR_TRANS_ARR_MAIN = {
label: {
seriesLabelFormatter: {
isArray: []
}
}
}
export function seriesAdaptor(template, color) {
template.label?.seriesLabelFormatter?.forEach(series => {
series['color'] = color
})
template.label?.seriesTooltipFormatter?.forEach(series => {
series['color'] = color
})
}
export function recursionTransObj(template, infoObj, scale, terminal) {
for (const templateKey in template) {
@ -378,6 +395,7 @@ export function adaptCurTheme(customStyle, customAttr) {
customAttr,
LIGHT_THEME_COMPONENT_BACKGROUND
)
seriesAdaptor(customAttr, LIGHT_THEME_COLOR_MAIN)
merge(customAttr, DEFAULT_COLOR_CASE, canvasStyle.component.chartColor)
} else {
recursionThemTransObj(THEME_STYLE_TRANS_MAIN, customStyle, DARK_THEME_COLOR_MAIN)
@ -388,6 +406,7 @@ export function adaptCurTheme(customStyle, customAttr) {
customAttr,
DARK_THEME_COMPONENT_BACKGROUND_BACK
)
seriesAdaptor(customAttr, DARK_THEME_COLOR_MAIN)
merge(customAttr, DEFAULT_COLOR_CASE_DARK, canvasStyle.component.chartColor)
}
customStyle['text'] = {

View File

@ -347,7 +347,7 @@ watch(
v-model="chart.customAttr.label.show"
:change-model="chart.customAttr.label"
@modelChange="val => onLabelChange(val, 'show')"
:title="$t('chart.label')"
:title="$t('chart.label') + '11'"
name="label"
>
<label-selector