Skip to content

fix(radar-transformer): fix theme config priority for radar #3992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/vchart/src/chart/radar/radar-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { array } from '../../util';
import { RoseLikeChartSpecTransformer } from '../polar';
import type { IRoseChartSpec } from '../rose';
import { mergeSpec } from '@visactor/vutils-extension';
import type { IPolarAxisCommonTheme } from '../../component/axis/polar/interface/theme';

export class RadarChartSpecTransformer<
T extends IRoseChartSpec = IRoseChartSpec
Expand All @@ -28,12 +29,17 @@ export class RadarChartSpecTransformer<

transformSpec(spec: T) {
super.transformSpec(spec);
//默认不显示轴的domainLine和Tick
// 默认不显示轴的 domainLine 和 Tick, 优先使用 theme 中的配置
(spec.axes ?? []).forEach((axis: any) => {
if (axis.orient === 'radius') {
['domainLine', 'label', 'tick'].forEach(configName => {
if (!axis[configName]) {
axis[configName] = { visible: false };
// 获取 theme 中的配置
const theme = this._option.getTheme?.();
const themeConfig = theme?.component?.axisRadius;
// 如果 theme 中设置了 visible,则使用 theme 的值,否则默认为 false
const themeVisible = themeConfig?.[configName as keyof IPolarAxisCommonTheme]?.visible ?? false;
axis[configName] = { visible: themeVisible };
}
});
if (!axis.grid) {
Expand Down