Skip to content
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?.();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里使用了旧版 getTheme() 的无参调用契约。当前 develop 中,VChart.getTheme(...keys)keys.length === 0 时直接返回 undefined,而 chart transformer 收到的正是这个方法。因此 themeConfig 始终为空,下面的 ?? false 会继续覆盖用户主题,本 PR 合入当前 develop 后无法修复 #3371。已用注册主题将 label/domainLine/tick.visible 全部设为 true 的真实渲染用例复现,最终三项仍全部为 false。请使用当前按路径读取主题的接口获取 component.axisRadius(例如 this._option.getTheme?.('component', 'axisRadius')),相应调整后续取值,并添加不依赖 mock 的回归测试。当前接口实现:

protected getTheme = (...keys: string[]): any => {
if (!this._currentTheme || !keys || !keys.length) {
return undefined;
}

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