Skip to content

Commit

Permalink
feat(label): label align definition
Browse files Browse the repository at this point in the history
  • Loading branch information
dxq613 authored and simaQ committed Mar 20, 2020
1 parent 8c3fda4 commit 394d8e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/geometry/label/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/geometry/label/interface.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 394d8e8

Please sign in to comment.