UNPKG

echarts-nightly

Version:

Apache ECharts is a powerful, interactive charting and data visualization library for browser

91 lines (90 loc) 4.41 kB
import ZRText from 'zrender/lib/graphic/Text.js'; import { LabelLayoutOption, NullUndefined } from '../util/types.js'; import { BoundingRect, OrientedBoundingRect, Polyline } from '../util/graphic.js'; import { PointLike } from 'zrender/lib/core/Point.js'; import { BoundingRectIntersectOpt } from 'zrender/lib/core/BoundingRect.js'; import { MatrixArray } from 'zrender/lib/core/matrix.js'; export declare const LABEL_LAYOUT_INFO_KIND_RAW: 1; export declare const LABEL_LAYOUT_INFO_KIND_COMPUTED: 2; export declare type LabelLayoutInfoAll = LabelLayoutInfoRaw | LabelLayoutInfoComputed | NullUndefined; interface LabelLayoutInfoBase { label: ZRText; labelLine?: Polyline | NullUndefined; layoutOption?: LabelLayoutOption | NullUndefined; priority: number; defaultAttr: { ignore?: boolean; labelGuideIgnore?: boolean; }; ignoreMargin?: boolean; suggestIgnore?: boolean; } export interface LabelLayoutInfoRaw extends LabelLayoutInfoBase { kind: typeof LABEL_LAYOUT_INFO_KIND_RAW; } export interface LabelLayoutInfoComputed extends LabelLayoutInfoBase, LabelIntersectionCheckInfo { kind: typeof LABEL_LAYOUT_INFO_KIND_COMPUTED; } export interface LabelIntersectionCheckInfo { rect: BoundingRect; axisAligned: boolean; obb: OrientedBoundingRect | NullUndefined; localRect: BoundingRect; transform: number[] | NullUndefined; } export declare function createLabelLayoutList(rawList: LabelLayoutInfoRaw[]): LabelLayoutInfoComputed[]; /** * The reverse operation of `ensureLabelLayoutInfoComputedv`. */ export declare function rollbackToLabelLayoutInfoRaw(labelLayoutInfo: LabelLayoutInfoAll): LabelLayoutInfoRaw; /** * This method supports that the label layout info is not computed until needed, * for performance consideration. * * [CAUTION] * - If the raw label is changed, must call * `ensureLabelLayoutInfoComputed(rollbackToLabelLayoutInfoRaw(layoutInfo))` * to recreate the layout info. * - Null checking is needed for the result. @see prepareLabelLayoutInfo * * Usage: * To make a copy of labelLayoutInfo, simply: * const layoutInfoCopy = rollbackToLabelLayoutInfoRaw(extends({}, someLabelLayoutInfo)); */ export declare function ensureLabelLayoutInfoComputed(labelLayoutInfo: LabelLayoutInfoAll): LabelLayoutInfoComputed | NullUndefined; export declare function prepareIntersectionCheckInfo(localRect: BoundingRect, transform: MatrixArray | NullUndefined): LabelIntersectionCheckInfo; export declare function createSingleLayoutInfoComputed(el: ZRText): LabelLayoutInfoComputed | NullUndefined; /** * The input localRect is never modified. * The returned localRect maybe the input localRect. */ export declare function applyTextMarginToLocalRect(label: ZRText, localRect: BoundingRect): BoundingRect; /** * Adjust labels on x direction to avoid overlap. */ export declare function shiftLayoutOnX(list: Pick<LabelLayoutInfoComputed, 'rect' | 'label'>[], leftBound: number, rightBound: number, balanceShift?: boolean): boolean; /** * Adjust labels on y direction to avoid overlap. */ export declare function shiftLayoutOnY(list: Pick<LabelLayoutInfoComputed, 'rect' | 'label'>[], topBound: number, bottomBound: number, balanceShift?: boolean): boolean; /** * [CAUTION]: the `label.ignore` in the input is not necessarily falsy. * this method checks intersection regardless of current `ignore`, * if no intersection, restore the `ignore` to `defaultAttr.ignore`. * And `labelList` will be modified. * Therefore, if some other overlap resolving strategy has ignored some elements, * do not input them to this method. * PENDING: review the diff between the requirements from LabelManager and AxisBuilder, * and uniform the behavior? */ export declare function hideOverlap(labelList: LabelLayoutInfoAll[]): void; /** * [NOTICE]: * - `label.ignore` is not considered - no requirement so far. * - `baseLayoutInfo` and `targetLayoutInfo` may be modified - obb may be created and saved. * * Enable fast check for performance; use obb if inevitable. * If `mtv` is used, `targetLayoutInfo` can be moved based on the values filled into `mtv`. */ export declare function labelIntersect(baseLayoutInfo: LabelIntersectionCheckInfo | NullUndefined, targetLayoutInfo: LabelIntersectionCheckInfo | NullUndefined, mtv?: PointLike, intersectOpt?: BoundingRectIntersectOpt): boolean; export {};