Skip to content

Commit

Permalink
fix: also support polar axis
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoluoHe committed Dec 25, 2024
1 parent baff6c4 commit 2f7b826
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 11 additions & 1 deletion packages/vchart/src/component/axis/base-axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { GridEnum } from '@visactor/vgrammar-core';
import { registerComponentMark } from '../../mark/component';
import { Factory } from '../../core/factory';
// eslint-disable-next-line no-duplicate-imports
import { GroupTransition } from '@visactor/vrender-components';
import { AXIS_ELEMENT_NAME, GroupTransition } from '@visactor/vrender-components';
// eslint-disable-next-line no-duplicate-imports
import { GroupFadeOut, GroupFadeIn } from '@visactor/vrender-core';
import { scaleParser } from '../../data/parser/scale';
Expand Down Expand Up @@ -704,6 +704,16 @@ export abstract class AxisComponent<T extends ICommonAxisSpec & Record<string, a
dataToPosition(values: any[]): number {
return this._scale.scale(values);
}

getDatum(childGraphic?: IGraphic) {
if (childGraphic && childGraphic.name === AXIS_ELEMENT_NAME.label) {
return childGraphic.data;
}

if (this._axisMark) {
return this._axisMark.getProduct()?.getGroupGraphicItem()?.attribute.items;
}
}
}

export const registerAxis = () => {
Expand Down
16 changes: 3 additions & 13 deletions packages/vchart/src/component/axis/cartesian/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ICartesianHorizontal } from './interface/spec';
import { Bounds, last, type IBounds, type IBoundsLike, type Maybe } from '@visactor/vutils';
// eslint-disable-next-line no-duplicate-imports
import type { IEffect, IModelInitOption, IModelSpecInfo } from '../../../model/interface';
import { SeriesTypeEnum, type ICartesianSeries } from '../../../series/interface';
import type { ICartesianSeries } from '../../../series/interface';
import type { IRegion } from '../../../region/interface';
import type { ICartesianAxisCommonSpec, IAxisHelper, ICartesianVertical } from './interface';
import { mergeSpec } from '@visactor/vutils-extension';
Expand Down Expand Up @@ -36,7 +36,7 @@ import type { IComponentOption } from '../../interface';
// eslint-disable-next-line no-duplicate-imports
import { ComponentTypeEnum } from '../../interface/type';
import { HOOK_EVENT } from '@visactor/vgrammar-core';
import { AXIS_ELEMENT_NAME, type AxisItem, type LineAxisAttributes } from '@visactor/vrender-components';
import type { AxisItem, LineAxisAttributes } from '@visactor/vrender-components';
// eslint-disable-next-line no-duplicate-imports
import { getAxisItem, isValidCartesianAxis, shouldUpdateAxis } from '../util';
import type { IAxis, ITick } from '../interface';
Expand All @@ -46,7 +46,7 @@ import type { ICartesianTickDataOpt } from '@visactor/vrender-components';
import type { DataSet } from '@visactor/vdataset';
// eslint-disable-next-line no-duplicate-imports
import { AxisComponent } from '../base-axis';
import type { FederatedEvent, IGraphic, IText } from '@visactor/vrender-core';
import type { IGraphic, IText } from '@visactor/vrender-core';
// eslint-disable-next-line no-duplicate-imports
import { createText } from '@visactor/vrender-core';
import type { ICartesianChartSpec } from '../../../chart/cartesian/interface';
Expand Down Expand Up @@ -974,16 +974,6 @@ export abstract class CartesianAxis<T extends ICartesianAxisCommonSpec = ICartes
this._clearLayoutCache();
}

getDatum(childGraphic?: IGraphic) {
if (childGraphic && childGraphic.name === AXIS_ELEMENT_NAME.label) {
return childGraphic.data;
}

if (this._axisMark) {
return this._axisMark.getProduct()?.getGroupGraphicItem()?.attribute.items;
}
}

private _appendAxisUnit(bounds: IBounds, isX: boolean) {
if (this._spec.unit && this._spec.unit.visible) {
const { text, style } = this._spec.unit;
Expand Down

0 comments on commit 2f7b826

Please sign in to comment.