Skip to content

Commit

Permalink
fix: compile error of sankey series
Browse files Browse the repository at this point in the history
  • Loading branch information
xile611 committed Jul 9, 2024
1 parent 3f1a703 commit 02c0512
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/vchart/src/series/interface/series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<A extends string> extends IModel
Expand Down Expand Up @@ -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<ILabelInfo, 'baseMark' | 'labelMark'>) => any;
Expand Down
11 changes: 6 additions & 5 deletions packages/vchart/src/series/sankey/sankey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends ISankeySeriesSpec = ISankeySeriesSpec> extends CartesianSeries<T> {
static readonly type: string = SeriesTypeEnum.sankey;
Expand Down Expand Up @@ -356,7 +357,7 @@ export class SankeySeries<T extends ISankeySeriesSpec = ISankeySeriesSpec> exten
);
}

initLabelMarkStyle(labelMark: ITextMark, labelSpec: ISankeyLabelSpec) {
initLabelMarkStyle(labelMark: ITextMark, labelSpec: ILabelSpec) {
if (!labelMark) {
return;
}
Expand All @@ -365,14 +366,14 @@ export class SankeySeries<T extends ISankeySeriesSpec = ISankeySeriesSpec> exten
if (position && position.includes('inside')) {
this.setMarkStyle<IComposedTextMarkSpec>(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<IComposedTextMarkSpec>(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
});
}

Expand Down

0 comments on commit 02c0512

Please sign in to comment.