From 394d8e834f71c076f575c6d57454dc879e67bec9 Mon Sep 17 00:00:00 2001 From: dxq613 Date: Fri, 20 Mar 2020 10:42:44 +0800 Subject: [PATCH] feat(label): label align definition --- src/geometry/label/base.ts | 6 +++--- src/geometry/label/interface.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/geometry/label/base.ts b/src/geometry/label/base.ts index f56de231e1..e9915e600e 100644 --- a/src/geometry/label/base.ts +++ b/src/geometry/label/base.ts @@ -4,7 +4,7 @@ import { Coordinate, Scale } from '../../dependents'; import { Datum, LabelOption, LooseObject, MappingDatum, Point } from '../../interface'; import { getPolygonCentroid } from '../../util/graphics'; import Geometry from '../base'; -import { LabelCfg, LabelItem, LabelPointCfg } from './interface'; +import { LabelCfg, LabelItem, LabelPointCfg, TextAlign } from './interface'; export type GeometryLabelConstructor = new (cfg: any) => GeometryLabel; @@ -235,8 +235,8 @@ export default class GeometryLabel { * @param total * @returns */ - protected getLabelAlign(item: LabelItem, index: number, total: number) { - let align = 'center'; + protected getLabelAlign(item: LabelItem, index: number, total: number): TextAlign { + let align: TextAlign = 'center'; const coordinate = this.coordinate; if (coordinate.isTransposed) { const offset = this.getDefaultOffset(item.offset); diff --git a/src/geometry/label/interface.ts b/src/geometry/label/interface.ts index 6efec0a937..6fefbacea9 100644 --- a/src/geometry/label/interface.ts +++ b/src/geometry/label/interface.ts @@ -1,6 +1,6 @@ import { Coordinate } from '../../dependents'; import { Datum, GeometryLabelCfg, MappingDatum, Point } from '../../interface'; - +export type TextAlign = 'start' | 'center' | 'end' | 'left' | 'right'; export interface LabelCfg extends GeometryLabelCfg { content?: any; position?: 'top' | 'bottom' | 'middle' | 'left' | 'right'; @@ -16,7 +16,7 @@ export interface LabelPointCfg { start?: Point; color?: string; content?: any; - textAlign?: 'start' | 'center' | 'end' | 'left' | 'right'; + textAlign?: TextAlign; rotate?: number; angle?: number; r?: number; @@ -32,7 +32,7 @@ export interface LabelItem extends GeometryLabelCfg { start?: Point; color?: string; content?: any; - textAlign?: 'start' | 'center' | 'end' | 'left' | 'right'; + textAlign?: TextAlign; rotate?: number; angle?: number; r?: number;