diff --git a/common/changes/@visactor/vchart/develop_2026-03-11-03-30.json b/common/changes/@visactor/vchart/develop_2026-03-11-03-30.json new file mode 100644 index 0000000000..5f5bc535a7 --- /dev/null +++ b/common/changes/@visactor/vchart/develop_2026-03-11-03-30.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: fix theme config of spec and option\n\n", + "type": "none", + "packageName": "@visactor/vchart" + } + ], + "packageName": "@visactor/vchart", + "email": "dingling112@gmail.com" +} \ No newline at end of file diff --git a/packages/vchart/src/core/vchart.ts b/packages/vchart/src/core/vchart.ts index b337bf670d..a43fd728fb 100644 --- a/packages/vchart/src/core/vchart.ts +++ b/packages/vchart/src/core/vchart.ts @@ -1471,27 +1471,19 @@ export class VChart implements IVChart { // 处理 specTheme 和 optionTheme, merge -> transform // 优先级 currentTheme < optionTheme < specTheme if (!isEmpty(optionTheme) || !isEmpty(specTheme)) { - if ( - (isString(optionTheme) && (!specTheme || isString(specTheme))) || - (isString(specTheme) && (!optionTheme || isString(optionTheme))) - ) { - const finalTheme = mergeTheme( - {}, - getThemeObject(this._currentThemeName), - getThemeObject(optionTheme), - getThemeObject(specTheme) - ); - - this._currentTheme = processThemeByChartType(chartType, finalTheme); - } else { - const finalTheme = mergeTheme( - {}, - getThemeObject(this._currentThemeName), - getThemeObject(optionTheme), - getThemeObject(specTheme) - ); - this._currentTheme = processThemeByChartType(chartType, finalTheme); - } + const finalTheme = mergeTheme( + {}, + getThemeObject( + isObject(specTheme) && specTheme.type + ? specTheme.type + : isObject(optionTheme) && optionTheme.type + ? optionTheme.type + : this._currentThemeName + ), + getThemeObject(optionTheme), + getThemeObject(specTheme) + ); + this._currentTheme = processThemeByChartType(chartType, finalTheme); } else { currentTheme = getThemeObject(this._currentThemeName); this._currentTheme = processThemeByChartType(chartType, currentTheme);