diff --git a/packages/vchart/src/series/interface/series.ts b/packages/vchart/src/series/interface/series.ts index e9f1738e10..8f6ddac584 100644 --- a/packages/vchart/src/series/interface/series.ts +++ b/packages/vchart/src/series/interface/series.ts @@ -17,6 +17,7 @@ import type { IGroupMark } from '../../mark/group'; import type { IGeoCoordinateHelper } from '../../component/geo/interface'; import type { ILabelMark } from '../../mark/label'; import type { BaseLegend } from '../../component/legend/base-legend'; +import type { ILabelSpec } from '../../component/label/interface'; // 使用类型约束系列支持的样式,但是感觉这样不合理 不使用这样的方式去做 // export interface ISeries extends IModel @@ -184,7 +185,7 @@ export interface ISeries extends IModel { */ getDefaultShapeType: () => string; /** 获取系列标签配置 */ - initLabelMarkStyle?: (labelMark: ILabelMark) => void; + initLabelMarkStyle?: (labelMark: ILabelMark, labelSpec: ILabelSpec) => void; /** 设置总计标签配置 */ initTotalLabelMarkStyle?: (labelMark: ILabelMark) => void; getTotalLabelComponentStyle?: (info: Pick) => any; diff --git a/packages/vchart/src/series/sankey/sankey.ts b/packages/vchart/src/series/sankey/sankey.ts index e7eff4a226..bbad414600 100644 --- a/packages/vchart/src/series/sankey/sankey.ts +++ b/packages/vchart/src/series/sankey/sankey.ts @@ -41,6 +41,7 @@ import type { IBaseScale } from '@visactor/vscale'; import { addDataKey, initKeyMap } from '../../data/transforms/data-key'; import { SankeySeriesSpecTransformer } from './sankey-transformer'; import { getFormatFunction } from '../../component/util'; +import type { ILabelSpec } from '../../component'; export class SankeySeries extends CartesianSeries { static readonly type: string = SeriesTypeEnum.sankey; @@ -356,7 +357,7 @@ export class SankeySeries exten ); } - initLabelMarkStyle(labelMark: ITextMark, labelSpec: ISankeyLabelSpec) { + initLabelMarkStyle(labelMark: ITextMark, labelSpec: ILabelSpec) { if (!labelMark) { return; } @@ -365,14 +366,14 @@ export class SankeySeries exten if (position && position.includes('inside')) { this.setMarkStyle(labelMark, { fill: '#ffffff', - text: (datum: Datum) => this._createText(datum, labelSpec), - maxLineWidth: (datum: Datum) => labelSpec.limit ?? datum.x1 - datum.x0 + text: (datum: Datum) => this._createText(datum, labelSpec as ISankeyLabelSpec), + maxLineWidth: (datum: Datum) => (labelSpec as ISankeyLabelSpec).limit ?? datum.x1 - datum.x0 }); } else { this.setMarkStyle(labelMark, { fill: this._fillByNode, - text: (datum: Datum) => this._createText(datum, labelSpec), - maxLineWidth: labelSpec.limit + text: (datum: Datum) => this._createText(datum, labelSpec as ISankeyLabelSpec), + maxLineWidth: (labelSpec as ISankeyLabelSpec).limit }); }