@visactor/vrender-components 0.22.0-vstory.11 → 0.22.0-vstory.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n EasingType,\n IGraphic,\n IGroupGraphicAttribute,\n ITextGraphicAttribute,\n IRichTextGraphicAttribute,\n IText,\n TextAlignType,\n TextBaselineType,\n ILineGraphicAttribute,\n IRichTextCharacter,\n IRichText,\n ILine,\n ICustomPath2D,\n IArc,\n IGroup\n} from '@visactor/vrender-core';\nimport type { BoundsAnchorType, IPointLike, InsideBoundsAnchorType } from '@visactor/vutils';\n\nexport type LabelItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n [key: string]: T;\n};\n\nexport type LabelItem = {\n // 用于动画\n id?: string;\n // 原始数据\n data?: any;\n [key: string]: any;\n // 文本类型:text, rich, html (区分于图元类型)\n textType?: string;\n /**\n * 文本内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n * 支持富文本内容, 如textConfig, html\n */\n text?: string | string[] | number | number[] | IRichTextCharacter[];\n /**\n * 兼容ITextGraphicAttribute与IRichTextGraphicAttribute的textAlign属性\n */\n textAlign?: 'left' | 'right' | 'center' | 'start' | 'end';\n textBaseline?: 'top' | 'middle' | 'bottom' | 'alphabetic';\n} & (\n | Omit<Partial<ITextGraphicAttribute>, 'textAlign' | 'textBaseline'>\n | Omit<Partial<IRichTextGraphicAttribute>, 'textAlign' | 'textBaseline'>\n);\n\nexport interface BaseLabelAttrs extends IGroupGraphicAttribute {\n type: string;\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n /**\n * @hack not recommend to use\n * @returns\n */\n getBaseMarks?: () => IGraphic[];\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 标签数据\n */\n data: LabelItem[];\n\n /** 文本样式,优先级低于 data */\n textStyle?: Partial<ITextGraphicAttribute>;\n\n /** 文本交互样式 */\n state?: LabelItemStateStyle<ITextGraphicAttribute>;\n\n /** 连接线样式 */\n line?: ILabelLineSpec;\n\n /** 连线的交互样式 */\n labelLineState?: LabelItemStateStyle<ILineGraphicAttribute>;\n\n syncState?: boolean;\n\n /** 标签默认位置 */\n position?: Functional<string>;\n\n /** 偏移量 */\n offset?: number;\n\n /** 是否开启防重叠\n * @default true\n */\n overlap?: OverlapAttrs | boolean;\n\n /** 智能反色 */\n smartInvert?: SmartInvertAttrs | boolean;\n\n /** 动画配置 */\n animation?: ILabelAnimation | boolean;\n /**\n * 新增标签动画\n */\n animationEnter?: ILabelUpdateAnimation | boolean;\n /**\n * 标签更新动画\n */\n animationUpdate?: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[] | boolean;\n /**\n * 标签被删除的动画配置\n */\n animationExit?: ILabelExitAnimation | boolean;\n\n /**\n * 数据过滤自定义函数,可以用于 排序 or 删减\n */\n dataFilter?: (data: LabelItem[]) => LabelItem[];\n\n /** 自定义布局函数\n * @description 当配置了 customLayoutFunc 后,默认布局逻辑将不再生效。(position/offset不生效)\n */\n customLayoutFunc?: (\n item: LabelItem[],\n labels: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint?: (data: LabelItem) => IPointLike\n ) => (IText | IRichText)[];\n\n /** 自定义标签躲避函数\n * @description 当配置了 customOverlapFunc 后,会根据 position 和 offset 进行初始布局。配置的防重叠逻辑(overlap)不生效。\n */\n customOverlapFunc?: (\n label: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint?: (data: LabelItem) => IPointLike\n ) => (IText | IRichText)[];\n /**\n * 防重叠计算完成后的回调函数\n * @since 1.19.16\n */\n onAfterOverlapping?: (\n labels: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint?: (data: LabelItem) => IPointLike\n ) => void;\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n /** 唯一标志符 */\n id?: string;\n}\n\nexport interface OverlapAttrs {\n /**\n * 防重叠的区域大小\n */\n size?: { width: number; height: number };\n\n /**\n * 发生重叠后,是否隐藏标签\n * @default true\n */\n hideOnHit?: boolean;\n\n /**\n * 是否约束标签在指定 size 的范围内。开启后若标签被区域裁剪,会向内收缩。\n * @default true\n */\n clampForce?: boolean;\n\n /**\n * 是否躲避基础图元\n * @default false\n */\n avoidBaseMark?: boolean;\n\n /**\n * 躲避指定图元\n * @default []\n */\n avoidMarks?: string[] | IGraphic[];\n\n /**\n * 发生重叠后的躲避策略\n * @since 0.20.10 支持全局 Y 方向偏移策略 'shiftY'。当标签发生重叠时,会保相对位置并在 Y 方向上散开。由于 'shiftY' 是全局布局策略,不与其他策略同时生效。\n */\n strategy?: Strategy[] | ShiftYStrategy;\n\n /**\n * 文字在防重叠计算中预留的边距。\n * @default 0\n */\n overlapPadding?: number;\n\n /**\n * 防重叠的顺序权重\n * @since 0.20.10\n * @param labelItem\n * @returns number 数值越大,权重越高。权重越高的标签越优先被布局。\n */\n priority?: (labelItem: LabelItem) => number;\n}\n\nexport interface SmartInvertAttrs {\n /**\n * 对比度度量\n * 'WCAG' | 'lightness'\n * 默认使用'WCAG'\n */\n mode?: string;\n /**\n * 文本类型\n * 包含普通文本和大文本,对应不同的对比度标准,label默认为普通文本\n * 'normalText' | 'largeText'\n * @default 'normalText'\n */\n textType?: string;\n /**\n * 自定义对比度阈值\n */\n contrastRatiosThreshold?: number;\n /**\n * 自定义备选label颜色\n */\n alternativeColors?: string | string[];\n /**\n * fillStrategy四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持fill设置的颜色)\n * @default 'invertBase'\n */\n fillStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * strokeStrategy的四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持stroke设置的颜色)\n * @default 'base'\n */\n strokeStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * 前景色与亮色具有对比度时,similarSeries使用该色\n * @default '#ffffff'\n */\n brightColor?: string;\n /**\n * 前景色与暗色具有对比度时,similarSeries使用该色\n * @default '#000000'\n */\n darkColor?: string;\n /**\n * label超出mark范围,也以mark作为背景色进行反色\n */\n outsideEnable?: boolean;\n /**\n * 当标签和mark相交,但是没有完全在mark内部的时候,支持三种处理方式:\n *\n * * none:不做任何处理\n * * stroked:标签存在描边的时候,根据描边进行处理\n * * inside: 和标签完全在mark内部一样处理\n */\n interactInvertType?: 'none' | 'stroked' | 'inside';\n}\n\nexport type ShiftYStrategy = {\n type: 'shiftY';\n /**\n * 布局迭代次数\n * @default 10\n */\n iteration?: number;\n /**\n * 布局容差\n * @default 0.1\n */\n maxError?: number;\n /**\n * 散开后的间距\n * @default 1\n */\n padding?: number;\n};\n\nexport type PositionStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n position?: Functional<LabelPosition[]>;\n /**\n * 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。\n * 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。\n * @since 0.20.18\n * @default true\n */\n restorePosition?: boolean;\n};\n\nexport type BoundStrategy = {\n /**\n * 标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n position?: Functional<LabelPosition[]>;\n /**\n * 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。\n * 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。\n * @since 0.20.18\n * @default true\n */\n restorePosition?: boolean;\n};\n\nexport type MoveYStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在Y方向上寻找位置。\n */\n type: 'moveY';\n /**\n * Y方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type MoveXStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在X方向上寻找位置。\n */\n type: 'moveX';\n /**\n * X方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type Strategy = PositionStrategy | BoundStrategy | MoveYStrategy | MoveXStrategy;\n\nexport type LabelPosition = SymbolLabelAttrs['position'] | RectLabelAttrs['position'];\n\nexport interface SymbolLabelAttrs extends BaseLabelAttrs {\n type: 'symbol';\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<BoundsAnchorType>;\n}\n\nexport interface RectLabelAttrs extends BaseLabelAttrs {\n type: 'rect';\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<InsideBoundsAnchorType | BoundsAnchorType>;\n}\n\nexport interface LineLabelAttrs extends BaseLabelAttrs {\n type: 'line';\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface AreaLabelAttrs extends BaseLabelAttrs {\n type: 'area';\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface LineDataLabelAttrs extends BaseLabelAttrs {\n type: 'line-data';\n\n /**\n * 标签位置\n * @default 'top'\n * @since 0.21.1 支持 'inside-middle' 在面积图元中显示在中间位置\n */\n position?: Functional<BoundsAnchorType | 'inside-middle'>;\n}\n\nexport interface PolygonLabelAttrs extends BaseLabelAttrs {\n type: 'polygon';\n /**\n * 标签位置\n * @default 'center'\n */\n position?: Functional<'center'>;\n}\n\nexport interface ArcLabelAttrs extends BaseLabelAttrs {\n type: 'arc';\n\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n\n /**\n * 标签位置\n * @default 'outside'\n * @since 0.20.1 support 'inside-center'\n */\n position?: 'inside' | 'outside' | 'inside-inner' | 'inside-outer' | 'inside-center';\n\n // 画布宽度\n width?: number;\n // 画布高度\n height?: number;\n\n /**\n * 是否允许标签重叠\n * @default false\n */\n coverEnable?: boolean;\n /**\n * 是否允许标签旋转\n * @default true\n */\n rotate?: boolean;\n\n /**\n * 文字与引导线间隔宽度\n * @default 5\n */\n spaceWidth?: number;\n /**\n * 标签旋转角度\n */\n angle?: number;\n /**\n * 标签旋转角度的偏移角度\n */\n offsetAngle?: number;\n /**\n * 标签相对于 `outerRadius` 的径向偏移,目前仅作用于 inside 标签\n */\n offsetRadius?: number;\n /**\n * 标签横向点对齐\n */\n textAlign?: TextAlignType;\n /**\n * 标签纵向点对齐\n */\n textBaseline?: TextBaselineType;\n /**\n * 扇区间标签的间隔\n * @default 6\n */\n layoutArcGap?: number;\n /** 标签引导线样式 */\n line?: IArcLabelLineSpec;\n /** 标签布局配置 */\n layout?: IArcLabelLayoutSpec;\n /** 标签引导线点集 */\n points?: IPoint[];\n /** 饼图扇区中心偏移 */\n centerOffset?: number;\n}\n\nexport interface ILabelLineSpec {\n /**\n * 是否显示引导线\n * @default true\n */\n visible?: boolean;\n /**\n * 自定义路径\n * @since 0.19.21\n */\n customShape?: (container: IGroup, attrs: Partial<ILineGraphicAttribute>, path: ICustomPath2D) => ICustomPath2D;\n /**\n * 引导线样式\n */\n style?: Partial<ILineGraphicAttribute>;\n}\n\nexport interface IArcLabelLineSpec extends ILabelLineSpec {\n /**\n * 引导线 line1 部分最小长度\n * @default 20\n */\n line1MinLength?: number;\n /**\n * 引导线 line2 部分最小长度\n * @default 10\n * @since 0.20.3 支持函数回调\n */\n line2MinLength?: number | ((texts: IGraphic[], arcs: IArc[], attrs: Partial<ArcLabelAttrs>) => number);\n /**\n * 引导线是否光滑\n * @default false\n */\n smooth?: boolean;\n}\n\nexport type ArcLabelAlignType = 'arc' | 'labelLine' | 'edge';\n\nexport type ArcLabelStrategyType = 'priority' | 'vertical' | 'none';\n\nexport interface IArcLabelLayoutSpec {\n /**\n * 标签对齐方式\n * @default 'arc'\n */\n textAlign?: ArcLabelAlignType;\n /** @deprecate 建议统一使用textAlign,后续将废除 */\n align?: ArcLabelAlignType;\n /**\n * 标签对齐的偏移量\n * @since 0.20.3\n */\n alignOffset?: number | ((texts: IGraphic[], arcs: IArc[], attrs: Partial<ArcLabelAttrs>) => number);\n /**\n * 标签布局策略\n * @default 'priority'\n */\n strategy?: ArcLabelStrategyType;\n /**\n * 是否启用切线约束\n * @default true\n */\n tangentConstraint?: boolean;\n}\n\nexport interface DataLabelAttrs extends IGroupGraphicAttribute {\n dataLabels: (RectLabelAttrs | SymbolLabelAttrs | ArcLabelAttrs | LineDataLabelAttrs)[];\n /**\n * 防重叠的区域大小\n */\n size: { width: number; height: number; padding?: { top?: number; left?: number; right?: number; bottom?: number } };\n}\n\nexport type Functional<T> = T | ((data: any) => T);\n\nexport interface ILabelExitAnimation {\n duration?: number;\n delay?: number;\n easing?: EasingType;\n}\n\nexport interface ILabelEnterAnimation extends ILabelExitAnimation {\n mode?: 'same-time' | 'after' | 'after-all';\n}\n\nexport interface ILabelUpdateAnimation extends ILabelExitAnimation {\n /** 是否开启 increaseCount 动画\n * @default true\n */\n increaseEffect?: boolean;\n}\n\nexport interface ILabelUpdateChannelAnimation extends ILabelUpdateAnimation {\n channel?: string[];\n options?: { excludeChannels?: string[] };\n}\n\nexport interface ILabelAnimation extends ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation {}\n\nexport interface IPoint {\n x: number;\n y: number;\n}\n\nexport interface IPolarPoint {\n radius: number;\n angle: number;\n}\n\nexport type Quadrant = 1 | 2 | 3 | 4;\n\nexport type TextAlign = 'left' | 'right' | 'center';\n\nexport type LabelContent = {\n text: IText | IRichText;\n labelLine?: ILine;\n};\n"]}
1
+ {"version":3,"sources":["../src/label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n EasingType,\n IGraphic,\n IGroupGraphicAttribute,\n ITextGraphicAttribute,\n IRichTextGraphicAttribute,\n IText,\n TextAlignType,\n TextBaselineType,\n ILineGraphicAttribute,\n IRichTextCharacter,\n IRichText,\n ILine,\n ICustomPath2D,\n IArc,\n IGroup\n} from '@visactor/vrender-core';\nimport type { BoundsAnchorType, IPointLike, InsideBoundsAnchorType } from '@visactor/vutils';\n\nexport type LabelItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n [key: string]: T;\n};\n\nexport type LabelItem = {\n // 用于动画\n id?: string;\n // 原始数据\n data?: any;\n [key: string]: any;\n // 文本类型:text, rich, html (区分于图元类型)\n textType?: string;\n /**\n * 文本内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n * 支持富文本内容, 如textConfig, html\n */\n text?: string | string[] | number | number[] | IRichTextCharacter[];\n /**\n * 兼容ITextGraphicAttribute与IRichTextGraphicAttribute的textAlign属性\n */\n textAlign?: 'left' | 'right' | 'center' | 'start' | 'end';\n textBaseline?: 'top' | 'middle' | 'bottom' | 'alphabetic';\n} & (\n | Omit<Partial<ITextGraphicAttribute>, 'textAlign' | 'textBaseline'>\n | Omit<Partial<IRichTextGraphicAttribute>, 'textAlign' | 'textBaseline'>\n);\n\nexport interface BaseLabelAttrs extends IGroupGraphicAttribute {\n type: string;\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n /**\n * @hack not recommend to use\n * @returns\n */\n getBaseMarks?: () => IGraphic[];\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 标签数据\n */\n data: LabelItem[];\n\n /** 文本样式,优先级低于 data */\n textStyle?: Partial<ITextGraphicAttribute>;\n\n /** 文本交互样式 */\n state?: LabelItemStateStyle<ITextGraphicAttribute>;\n\n /** 连接线样式 */\n line?: ILabelLineSpec;\n\n /** 连线的交互样式 */\n labelLineState?: LabelItemStateStyle<ILineGraphicAttribute>;\n\n syncState?: boolean;\n\n /** 标签默认位置 */\n position?: Functional<string>;\n\n /** 偏移量 */\n offset?: number;\n\n /** 是否开启防重叠\n * @default true\n */\n overlap?: OverlapAttrs | boolean;\n\n /** 智能反色 */\n smartInvert?: SmartInvertAttrs | boolean;\n\n /** 动画配置 */\n animation?: ILabelAnimation | boolean;\n /**\n * 新增标签动画\n */\n animationEnter?: ILabelUpdateAnimation | boolean;\n /**\n * 标签更新动画\n */\n animationUpdate?: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[] | boolean;\n /**\n * 标签被删除的动画配置\n */\n animationExit?: ILabelExitAnimation | boolean;\n\n /**\n * 数据过滤自定义函数,可以用于 排序 or 删减\n */\n dataFilter?: (data: LabelItem[]) => LabelItem[];\n\n /** 自定义布局函数\n * @description 当配置了 customLayoutFunc 后,默认布局逻辑将不再生效。(position/offset不生效)\n */\n customLayoutFunc?: (\n item: LabelItem[],\n labels: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint: ((data: LabelItem) => IPointLike) | null | undefined,\n labelComponent: IGroup\n ) => (IText | IRichText)[];\n\n /** 自定义标签躲避函数\n * @description 当配置了 customOverlapFunc 后,会根据 position 和 offset 进行初始布局。配置的防重叠逻辑(overlap)不生效。\n */\n customOverlapFunc?: (\n label: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint: ((data: LabelItem) => IPointLike) | null | undefined,\n labelComponent: IGroup\n ) => (IText | IRichText)[];\n /**\n * 防重叠计算完成后的回调函数\n * @since 1.19.16\n */\n onAfterOverlapping?: (\n labels: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint: ((data: LabelItem) => IPointLike) | null | undefined,\n labelComponent: IGroup\n ) => void;\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n /** 唯一标志符 */\n id?: string;\n}\n\nexport interface OverlapAttrs {\n /**\n * 防重叠的区域大小\n */\n size?: {\n /**\n * 防重叠区域的宽度\n */\n width: number;\n /**\n * 防重叠区域的高度\n */\n height: number;\n };\n\n /**\n * 发生重叠后,是否隐藏标签\n * @default true\n */\n hideOnHit?: boolean;\n\n /**\n * 是否约束标签在指定 size 的范围内。开启后若标签被区域裁剪,会向内收缩。\n * @default true\n */\n clampForce?: boolean;\n\n /**\n * 是否躲避基础图元\n * @default false\n */\n avoidBaseMark?: boolean;\n\n /**\n * 躲避指定图元\n * @default []\n */\n avoidMarks?: string[] | IGraphic[];\n\n /**\n * 发生重叠后的躲避策略\n * @since 0.20.10 支持全局 Y 方向偏移策略 'shiftY'。当标签发生重叠时,会保相对位置并在 Y 方向上散开。由于 'shiftY' 是全局布局策略,不与其他策略同时生效。\n */\n strategy?: Strategy[] | ShiftYStrategy;\n\n /**\n * 文字在防重叠计算中预留的边距。\n * @default 0\n */\n overlapPadding?: number;\n\n /**\n * 防重叠的顺序权重\n * @since 0.20.10\n * @param labelItem\n * @returns number 数值越大,权重越高。权重越高的标签越优先被布局。\n */\n priority?: (labelItem: LabelItem) => number;\n}\n\nexport interface SmartInvertAttrs {\n /**\n * 对比度度量\n * 'WCAG' | 'lightness'\n * 默认使用'WCAG'\n */\n mode?: string;\n /**\n * 文本类型\n * 包含普通文本和大文本,对应不同的对比度标准,label默认为普通文本\n * 'normalText' | 'largeText'\n * @default 'normalText'\n */\n textType?: string;\n /**\n * 自定义对比度阈值\n */\n contrastRatiosThreshold?: number;\n /**\n * 自定义备选label颜色\n */\n alternativeColors?: string | string[];\n /**\n * fillStrategy四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持fill设置的颜色)\n * @default 'invertBase'\n */\n fillStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * strokeStrategy的四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持stroke设置的颜色)\n * @default 'base'\n */\n strokeStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * 前景色与亮色具有对比度时,similarSeries使用该色\n * @default '#ffffff'\n */\n brightColor?: string;\n /**\n * 前景色与暗色具有对比度时,similarSeries使用该色\n * @default '#000000'\n */\n darkColor?: string;\n /**\n * label超出mark范围,也以mark作为背景色进行反色\n */\n outsideEnable?: boolean;\n /**\n * 当标签和mark相交,但是没有完全在mark内部的时候,支持三种处理方式:\n *\n * * none:不做任何处理\n * * stroked:标签存在描边的时候,根据描边进行处理\n * * inside: 和标签完全在mark内部一样处理\n */\n interactInvertType?: 'none' | 'stroked' | 'inside';\n}\n\nexport type ShiftYStrategy = {\n /**\n * 将防重叠策略设置为 'shiftY'\n */\n type: 'shiftY';\n /**\n * 布局迭代次数\n * @default 10\n */\n iteration?: number;\n /**\n * 布局容差\n * @default 0.1\n */\n maxError?: number;\n /**\n * 散开后的间距\n * @default 1\n */\n padding?: number;\n};\n\nexport type PositionStrategy = {\n /**\n * 将防重叠的策略设置为'position',即可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n /**\n * 所有的备选位置\n */\n position?: Functional<LabelPosition[]>;\n /**\n * 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。\n * 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。\n * @since 0.20.18\n * @default true\n */\n restorePosition?: boolean;\n};\n\nexport type BoundStrategy = {\n /**\n * 将防重叠策略设置为'bound',当标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n /**\n * 所有的备选位置\n */\n position?: Functional<LabelPosition[]>;\n /**\n * 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。\n * 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。\n * @since 0.20.18\n * @default true\n */\n restorePosition?: boolean;\n};\n\nexport type MoveYStrategy = {\n /**\n * 将防重叠策略设置为'moveY'\n * 若默认位置没有足够的空间放置标签,则根据 offset 在Y方向上寻找位置。\n */\n type: 'moveY';\n /**\n * Y方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type MoveXStrategy = {\n /**\n * 将防重叠策略设置为'moveX'\n * 若默认位置没有足够的空间放置标签,则根据 offset 在X方向上寻找位置。\n */\n type: 'moveX';\n /**\n * X方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type Strategy = PositionStrategy | BoundStrategy | MoveYStrategy | MoveXStrategy;\n\nexport type LabelPosition = SymbolLabelAttrs['position'] | RectLabelAttrs['position'];\n\nexport interface SymbolLabelAttrs extends BaseLabelAttrs {\n type: 'symbol';\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<BoundsAnchorType>;\n}\n\nexport interface RectLabelAttrs extends BaseLabelAttrs {\n type: 'rect';\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<InsideBoundsAnchorType | BoundsAnchorType>;\n}\n\nexport interface LineLabelAttrs extends BaseLabelAttrs {\n type: 'line';\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface AreaLabelAttrs extends BaseLabelAttrs {\n type: 'area';\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface LineDataLabelAttrs extends BaseLabelAttrs {\n type: 'line-data';\n\n /**\n * 标签位置\n * @default 'top'\n * @since 0.21.1 支持 'inside-middle' 在面积图元中显示在中间位置\n */\n position?: Functional<BoundsAnchorType | 'inside-middle'>;\n}\n\nexport interface PolygonLabelAttrs extends BaseLabelAttrs {\n type: 'polygon';\n /**\n * 标签位置\n * @default 'center'\n */\n position?: Functional<'center'>;\n}\n\nexport interface ArcLabelAttrs extends BaseLabelAttrs {\n type: 'arc';\n\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n\n /**\n * 标签位置\n * @default 'outside'\n * @since 0.20.1 support 'inside-center'\n */\n position?: 'inside' | 'outside' | 'inside-inner' | 'inside-outer' | 'inside-center';\n\n // 画布宽度\n width?: number;\n // 画布高度\n height?: number;\n\n /**\n * 是否允许标签重叠\n * @default false\n */\n coverEnable?: boolean;\n /**\n * 是否允许标签旋转\n * @default true\n */\n rotate?: boolean;\n\n /**\n * 文字与引导线间隔宽度\n * @default 5\n */\n spaceWidth?: number;\n /**\n * 标签旋转角度\n */\n angle?: number;\n /**\n * 标签旋转角度的偏移角度\n */\n offsetAngle?: number;\n /**\n * 标签相对于 `outerRadius` 的径向偏移,目前仅作用于 inside 标签\n */\n offsetRadius?: number;\n /**\n * 标签横向点对齐\n */\n textAlign?: TextAlignType;\n /**\n * 标签纵向点对齐\n */\n textBaseline?: TextBaselineType;\n /**\n * 扇区间标签的间隔\n * @default 6\n */\n layoutArcGap?: number;\n /** 标签引导线样式 */\n line?: IArcLabelLineSpec;\n /** 标签布局配置 */\n layout?: IArcLabelLayoutSpec;\n /** 标签引导线点集 */\n points?: IPoint[];\n /** 饼图扇区中心偏移 */\n centerOffset?: number;\n}\n\nexport interface ILabelLineSpec {\n /**\n * 是否显示引导线\n * @default true\n */\n visible?: boolean;\n /**\n * 自定义路径\n * @since 0.19.21\n */\n customShape?: (container: IGroup, attrs: Partial<ILineGraphicAttribute>, path: ICustomPath2D) => ICustomPath2D;\n /**\n * 引导线样式\n */\n style?: Partial<ILineGraphicAttribute>;\n}\n\nexport interface IArcLabelLineSpec extends ILabelLineSpec {\n /**\n * 引导线 line1 部分最小长度\n * @default 20\n */\n line1MinLength?: number;\n /**\n * 引导线 line2 部分最小长度\n * @default 10\n * @since 0.20.3 支持函数回调\n */\n line2MinLength?: number | ((texts: IGraphic[], arcs: IArc[], attrs: Partial<ArcLabelAttrs>) => number);\n /**\n * 引导线是否光滑\n * @default false\n */\n smooth?: boolean;\n}\n\nexport type ArcLabelAlignType = 'arc' | 'labelLine' | 'edge';\n\nexport type ArcLabelStrategyType = 'priority' | 'vertical' | 'none';\n\nexport interface IArcLabelLayoutSpec {\n /**\n * 标签对齐方式\n * @default 'arc'\n */\n textAlign?: ArcLabelAlignType;\n /** @deprecate 建议统一使用textAlign,后续将废除 */\n align?: ArcLabelAlignType;\n /**\n * 标签对齐的偏移量\n * @since 0.20.3\n */\n alignOffset?: number | ((texts: IGraphic[], arcs: IArc[], attrs: Partial<ArcLabelAttrs>) => number);\n /**\n * 标签布局策略\n * @default 'priority'\n */\n strategy?: ArcLabelStrategyType;\n /**\n * 是否启用切线约束\n * @default true\n */\n tangentConstraint?: boolean;\n}\n\nexport interface DataLabelAttrs extends IGroupGraphicAttribute {\n dataLabels: (RectLabelAttrs | SymbolLabelAttrs | ArcLabelAttrs | LineDataLabelAttrs)[];\n /**\n * 防重叠的区域大小\n */\n size: { width: number; height: number; padding?: { top?: number; left?: number; right?: number; bottom?: number } };\n}\n\nexport type Functional<T> = T | ((data: any) => T);\n\n/**\n * 标签的离场动画配置\n */\nexport interface ILabelExitAnimation {\n /**\n * 动画执行的时长\n */\n duration?: number;\n /**\n * 动画延迟的时长\n */\n delay?: number;\n /**\n * 动画的缓动函数\n */\n easing?: EasingType;\n}\n\n/**\n * 标签的入场动画配置\n */\nexport interface ILabelEnterAnimation extends ILabelExitAnimation {\n /**\n * 标签动画的模式,支持三种类型\n * - same-time:标签出现动画和关联图形的动画同时进行\n * - after:当关联动图的出场动画结束后,执行标签的出场动画\n * - after-all:当所有关联图元的出场动画结束后,执行标签的出场动画\n */\n mode?: 'same-time' | 'after' | 'after-all';\n}\n\n/**\n * 标签的更新动画配置\n */\nexport interface ILabelUpdateAnimation extends ILabelExitAnimation {\n /**\n * 是否开启 increaseCount 动画\n * @default true\n */\n increaseEffect?: boolean;\n}\n\n/**\n * 标签更新的时候,动画的通道配置\n */\nexport interface ILabelUpdateChannelAnimation extends ILabelUpdateAnimation {\n /**\n * 进行插值动画的视觉通道\n */\n channel?: string[];\n /**\n * 动画的配置\n */\n options?: {\n /**\n * 忽略的视觉通道\n */\n excludeChannels?: string[];\n };\n}\n\nexport interface ILabelAnimation extends ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation {}\n\nexport interface IPoint {\n x: number;\n y: number;\n}\n\nexport interface IPolarPoint {\n radius: number;\n angle: number;\n}\n\nexport type Quadrant = 1 | 2 | 3 | 4;\n\nexport type TextAlign = 'left' | 'right' | 'center';\n\nexport type LabelContent = {\n text: IText | IRichText;\n labelLine?: ILine;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/legend/discrete/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n EasingType,\n IGroupGraphicAttribute,\n ILinearGradient,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { BaseGraphicAttributes, Padding } from '../../core/type';\nimport type { PagerAttributes } from '../../pager/type';\nimport type { LegendBaseAttributes } from '../type';\nimport type { ScrollBarAttributes } from '../../scrollbar/type';\nimport type { GraphicEventType } from '@visactor/vrender-core';\n\nexport interface LegendSwitchComponentAttributes {\n /**\n * 翻页组件同图例内容项之间的间距\n */\n space?: number;\n /**\n * the default page\n */\n defaultCurrent?: number;\n /**\n * 翻页是否开启动画\n */\n animation?: boolean;\n /**\n * 动画执行时间\n */\n animationDuration?: number;\n /**\n * 动画执行效果\n */\n animationEasing?: EasingType;\n}\n\nexport type LegendPagerAttributes = Omit<PagerAttributes, 'total'> &\n LegendSwitchComponentAttributes & {\n /**\n * 分页器的显示位置,默认 'middle'\n * @default 'middle'\n */\n position?: 'start' | 'middle' | 'end';\n };\n\nexport type LegendScrollbarAttributes = Omit<ScrollBarAttributes, 'range' | 'limitRange'> &\n LegendSwitchComponentAttributes & {\n type: 'scrollbar';\n /**\n * @deprecated since 0.20.13\n * 滚动条的位置是否支持展示在分页的中间。\n * 0.20.13 版本改造了滚动条逻辑后,此配置废弃。改造内容:\n * 由分页拟合的滚动调整为滚动窗口的逻辑,不再与分页绑定\n */\n scrollByPosition?: boolean;\n /**\n * 是否支持鼠标/触控板滚动\n * @default false\n */\n roamScroll?: boolean;\n /**\n * @since 0.20.13\n * 是否隐藏滚动条\n */\n visible?: boolean;\n /**\n * @since 0.20.13\n * 滚动时,图例区域未到尽头时的前后遮罩\n */\n scrollMask?: {\n /** 是否显示 @default false */\n visible?: boolean;\n /** 渐变区域长度 @default 16 */\n gradientLength?: number;\n /** 渐变配置 */\n gradientStops: ILinearGradient['stops'];\n };\n };\n\nexport type LegendItemDatum = {\n /**\n * 该条数据的唯一标识,可用于动画或者查找\n */\n id?: string;\n /** 显示文本 */\n label: string;\n /** 显示数据 */\n value?: string | number;\n /** 图例项前的 shape 形状定义 */\n shape: {\n symbolType?: string;\n fill?: string;\n stroke?: string;\n };\n [key: string]: any;\n};\n\nexport type StyleCallback<T> = (\n item: LegendItemDatum,\n isSelected: boolean,\n index: number,\n allItems: LegendItemDatum[]\n) => T;\n\nexport type formatterCallback = (text: string | number, item: LegendItemDatum, index: number) => any;\n\nexport type LegendItem = {\n /**\n * 是否展示图例项\n * @default true\n */\n visible?: boolean;\n /**\n * 图例项的列间距 水平间距\n */\n spaceCol?: number;\n /**\n * 图例项的行间距 垂直间距\n */\n spaceRow?: number;\n /**\n * 图例项的最大宽度,默认为 null,由上层传入\n */\n maxWidth?: number;\n /**\n * 图例项的宽度, 默认自动计算\n */\n width?: number;\n /**\n * 图例的高度,默认自动计算\n */\n height?: number;\n /**\n * 图例项自身的内边距\n */\n padding?: Padding;\n /**\n * 图例项背景配置\n */\n background?: {\n visible?: boolean;\n } & BaseGraphicAttributes<Partial<IGroupGraphicAttribute> | StyleCallback<Partial<IGroupGraphicAttribute>>>;\n /**\n * 图例项的 shape 图标的配置\n */\n shape?: {\n visible?: boolean;\n /** shape 同后面 label 的间距 */\n space?: number;\n } & BaseGraphicAttributes<Partial<ISymbolGraphicAttribute> | StyleCallback<Partial<ISymbolGraphicAttribute>>>;\n\n /**\n * 当label+ value同时存在的时候,自动省略的策略\n * 'labelFirst' - 尽量保证完整展示`label`\n * 'valueFirst' - 尽量保证完整展示`value`\n * 'none' - 按照`widthRatio`展示label 和 value\n */\n autoEllipsisStrategy?: 'labelFirst' | 'valueFirst' | 'none';\n\n /**\n * 图例项的 label 文本配置\n */\n label?: {\n /**\n * 当 label + value 同时展示,切超长的时候,label的宽度占比\n */\n widthRatio?: number;\n /**\n * 图例项 label 同后面 value 的间距\n */\n space?: number;\n /**\n * 格式化文本函数\n */\n formatMethod?: formatterCallback;\n } & BaseGraphicAttributes<Partial<ITextGraphicAttribute> | StyleCallback<Partial<ITextGraphicAttribute>>>;\n /**\n * 图例项 value 配置\n */\n value?: {\n /**\n * 当 label + value 同时展示,切超长的时候,label的宽度占比\n */\n widthRatio?: number;\n /** value 同后面元素的间距 */\n space?: number;\n /**\n * 是否右对齐显示,仅当设置图例项宽度 itemWidth 时生效\n * 默认为 false,\n */\n alignRight?: boolean;\n /**\n * 格式化文本函数\n */\n formatMethod?: formatterCallback;\n } & BaseGraphicAttributes<Partial<ITextGraphicAttribute> | StyleCallback<Partial<ITextGraphicAttribute>>>;\n /**\n * 是否开启聚焦功能,默认关闭\n */\n focus?: boolean;\n /**\n * 聚焦按钮配置\n */\n focusIconStyle?: Partial<ISymbolGraphicAttribute>;\n /**\n * 指定图例项中图标和文字的摆放位置,可选值为:\n * 'left' 图标在左侧\n * 'right' 图标在右侧\n */\n align?: 'left' | 'right';\n /**\n * @since 0.21.3\n * 水平方向时,一行中多个图例的垂直对齐方式\n */\n verticalAlign?: 'top' | 'middle' | 'bottom';\n};\n\nexport type DiscreteLegendAttrs = {\n /**\n * 是否开启选中交互\n */\n select?:\n | boolean\n | {\n /** @since 0.20.13 */\n trigger?: GraphicEventType;\n };\n\n /**\n * 是否开启 hover 交互\n */\n hover?:\n | boolean\n | {\n /** @since 0.20.13 */\n trigger?: GraphicEventType;\n /** @since 0.20.13 */\n triggerOff?: GraphicEventType;\n };\n /**\n * 图例数据\n */\n items: LegendItemDatum[];\n /**\n * 默认选中的图例项\n */\n defaultSelected?: (string | number)[];\n /**\n * 单选/多选模式配置,默认 'multiple'。\n * - `single` 表示单选\n * - `multiple` 表示多选\n * - `focus` 表示聚焦模式 (自 0.19.2版本开始支持)\n */\n selectMode?: 'single' | 'multiple' | 'focus';\n /**\n * 是否允许图例全部取消,多选模式下生效\n */\n allowAllCanceled?: boolean;\n /**\n * 图例项的顺序是否要逆序,默认为 false\n */\n reversed?: boolean;\n /**\n * 图例项相关的配置\n */\n item?: LegendItem;\n /**\n * 最大宽度,决定 layout : 'horizontal' 是否自动换行\n */\n maxWidth?: number;\n /**\n * 最大高度,决定是否分页\n */\n maxHeight?: number;\n /**\n * 最大行数,当且仅当 layout 为 'horizontal' 时生效\n */\n maxRow?: number;\n /**\n * 最大列数,当且仅当 layout 为 'vertical' 时生效\n */\n maxCol?: number;\n /**\n * 延迟渲染,按需渲染图例项目\n */\n lazyload?: boolean;\n /**\n * 是否进行自动分页,默认为 true\n */\n autoPage?: boolean;\n /**\n * 翻页器配置\n */\n pager?: LegendPagerAttributes | LegendScrollbarAttributes;\n} & LegendBaseAttributes;\n"]}
1
+ {"version":3,"sources":["../src/legend/discrete/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n EasingType,\n IGroupGraphicAttribute,\n ILinearGradient,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { BaseGraphicAttributes, Padding } from '../../core/type';\nimport type { PagerAttributes } from '../../pager/type';\nimport type { LegendBaseAttributes } from '../type';\nimport type { ScrollBarAttributes } from '../../scrollbar/type';\nimport type { GraphicEventType } from '@visactor/vrender-core';\n\nexport interface LegendSwitchComponentAttributes {\n /**\n * 翻页组件同图例内容项之间的间距\n */\n space?: number;\n /**\n * the default page\n */\n defaultCurrent?: number;\n /**\n * 翻页是否开启动画\n */\n animation?: boolean;\n /**\n * 动画执行时间\n */\n animationDuration?: number;\n /**\n * 动画执行效果\n */\n animationEasing?: EasingType;\n}\n\n/**\n * 离散类型的图例组件,当图例项较多的时候,默认使用分页器组件\n */\nexport type LegendPagerAttributes = Omit<PagerAttributes, 'total'> &\n LegendSwitchComponentAttributes & {\n /**\n * 分页器的显示位置,默认 'middle'\n * @default 'middle'\n */\n position?: 'start' | 'middle' | 'end';\n };\n\n/**\n * 离散类型的图例组件使用滚动条组件的时候对应的配置\n */\nexport type LegendScrollbarAttributes = Omit<ScrollBarAttributes, 'range' | 'limitRange'> &\n LegendSwitchComponentAttributes & {\n /**\n * 将翻页器的类型设置为 'scrollbar'\n * 申明图例组件使用滚动条进行翻页展示更多的图例项\n */\n type: 'scrollbar';\n /**\n * @deprecated since 0.20.13\n * 滚动条的位置是否支持展示在分页的中间。\n * 0.20.13 版本改造了滚动条逻辑后,此配置废弃。改造内容:\n * 由分页拟合的滚动调整为滚动窗口的逻辑,不再与分页绑定\n */\n scrollByPosition?: boolean;\n /**\n * 是否支持鼠标/触控板滚动\n * @default false\n */\n roamScroll?: boolean;\n /**\n * @since 0.20.13\n * 是否隐藏滚动条\n */\n visible?: boolean;\n /**\n * @since 0.20.13\n * 滚动时,图例区域未到尽头时的前后遮罩\n */\n scrollMask?: {\n /** 是否显示 @default false */\n visible?: boolean;\n /** 渐变区域长度 @default 16 */\n gradientLength?: number;\n /** 渐变配置 */\n gradientStops: ILinearGradient['stops'];\n };\n };\n\nexport type LegendItemDatum = {\n /**\n * 该条数据的唯一标识,可用于动画或者查找\n */\n id?: string;\n /** 显示文本 */\n label: string;\n /** 显示数据 */\n value?: string | number;\n /** 图例项前的 shape 形状定义 */\n shape: {\n symbolType?: string;\n fill?: string;\n stroke?: string;\n };\n [key: string]: any;\n};\n\nexport type StyleCallback<T> = (\n item: LegendItemDatum,\n isSelected: boolean,\n index: number,\n allItems: LegendItemDatum[]\n) => T;\n\nexport type formatterCallback = (text: string | number, item: LegendItemDatum, index: number) => any;\n\nexport type LegendItem = {\n /**\n * 是否展示图例项\n * @default true\n */\n visible?: boolean;\n /**\n * 图例项的列间距 水平间距\n */\n spaceCol?: number;\n /**\n * 图例项的行间距 垂直间距\n */\n spaceRow?: number;\n /**\n * 图例项的最大宽度,默认为 null,由上层传入\n */\n maxWidth?: number;\n /**\n * 图例项的宽度, 默认自动计算\n */\n width?: number;\n /**\n * 图例的高度,默认自动计算\n */\n height?: number;\n /**\n * 图例项自身的内边距\n */\n padding?: Padding;\n /**\n * 图例项背景配置\n */\n background?: {\n visible?: boolean;\n } & BaseGraphicAttributes<Partial<IGroupGraphicAttribute> | StyleCallback<Partial<IGroupGraphicAttribute>>>;\n /**\n * 图例项的 shape 图标的配置\n */\n shape?: {\n visible?: boolean;\n /** shape 同后面 label 的间距 */\n space?: number;\n } & BaseGraphicAttributes<Partial<ISymbolGraphicAttribute> | StyleCallback<Partial<ISymbolGraphicAttribute>>>;\n\n /**\n * 当label+ value同时存在的时候,自动省略的策略\n * 'labelFirst' - 尽量保证完整展示`label`\n * 'valueFirst' - 尽量保证完整展示`value`\n * 'none' - 按照`widthRatio`展示label 和 value\n */\n autoEllipsisStrategy?: 'labelFirst' | 'valueFirst' | 'none';\n\n /**\n * 图例项的 label 文本配置\n */\n label?: {\n /**\n * 当 label + value 同时展示,切超长的时候,label的宽度占比\n */\n widthRatio?: number;\n /**\n * 图例项 label 同后面 value 的间距\n */\n space?: number;\n /**\n * 格式化文本函数\n */\n formatMethod?: formatterCallback;\n } & BaseGraphicAttributes<Partial<ITextGraphicAttribute> | StyleCallback<Partial<ITextGraphicAttribute>>>;\n /**\n * 图例项 value 配置\n */\n value?: {\n /**\n * 当 label + value 同时展示,切超长的时候,label的宽度占比\n */\n widthRatio?: number;\n /** value 同后面元素的间距 */\n space?: number;\n /**\n * 是否右对齐显示,仅当设置图例项宽度 itemWidth 时生效\n * 默认为 false,\n */\n alignRight?: boolean;\n /**\n * 格式化文本函数\n */\n formatMethod?: formatterCallback;\n } & BaseGraphicAttributes<Partial<ITextGraphicAttribute> | StyleCallback<Partial<ITextGraphicAttribute>>>;\n /**\n * 是否开启聚焦功能,默认关闭\n */\n focus?: boolean;\n /**\n * 聚焦按钮配置\n */\n focusIconStyle?: Partial<ISymbolGraphicAttribute>;\n /**\n * 指定图例项中图标和文字的摆放位置,可选值为:\n * 'left' 图标在左侧\n * 'right' 图标在右侧\n */\n align?: 'left' | 'right';\n /**\n * 水平方向时,一行中多个图例的垂直对齐方式\n * @since 0.21.3\n */\n verticalAlign?: 'top' | 'middle' | 'bottom';\n};\n\nexport type DiscreteLegendAttrs = {\n /**\n * 是否开启选中交互\n */\n select?:\n | boolean\n | {\n /**\n * 触发选中交互的事件类型\n * @since 0.20.13\n **/\n trigger?: GraphicEventType;\n };\n\n /**\n * 是否开启 hover 交互\n */\n hover?:\n | boolean\n | {\n /**\n * 触发hover交互的事件类型\n * @since 0.20.13\n **/\n trigger?: GraphicEventType;\n /**\n * 触发取消hover交互的事件类型\n * @since 0.20.13\n **/\n triggerOff?: GraphicEventType;\n };\n /**\n * 图例数据\n */\n items: LegendItemDatum[];\n /**\n * 默认选中的图例项\n */\n defaultSelected?: (string | number)[];\n /**\n * 单选/多选模式配置,默认 'multiple'。\n * - `single` 表示单选\n * - `multiple` 表示多选\n * - `focus` 表示聚焦模式 (自 0.19.2版本开始支持)\n */\n selectMode?: 'single' | 'multiple' | 'focus';\n /**\n * 是否允许图例全部取消,多选模式下生效\n */\n allowAllCanceled?: boolean;\n /**\n * 图例项的顺序是否要逆序,默认为 false\n */\n reversed?: boolean;\n /**\n * 图例项相关的配置\n */\n item?: LegendItem;\n /**\n * 最大宽度,决定 layout : 'horizontal' 是否自动换行\n */\n maxWidth?: number;\n /**\n * 最大高度,决定是否分页\n */\n maxHeight?: number;\n /**\n * 最大行数,当且仅当 layout 为 'horizontal' 时生效\n */\n maxRow?: number;\n /**\n * 最大列数,当且仅当 layout 为 'vertical' 时生效\n */\n maxCol?: number;\n /**\n * 延迟渲染,按需渲染图例项目\n */\n lazyload?: boolean;\n /**\n * 是否进行自动分页,默认为 true\n */\n autoPage?: boolean;\n /**\n * 翻页器配置\n */\n pager?: LegendPagerAttributes | LegendScrollbarAttributes;\n} & LegendBaseAttributes;\n"]}
@@ -28,23 +28,14 @@ class MarkArea extends base_1.Marker {
28
28
  this.defaultExitAnimation = animate_1.DefaultExitMarkerAnimation;
29
29
  }
30
30
  getPointAttrByPosition(position) {
31
- const {x1: x1, x2: x2, y1: y1, y2: y2} = this._area.AABBBounds;
32
- return position.includes("left") || position.includes("Left") ? {
33
- x: x1,
34
- y: (y1 + y2) / 2
35
- } : position.includes("right") || position.includes("Right") ? {
36
- x: x2,
37
- y: (y1 + y2) / 2
38
- } : position.includes("top") || position.includes("Top") ? {
39
- x: (x1 + x2) / 2,
40
- y: y1
41
- } : position.includes("bottom") || position.includes("Bottom") ? {
42
- x: (x1 + x2) / 2,
43
- y: y2
44
- } : {
31
+ const {x1: x1, x2: x2, y1: y1, y2: y2} = this._area.AABBBounds, result = {
45
32
  x: (x1 + x2) / 2,
46
33
  y: (y1 + y2) / 2
47
34
  };
35
+ return (position.includes("left") || position.includes("Left")) && (result.x = x1),
36
+ (position.includes("right") || position.includes("Right")) && (result.x = x2), (position.includes("top") || position.includes("Top")) && (result.y = y1),
37
+ (position.includes("bottom") || position.includes("Bottom")) && (result.y = y2),
38
+ result;
48
39
  }
49
40
  setLabelPos() {
50
41
  var _a;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marker/area.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AACxD,6CAAwD;AAGxD,gCAA6B;AAC7B,iCAAgC;AAChC,qCAA+F;AAE/F,qDAAyD;AAEzD,yCAAmD;AAEnD,0CAA6C;AAC7C,+CAAgH;AAEhH,IAAA,gCAAqB,GAAE,CAAC;AAExB,SAAgB,uBAAuB;IACrC,QAAQ,CAAC,QAAQ,GAAG,yBAAe,CAAC;AACtC,CAAC;AAFD,0DAEC;AAED,MAAa,QAAS,SAAQ,aAAkD;IAOpE,aAAa,CAAC,KAA2B;QACjD,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC9C,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,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I,CAAC,KAAK,CAAC,MAAM,GAAG,IAAA,cAAK,EAAC,EAAE,EAAE,yBAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAC,CAAC;SAC5D;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,aAAa,+BACvB,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,CAAC,IACD,KAAuB,KAC3B,KAAK,EAAE;oBACL,KAAK,EAAE,IAAA,cAAK,EAAC,EAAE,EAAE,yBAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAC;oBACxD,IAAI,EAAE,IAAA,cAAK,EAAC,EAAE,EAAE,yBAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;iBAC9C,IACD,CAAC;SACJ;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAES,aAAa;QACrB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,SAA0B,CAAC;QACnD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;QACD,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAY,EAAE,EAAE;YAC9B,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBAC5E,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AAjJH,4BAkJC;AAhJQ,0BAAiB,GAAG,gCAAuB,CAAC","file":"area.js","sourcesContent":["import type { IGroup, INode, IPolygon } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { isValidNumber, merge } from '@visactor/vutils';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_CARTESIAN_MARK_AREA_TEXT_STYLE_MAP, DEFAULT_MARK_AREA_THEME } from './config';\nimport type { CommonMarkAreaAnimationType, IMarkAreaLabelPosition, MarkAreaAttrs, MarkerAnimationState } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkAreaComponent } from './register';\nimport type { Point } from '../core/type';\nimport { DEFAULT_STATES } from '../constant';\nimport { DefaultExitMarkerAnimation, DefaultUpdateMarkAreaAnimation, markAreaAnimate } from './animate/animate';\n\nloadMarkAreaComponent();\n\nexport function registerMarkAreaAnimate() {\n MarkArea._animate = markAreaAnimate;\n}\n\nexport class MarkArea extends Marker<MarkAreaAttrs, CommonMarkAreaAnimationType> {\n name = 'markArea';\n static defaultAttributes = DEFAULT_MARK_AREA_THEME;\n\n /** animate */\n defaultUpdateAnimation = DefaultUpdateMarkAreaAnimation;\n defaultExitAnimation = DefaultExitMarkerAnimation;\n protected markerAnimate(state: MarkerAnimationState) {\n if (MarkArea._animate && this._animationConfig) {\n MarkArea._animate(this._area, this._label, this._animationConfig, state);\n }\n }\n\n private _area!: IPolygon;\n getArea() {\n return this._area;\n }\n\n getLabel() {\n return this._label;\n }\n\n constructor(attributes: MarkAreaAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkArea.defaultAttributes, attributes));\n }\n\n protected getPointAttrByPosition(position: IMarkAreaLabelPosition) {\n const { x1, x2, y1, y2 } = this._area.AABBBounds;\n\n if (position.includes('left') || position.includes('Left')) {\n return {\n x: x1,\n y: (y1 + y2) / 2\n };\n }\n if (position.includes('right') || position.includes('Right')) {\n return {\n x: x2,\n y: (y1 + y2) / 2\n };\n }\n if (position.includes('top') || position.includes('Top')) {\n return {\n x: (x1 + x2) / 2,\n y: y1\n };\n }\n if (position.includes('bottom') || position.includes('Bottom')) {\n return {\n x: (x1 + x2) / 2,\n y: y2\n };\n }\n\n return {\n x: (x1 + x2) / 2,\n y: (y1 + y2) / 2\n };\n }\n\n protected setLabelPos() {\n if (this._label && this._area) {\n const { label = {} } = this.attribute as MarkAreaAttrs;\n const labelPosition = label.position ?? 'middle';\n const labelPoint = this.getPointAttrByPosition(labelPosition as IMarkAreaLabelPosition);\n this._label.setAttributes({\n ...labelPoint,\n textStyle: {\n ...DEFAULT_CARTESIAN_MARK_AREA_TEXT_STYLE_MAP[labelPosition],\n ...label.textStyle\n }\n });\n\n if (this.attribute.limitRect && label.confine) {\n const { x, y, width, height } = this.attribute.limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n }\n\n protected initMarker(container: IGroup) {\n const { points, label, areaStyle, state } = this.attribute as MarkAreaAttrs;\n const area = graphicCreator.polygon({\n points: points,\n ...areaStyle\n });\n area.states = merge({}, DEFAULT_STATES, state?.area);\n area.name = 'mark-area-polygon';\n this._area = area;\n container.add(area);\n\n const markLabel = new Tag({\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\n });\n markLabel.name = 'mark-area-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { points, label, areaStyle, state } = this.attribute as MarkAreaAttrs;\n if (this._area) {\n this._area.setAttributes({\n points: points,\n ...areaStyle\n });\n this._area.states = merge({}, DEFAULT_STATES, state?.area);\n }\n if (this._label) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\n });\n }\n this.setLabelPos();\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkAreaAttrs;\n if (!points || points.length < 3) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point) => {\n if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/marker/area.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AACxD,6CAAwD;AAGxD,gCAA6B;AAC7B,iCAAgC;AAChC,qCAA+F;AAE/F,qDAAyD;AAEzD,yCAAmD;AAEnD,0CAA6C;AAC7C,+CAAgH;AAEhH,IAAA,gCAAqB,GAAE,CAAC;AAExB,SAAgB,uBAAuB;IACrC,QAAQ,CAAC,QAAQ,GAAG,yBAAe,CAAC;AACtC,CAAC;AAFD,0DAEC;AAED,MAAa,QAAS,SAAQ,aAAkD;IAOpE,aAAa,CAAC,KAA2B;QACjD,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC9C,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;SAC1E;IACH,CAAC;IAGD,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,YAAY,UAAyB,EAAE,OAA0B;QAC/D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAtB/F,SAAI,GAAG,UAAU,CAAC;QAIlB,2BAAsB,GAAG,wCAA8B,CAAC;QACxD,yBAAoB,GAAG,oCAA0B,CAAC;IAkBlD,CAAC;IAES,sBAAsB,CAAC,QAAgC;QAC/D,MA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B,MAAM,CAAC,OAAO,CAAC,CAAC,KAAY,EAAE,EAAE;YAC9B,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBAC5E,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AAtIH,4BAuIC;AArIQ,0BAAiB,GAAG,gCAAuB,CAAC","file":"area.js","sourcesContent":["import type { IGroup, INode, IPolygon } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { isValidNumber, merge } from '@visactor/vutils';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_CARTESIAN_MARK_AREA_TEXT_STYLE_MAP, DEFAULT_MARK_AREA_THEME } from './config';\nimport type { CommonMarkAreaAnimationType, IMarkAreaLabelPosition, MarkAreaAttrs, MarkerAnimationState } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkAreaComponent } from './register';\nimport type { Point } from '../core/type';\nimport { DEFAULT_STATES } from '../constant';\nimport { DefaultExitMarkerAnimation, DefaultUpdateMarkAreaAnimation, markAreaAnimate } from './animate/animate';\n\nloadMarkAreaComponent();\n\nexport function registerMarkAreaAnimate() {\n MarkArea._animate = markAreaAnimate;\n}\n\nexport class MarkArea extends Marker<MarkAreaAttrs, CommonMarkAreaAnimationType> {\n name = 'markArea';\n static defaultAttributes = DEFAULT_MARK_AREA_THEME;\n\n /** animate */\n defaultUpdateAnimation = DefaultUpdateMarkAreaAnimation;\n defaultExitAnimation = DefaultExitMarkerAnimation;\n protected markerAnimate(state: MarkerAnimationState) {\n if (MarkArea._animate && this._animationConfig) {\n MarkArea._animate(this._area, this._label, this._animationConfig, state);\n }\n }\n\n private _area!: IPolygon;\n getArea() {\n return this._area;\n }\n\n getLabel() {\n return this._label;\n }\n\n constructor(attributes: MarkAreaAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkArea.defaultAttributes, attributes));\n }\n\n protected getPointAttrByPosition(position: IMarkAreaLabelPosition) {\n const { x1, x2, y1, y2 } = this._area.AABBBounds;\n const result = {\n x: (x1 + x2) / 2,\n y: (y1 + y2) / 2\n };\n\n if (position.includes('left') || position.includes('Left')) {\n result.x = x1;\n }\n if (position.includes('right') || position.includes('Right')) {\n result.x = x2;\n }\n if (position.includes('top') || position.includes('Top')) {\n result.y = y1;\n }\n if (position.includes('bottom') || position.includes('Bottom')) {\n result.y = y2;\n }\n\n return result;\n }\n\n protected setLabelPos() {\n if (this._label && this._area) {\n const { label = {} } = this.attribute as MarkAreaAttrs;\n const labelPosition = label.position ?? 'middle';\n const labelPoint = this.getPointAttrByPosition(labelPosition as IMarkAreaLabelPosition);\n this._label.setAttributes({\n ...labelPoint,\n textStyle: {\n ...DEFAULT_CARTESIAN_MARK_AREA_TEXT_STYLE_MAP[labelPosition],\n ...label.textStyle\n }\n });\n\n if (this.attribute.limitRect && label.confine) {\n const { x, y, width, height } = this.attribute.limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n }\n\n protected initMarker(container: IGroup) {\n const { points, label, areaStyle, state } = this.attribute as MarkAreaAttrs;\n const area = graphicCreator.polygon({\n points: points,\n ...areaStyle\n });\n area.states = merge({}, DEFAULT_STATES, state?.area);\n area.name = 'mark-area-polygon';\n this._area = area;\n container.add(area);\n\n const markLabel = new Tag({\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\n });\n markLabel.name = 'mark-area-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { points, label, areaStyle, state } = this.attribute as MarkAreaAttrs;\n if (this._area) {\n this._area.setAttributes({\n points: points,\n ...areaStyle\n });\n this._area.states = merge({}, DEFAULT_STATES, state?.area);\n }\n if (this._label) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\n });\n }\n this.setLabelPos();\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkAreaAttrs;\n if (!points || points.length < 3) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point) => {\n if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":";;;AAmBA,IAAY,sBAkBX;AAlBD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,+CAAqB,CAAA;IACrB,qDAA2B,CAAA;IAC3B,qDAA2B,CAAA;IAC3B,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IAEvC,2CAAiB,CAAA;IACjB,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IAEzC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAlBW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAkBjC;AAED,IAAY,sBAoBX;AApBD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,6CAAmB,CAAA;IACnB,+CAAqB,CAAA;IACrB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAE3B,2CAAiB,CAAA;IAEjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,yDAA+B,CAAA;IAC/B,2DAAiC,CAAA;IACjC,+DAAqC,CAAA;IACrC,iEAAuC,CAAA;AACzC,CAAC,EApBW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAoBjC;AAED,IAAY,2BAQX;AARD,WAAY,2BAA2B;IACrC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,gDAAiB,CAAA;AACnB,CAAC,EARW,2BAA2B,GAA3B,mCAA2B,KAA3B,mCAA2B,QAQtC;AAED,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAOjC","file":"type.js","sourcesContent":["import type {\n EasingType,\n IArcGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n ILineGraphicAttribute,\n IPolygonAttribute,\n IPolygonGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextGraphicAttribute,\n ISymbol,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { CommonSegmentAttributes, ILineGraphicWithCornerRadius, SegmentAttributes } from '../segment/type';\nimport type { TagAttributes } from '../tag/type';\nimport type { Point, State } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n startTop = 'startTop',\n startBottom = 'startBottom',\n insideStart = 'insideStart',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n\n middle = 'middle',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n\n end = 'end',\n endTop = 'endTop',\n endBottom = 'endBottom',\n insideEnd = 'insideEnd',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n topLeft = 'topLeft',\n topRight = 'topRight',\n bottomLeft = 'bottomLeft',\n bottomRight = 'bottomRight',\n\n middle = 'middle',\n\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideTopLeft = 'insideTopLeft',\n insideTopRight = 'insideTopRight',\n insideBottomLeft = 'insideBottomLeft',\n insideBottomRight = 'insideBottomRight'\n}\n\nexport enum IMarkCommonArcLabelPosition {\n arcInnerStart = 'arcInnerStart',\n arcInnerEnd = 'arcInnerEnd',\n arcInnerMiddle = 'arcInnerMiddle',\n arcOuterStart = 'arcOuterStart',\n arcOuterEnd = 'arcOuterEnd',\n arcOuterMiddle = 'arcOuterMiddle',\n center = 'center'\n}\n\nexport enum IMarkPointItemPosition {\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideMiddle = 'insideMiddle'\n}\n\nexport type IMarkBackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * TODO: 根据文字宽度进行背景 panel size自适应\n */\n autoHeight?: boolean;\n /**\n * TODO: 根据文高度度进行背景 panel size自适应\n */\n autoWidth?: boolean;\n} & Partial<IRectGraphicAttribute>;\n\nexport type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n};\n\nexport type IMarkRef = {\n /**\n * 自动旋转,沿着线的方向\n * @default\n * mark-line/mark-area/mark-point: false - 旧逻辑里autoRotate是false, 保持不变\n * mark-arc-line/mark-arc-area: true - 新增逻辑, 如果不开启的话, 效果不太好, 所以默认true\n * mark-point - 旧逻辑里autoRotate是true, 保持不变\n */\n autoRotate?: boolean;\n /**\n * label 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n};\n\nexport type MarkerAttrs<AnimationType> = IGroupGraphicAttribute & {\n type?: 'line' | 'arc-line' | 'area' | 'arc-area' | 'point';\n /**\n * 是否支持交互\n * @default true\n */\n interactive?: boolean;\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 是否显示marker组件\n * @default true\n */\n visible?: boolean;\n /**\n * 是否将组件在绘制区域内进行剪切\n * @default true\n */\n clipInRange?: boolean;\n /**\n * 组件绘制范围配置\n */\n limitRect?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n} & BaseMarkerAnimation<AnimationType>;\n\n/** animation type */\nexport type BaseMarkerAnimation<T> = {\n animation?: MarkerAnimation<T> | boolean;\n animationEnter?: MarkerUpdateAnimation<T>;\n animationUpdate?: MarkerUpdateAnimation<T>;\n animationExit?: MarkerExitAnimation;\n};\nexport type MarkerAnimation<T> = MarkerUpdateAnimation<T> | MarkerUpdateAnimation<T>;\n\nexport type MarkerUpdateAnimation<T> = {\n type: T;\n} & MarkerExitAnimation;\n\nexport type MarkCommonLineAnimationType = 'clipIn' | 'fadeIn';\n\nexport type CommonMarkAreaAnimationType = 'fadeIn';\n\nexport type MarkPointAnimationType = 'callIn' | 'fadeIn';\n\nexport type MarkerExitAnimation = {\n type: 'fadeOut';\n duration?: number;\n delay?: number;\n easing?: EasingType;\n};\n\nexport type MarkerAnimationState = 'enter' | 'update' | 'exit';\n\n/** state type */\nexport type MarkCommonLineState<LineAttr> = {\n line?: State<LineAttr>;\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n label?: State<Partial<ITextGraphicAttribute>>;\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type CommonMarkAreaState<AreaAttr> = {\n area?: State<Partial<AreaAttr>>;\n label?: State<Partial<ITextGraphicAttribute>>;\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type MarkPointState = {\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n image?: State<Partial<IImageGraphicAttribute>>;\n text?: State<Partial<ITextGraphicAttribute>>;\n textBackground?: State<Partial<IRectGraphicAttribute>>;\n richText?: State<Partial<IRichTextGraphicAttribute>>;\n customMark?: State<Partial<IGroupGraphicAttribute>>;\n targetItem?: State<Partial<ISymbolGraphicAttribute>>;\n};\n\nexport type MarkCommonLineAttrs<LineAttr, LineLabelPosition, MarkCommonLineAnimationType> =\n MarkerAttrs<MarkCommonLineAnimationType> &\n Omit<CommonSegmentAttributes, 'state' | 'lineStyle'> & {\n /**\n * 标签\n */\n label?: {\n /**\n * label 相对line的位置\n */\n position?: LineLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n state?: MarkCommonLineState<LineAttr>;\n };\n\nexport type MarkLineAttrs = MarkCommonLineAttrs<\n ILineGraphicWithCornerRadius | ILineGraphicAttribute[],\n keyof typeof IMarkLineLabelPosition,\n MarkCommonLineAnimationType\n> & {\n type?: 'line';\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为曲线\n */\n points: Point[] | Point[][];\n lineStyle?: ILineGraphicAttribute;\n};\n\nexport type MarkArcLineAttrs = MarkCommonLineAttrs<\n IArcGraphicAttribute,\n keyof typeof IMarkCommonArcLabelPosition,\n MarkCommonLineAnimationType\n> & {\n type?: 'arc-line';\n /**\n * 弧线中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 弧线半径\n */\n radius: number;\n /**\n * 弧线起始角度(弧度)\n */\n startAngle: number;\n /**\n * 弧线终点角度(弧度)\n */\n endAngle: number;\n lineStyle?: IArcGraphicAttribute;\n};\n\nexport type MarkAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: Point[];\n /**\n * 标签\n */\n label?: {\n position?: keyof typeof IMarkAreaLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\n\n state?: CommonMarkAreaState<IPolygonGraphicAttribute>;\n};\n\nexport type MarkArcAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'arc-area';\n /**\n * 扇区中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 扇区内半径\n */\n innerRadius: number;\n /**\n * 扇区外半径\n */\n outerRadius: number;\n /**\n * 扇区起始角度(弧度)\n */\n startAngle: number;\n /**\n * 扇区终点角度(弧度)\n */\n endAngle: number;\n /**\n * 标签\n */\n label?: {\n position?: keyof typeof IMarkCommonArcLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IArcGraphicAttribute;\n\n state?: CommonMarkAreaState<IArcGraphicAttribute>;\n};\n\nexport type IItemContent = IMarkRef & {\n /**\n * 标注类型\n * Tips: 保留'richText'与之前的定义做兼容\n */\n type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';\n position?: keyof typeof IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbolStyle?: ISymbolGraphicAttribute;\n /**\n * type为image时, image的样式\n */\n imageStyle?: IImageGraphicAttribute;\n /**\n * type为text时, text的配置\n * 'text'类型的ItemContent新增三种子类型:'text','rich','html'。配置在textStyle.type上,继承自TagAttributes。\n */\n textStyle?: IMarkLabel;\n /**\n * type为rich text时, rich text的样式\n */\n richTextStyle?: IRichTextGraphicAttribute;\n /**\n * type为custom时,允许以callback的方式传入需要render的item\n */\n renderCustomCallback?: () => IGroup;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n};\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op' | 'type-arc';\n visible?: boolean;\n /**\n * 当type为type-arc时生效, 数值决定曲率, 符号决定法向, 不能等于0\n * @default 0.8\n */\n arcRatio?: number;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n visible?: boolean;\n length?: number;\n };\n} & Omit<SegmentAttributes, 'points'>;\n\nexport type MarkPointAttrs = Omit<MarkerAttrs<MarkPointAnimationType>, 'labelStyle'> & {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: Point;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n\n /**\n * 被标注的内容\n */\n targetSymbol?: {\n /**\n * 被标注内容与标记线间的间隙\n * @default 0\n */\n offset?: number;\n /**\n * 是否显示\n * @default false\n */\n visible?: boolean;\n /**\n * 大小\n * @default 20\n */\n size?: number;\n style?: ISymbol;\n };\n\n state?: MarkPointState;\n} & BaseMarkerAnimation<MarkPointAnimationType>;\n"]}
1
+ {"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":";;;AAmBA,IAAY,sBAkBX;AAlBD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,+CAAqB,CAAA;IACrB,qDAA2B,CAAA;IAC3B,qDAA2B,CAAA;IAC3B,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IAEvC,2CAAiB,CAAA;IACjB,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IAEzC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAlBW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAkBjC;AAED,IAAY,sBAoBX;AApBD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,6CAAmB,CAAA;IACnB,+CAAqB,CAAA;IACrB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAE3B,2CAAiB,CAAA;IAEjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,yDAA+B,CAAA;IAC/B,2DAAiC,CAAA;IACjC,+DAAqC,CAAA;IACrC,iEAAuC,CAAA;AACzC,CAAC,EApBW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAoBjC;AAED,IAAY,2BAQX;AARD,WAAY,2BAA2B;IACrC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,gDAAiB,CAAA;AACnB,CAAC,EARW,2BAA2B,GAA3B,mCAA2B,KAA3B,mCAA2B,QAQtC;AAED,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAOjC","file":"type.js","sourcesContent":["import type {\n EasingType,\n IArcGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n ILineGraphicAttribute,\n IPolygonAttribute,\n IPolygonGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextGraphicAttribute,\n ISymbol,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { CommonSegmentAttributes, ILineGraphicWithCornerRadius, SegmentAttributes } from '../segment/type';\nimport type { TagAttributes } from '../tag/type';\nimport type { Point, State } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n startTop = 'startTop',\n startBottom = 'startBottom',\n insideStart = 'insideStart',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n\n middle = 'middle',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n\n end = 'end',\n endTop = 'endTop',\n endBottom = 'endBottom',\n insideEnd = 'insideEnd',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n topLeft = 'topLeft',\n topRight = 'topRight',\n bottomLeft = 'bottomLeft',\n bottomRight = 'bottomRight',\n\n middle = 'middle',\n\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideTopLeft = 'insideTopLeft',\n insideTopRight = 'insideTopRight',\n insideBottomLeft = 'insideBottomLeft',\n insideBottomRight = 'insideBottomRight'\n}\n\nexport enum IMarkCommonArcLabelPosition {\n arcInnerStart = 'arcInnerStart',\n arcInnerEnd = 'arcInnerEnd',\n arcInnerMiddle = 'arcInnerMiddle',\n arcOuterStart = 'arcOuterStart',\n arcOuterEnd = 'arcOuterEnd',\n arcOuterMiddle = 'arcOuterMiddle',\n center = 'center'\n}\n\nexport enum IMarkPointItemPosition {\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideMiddle = 'insideMiddle'\n}\n\nexport type IMarkBackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * TODO: 根据文字宽度进行背景 panel size自适应\n */\n autoHeight?: boolean;\n /**\n * TODO: 根据文高度度进行背景 panel size自适应\n */\n autoWidth?: boolean;\n} & Partial<IRectGraphicAttribute>;\n\nexport type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n};\n\nexport type IMarkRef = {\n /**\n * 自动旋转,沿着线的方向\n * @default\n * mark-line/mark-area/mark-point: false - 旧逻辑里autoRotate是false, 保持不变\n * mark-arc-line/mark-arc-area: true - 新增逻辑, 如果不开启的话, 效果不太好, 所以默认true\n * mark-point - 旧逻辑里autoRotate是true, 保持不变\n */\n autoRotate?: boolean;\n /**\n * label 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n};\n\nexport type MarkerAttrs<AnimationType> = IGroupGraphicAttribute & {\n /**\n * 设置标注的类型\n */\n type?: 'line' | 'arc-line' | 'area' | 'arc-area' | 'point';\n /**\n * 是否支持交互\n * @default true\n */\n interactive?: boolean;\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 是否显示marker组件\n * @default true\n */\n visible?: boolean;\n /**\n * 是否将组件在绘制区域内进行剪切\n * @default true\n */\n clipInRange?: boolean;\n /**\n * 组件绘制范围配置\n */\n limitRect?: {\n /**\n * 绘制范围的起点x坐标\n */\n x: number;\n /**\n * 绘制范围的起点y坐标\n */\n y: number;\n /**\n * 绘制范围的宽度\n */\n width: number;\n /**\n * 绘制范围的高度\n */\n height: number;\n };\n} & BaseMarkerAnimation<AnimationType>;\n\n/** animation type */\nexport type BaseMarkerAnimation<T> = {\n /**\n * 动画公共配置\n */\n animation?: MarkerAnimation<T> | boolean;\n /**\n * 入场动画配置\n */\n animationEnter?: MarkerUpdateAnimation<T>;\n /**\n * 更新动画配置\n */\n animationUpdate?: MarkerUpdateAnimation<T>;\n /**\n * 离场动画配置\n */\n animationExit?: MarkerExitAnimation;\n};\nexport type MarkerAnimation<T> = MarkerUpdateAnimation<T> | MarkerUpdateAnimation<T>;\n\nexport type MarkerUpdateAnimation<T> = {\n /**\n * 设置动画的类型\n */\n type: T;\n} & MarkerExitAnimation;\n\nexport type MarkCommonLineAnimationType = 'clipIn' | 'fadeIn';\n\nexport type CommonMarkAreaAnimationType = 'fadeIn';\n\nexport type MarkPointAnimationType = 'callIn' | 'fadeIn';\n\nexport type MarkerExitAnimation = {\n /**\n * 设置离场动画的类型为fadeOut,即淡出\n */\n type: 'fadeOut';\n /**\n * 动画的时长\n */\n duration?: number;\n /**\n * 动画延迟的时长\n */\n delay?: number;\n /**\n * 动画的缓动函数\n */\n easing?: EasingType;\n};\n\nexport type MarkerAnimationState = 'enter' | 'update' | 'exit';\n\n/** state type */\nexport type MarkCommonLineState<LineAttr> = {\n /**\n * 设置线图形的在特定状态下的样式\n */\n line?: State<LineAttr>;\n /**\n * 设置线的起点在特定状态下的样式\n */\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置线的终点在特定状态下的样式\n */\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置标签在特定状态下的样式\n */\n label?: State<Partial<ITextGraphicAttribute>>;\n /**\n * 设置标签背景区块在特定状态下的样式\n */\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type CommonMarkAreaState<AreaAttr> = {\n /**\n * 设置标注区域在特定状态下的样式\n */\n area?: State<Partial<AreaAttr>>;\n /**\n * 设置标注区域标签在特定状态下的样式\n */\n label?: State<Partial<ITextGraphicAttribute>>;\n /**\n * 设置标签背景区块在特定状态下的样式\n */\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type MarkPointState = {\n /**\n * 设置标注点连线在特定状态下的样式\n */\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n /**\n * 设置线起点图形在特定状态下的样式\n */\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置线终点图形在特定状态下的样式\n */\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置标注图形在特定状态下的样式\n */\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置标注图形在特定状态下的样式\n */\n image?: State<Partial<IImageGraphicAttribute>>;\n /**\n * 设置标签在特定状态下的样式\n */\n text?: State<Partial<ITextGraphicAttribute>>;\n /**\n * 设置标签背景区块在特定状态下的样式\n */\n textBackground?: State<Partial<IRectGraphicAttribute>>;\n /**\n * 设置富文本在特定状态下的样式\n */\n richText?: State<Partial<IRichTextGraphicAttribute>>;\n /**\n * 设置自定义标注图形在特定状态下的样式\n */\n customMark?: State<Partial<IGroupGraphicAttribute>>;\n /**\n * 设置目标元素在特定状态下的样式\n */\n targetItem?: State<Partial<ISymbolGraphicAttribute>>;\n};\n\nexport type MarkCommonLineAttrs<LineAttr, LineLabelPosition, MarkCommonLineAnimationType> =\n MarkerAttrs<MarkCommonLineAnimationType> &\n Omit<CommonSegmentAttributes, 'state' | 'lineStyle'> & {\n /**\n * 标签\n */\n label?: {\n /**\n * label 相对line的位置\n */\n position?: LineLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n /**\n * 辅助线各种状态下的样式\n */\n state?: MarkCommonLineState<LineAttr>;\n };\n\nexport type MarkLineAttrs = MarkCommonLineAttrs<\n ILineGraphicWithCornerRadius | ILineGraphicAttribute[],\n keyof typeof IMarkLineLabelPosition,\n MarkCommonLineAnimationType\n> & {\n /**\n * 将辅助线的类型设置为 'line'\n */\n type?: 'line';\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为折线\n */\n points: Point[] | Point[][];\n /**\n * 线的样式设置\n */\n lineStyle?: ILineGraphicAttribute;\n};\n\nexport type MarkArcLineAttrs = MarkCommonLineAttrs<\n IArcGraphicAttribute,\n keyof typeof IMarkCommonArcLabelPosition,\n MarkCommonLineAnimationType\n> & {\n /**\n * 将辅助线的类型设置为 'arc-line',即弧线\n */\n type?: 'arc-line';\n /**\n * 弧线中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 弧线半径\n */\n radius: number;\n /**\n * 弧线起始角度(弧度)\n */\n startAngle: number;\n /**\n * 弧线终点角度(弧度)\n */\n endAngle: number;\n /**\n * 设置弧线的样式\n */\n lineStyle?: IArcGraphicAttribute;\n};\n\nexport type MarkAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: Point[];\n /**\n * 标签\n */\n label?: {\n /**\n * 设置标签的位置\n */\n position?: keyof typeof IMarkAreaLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\n /**\n * 设置标注区域在各种状态下的样式\n */\n state?: CommonMarkAreaState<IPolygonGraphicAttribute>;\n};\n\nexport type MarkArcAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'arc-area';\n /**\n * 扇区中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 扇区内半径\n */\n innerRadius: number;\n /**\n * 扇区外半径\n */\n outerRadius: number;\n /**\n * 扇区起始角度(弧度)\n */\n startAngle: number;\n /**\n * 扇区终点角度(弧度)\n */\n endAngle: number;\n /**\n * 标签\n */\n label?: {\n /**\n * 标签的位置\n */\n position?: keyof typeof IMarkCommonArcLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IArcGraphicAttribute;\n /**\n * 辅助区域这种状态下各个图元的样式设置\n */\n state?: CommonMarkAreaState<IArcGraphicAttribute>;\n};\n\nexport type IItemContent = IMarkRef & {\n /**\n * 标注类型\n * Tips: 保留'richText'与之前的定义做兼容\n */\n type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';\n /**\n * 设置标注的位置\n */\n position?: keyof typeof IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbolStyle?: ISymbolGraphicAttribute;\n /**\n * type为image时, image的样式\n */\n imageStyle?: IImageGraphicAttribute;\n /**\n * type为text时, text的配置\n * 'text'类型的ItemContent新增三种子类型:'text','rich','html'。配置在textStyle.type上,继承自TagAttributes。\n */\n textStyle?: IMarkLabel;\n /**\n * type为rich text时, rich text的样式\n */\n richTextStyle?: IRichTextGraphicAttribute;\n /**\n * type为custom时,允许以callback的方式传入需要render的item\n */\n renderCustomCallback?: () => IGroup;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n};\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op' | 'type-arc';\n /**\n * 是否展示该标注\n */\n visible?: boolean;\n /**\n * 当type为type-arc时生效, 数值决定曲率, 符号决定法向, 不能等于0\n * @default 0.8\n */\n arcRatio?: number;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n /**\n * 是否显示引导线的装饰线\n */\n visible?: boolean;\n /**\n * 装饰线的长度\n */\n length?: number;\n };\n} & Omit<SegmentAttributes, 'points'>;\n\nexport type MarkPointAttrs = Omit<MarkerAttrs<MarkPointAnimationType>, 'labelStyle'> & {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: Point;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n\n /**\n * 被标注的内容\n */\n targetSymbol?: {\n /**\n * 被标注内容与标记线间的间隙\n * @default 0\n */\n offset?: number;\n /**\n * 是否显示\n * @default false\n */\n visible?: boolean;\n /**\n * 大小\n * @default 20\n */\n size?: number;\n /**\n * 被标注内容的样式设置\n */\n style?: ISymbol;\n };\n /**\n * 标注点各个状态下的样式\n */\n state?: MarkPointState;\n} & BaseMarkerAnimation<MarkPointAnimationType>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/poptip/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphic,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { Padding, State } from '../core/type';\nimport type { BackgroundAttributes } from '../interface';\n\ntype StateStyle = {\n /**\n * title 文本的状态配置\n */\n title?: State<Partial<ITextGraphicAttribute>>;\n /**\n * content 文本的状态配置\n */\n content?: State<Partial<ITextGraphicAttribute>>;\n /**\n * panel 背景的状态配置ß\n */\n panel?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type PopTipAttributes = {\n /** 位置,参考arco design */\n position?: 'auto' | 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb';\n /**\n * 标题内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n */\n title?: string | string[] | number | number[];\n /** 标题样式 */\n titleStyle?: Partial<ITextGraphicAttribute>;\n titleFormatMethod?: (t: string | string[] | number | number[]) => string | string[] | number | number[];\n /**\n * 内容文本,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n */\n content?: string | string[] | number | number[];\n /** 内容文本样式 */\n contentStyle?: Partial<ITextGraphicAttribute>;\n contentFormatMethod?: (t: string | string[] | number | number[]) => string | string[] | number | number[];\n /**\n * 标题与内容的间距\n */\n space?: number;\n /**\n * 内部边距\n */\n padding?: Padding;\n /**\n * 标签的背景面板配置, TODO: 支持symbol形状\n * space: 与位置之间的距离\n * square: 是否是正方形\n */\n panel?: BackgroundAttributes &\n ISymbolGraphicAttribute & { space?: number; square?: boolean; panelSymbolType?: string };\n\n // 标签三角的模式,默认是default,即默认的三角形状,concise是紧凑型三角形状显得更简洁\n // @since 0.22.0\n triangleMode?: 'default' | 'concise';\n\n // 放置在poptip前方的logo区域\n logoSymbol?: ISymbolGraphicAttribute;\n // logo内的text\n logoText?: string | string[] | number | number[];\n // logo内的text样式\n logoTextStyle?: Partial<ITextGraphicAttribute>;\n\n /**\n * 最小宽度,像素值\n * @default 30\n */\n minWidth?: number;\n /**\n * 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n\n // 最大宽度比例\n maxWidthPercent?: number;\n\n visible?: boolean;\n visibleFunc?: (graphic: IGraphic) => boolean;\n state?: StateStyle;\n dx?: number;\n dy?: number;\n} & Omit<IGroupGraphicAttribute, 'background'>;\n\nexport type PoptipShapeAttributes = {\n /**\n * 是否展示 shape\n */\n visible: boolean;\n} & Partial<ISymbolGraphicAttribute>;\n"]}
1
+ {"version":3,"sources":["../src/poptip/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphic,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { Padding, State } from '../core/type';\nimport type { BackgroundAttributes } from '../interface';\n\ntype StateStyle = {\n /**\n * title 文本的状态配置\n */\n title?: State<Partial<ITextGraphicAttribute>>;\n /**\n * content 文本的状态配置\n */\n content?: State<Partial<ITextGraphicAttribute>>;\n /**\n * panel 背景的状态配置ß\n */\n panel?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type PopTipAttributes = {\n /**\n * 弹出框的方位,有 12 个方位可供选择\n */\n position?: 'auto' | 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb';\n /**\n * 标题内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n */\n title?: string | string[] | number | number[];\n /**\n * 标题样式\n */\n titleStyle?: Partial<ITextGraphicAttribute>;\n /**\n * 标题的格式化方法\n */\n titleFormatMethod?: (t: string | string[] | number | number[]) => string | string[] | number | number[];\n /**\n * 内容文本,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n */\n content?: string | string[] | number | number[];\n /**\n * 内容文本样式\n */\n contentStyle?: Partial<ITextGraphicAttribute>;\n /**\n * 内容的格式化方法\n */\n contentFormatMethod?: (t: string | string[] | number | number[]) => string | string[] | number | number[];\n /**\n * 标题与内容的间距\n */\n space?: number;\n /**\n * 内部边距\n */\n padding?: Padding;\n /**\n * 标签的背景面板配置, TODO: 支持symbol形状\n * space: 与位置之间的距离\n * square: 是否是正方形\n */\n panel?: BackgroundAttributes &\n ISymbolGraphicAttribute & { space?: number; square?: boolean; panelSymbolType?: string };\n\n // 标签三角的模式,默认是default,即默认的三角形状,concise是紧凑型三角形状显得更简洁\n // @since 0.22.0\n triangleMode?: 'default' | 'concise';\n\n // 放置在poptip前方的logo区域\n logoSymbol?: ISymbolGraphicAttribute;\n // logo内的text\n logoText?: string | string[] | number | number[];\n // logo内的text样式\n logoTextStyle?: Partial<ITextGraphicAttribute>;\n\n /**\n * 最小宽度,像素值\n * @default 30\n */\n minWidth?: number;\n /**\n * 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n\n /**\n * 最大宽度比例\n */\n maxWidthPercent?: number;\n /**\n * 是否展示\n */\n visible?: boolean;\n /**\n * 自定义的展示逻辑\n */\n visibleFunc?: (graphic: IGraphic) => boolean;\n state?: StateStyle;\n dx?: number;\n dy?: number;\n} & Omit<IGroupGraphicAttribute, 'background'>;\n\nexport type PoptipShapeAttributes = {\n /**\n * 是否展示 shape\n */\n visible: boolean;\n} & Partial<ISymbolGraphicAttribute>;\n"]}
@@ -14,21 +14,21 @@ class Title extends base_1.AbstractComponent {
14
14
  this.name = "title";
15
15
  }
16
16
  render() {
17
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
18
18
  const {textType: textType, text: text, subtextType: subtextType, textStyle: textStyle = {}, subtext: subtext, subtextStyle: subtextStyle = {}, width: width, height: height, minWidth: minWidth, maxWidth: maxWidth, minHeight: minHeight, maxHeight: maxHeight, align: align, verticalAlign: verticalAlign, padding: padding = 0} = this.attribute, parsedPadding = (0,
19
19
  vutils_1.normalizePadding)(padding), group = this.createOrUpdateChild("title-container", {
20
20
  x: parsedPadding[3],
21
21
  y: parsedPadding[0],
22
22
  zIndex: 1
23
- }, "group");
23
+ }, "group"), fixedMainTitleHeight = null !== (_a = textStyle.height) && void 0 !== _a ? _a : height;
24
24
  if (!1 !== this.attribute.visible && !1 !== textStyle.visible) {
25
- const {width: mainTitleWidth, height: mainTitleHeight, maxHeight: mainTitleMaxHeight, maxWidth: mainTitleMaxWidth, x: x = 0, y: y = 0, ellipsis: ellipsis = !0, wordBreak: wordBreak = "break-word", maxWidth: maxWidth, lineClamp: lineClamp} = textStyle;
25
+ const {width: mainTitleWidth, maxHeight: mainTitleMaxHeight, maxWidth: mainTitleMaxWidth, x: x = 0, y: y = 0, ellipsis: ellipsis = !0, wordBreak: wordBreak = "break-word", maxWidth: maxWidth, lineClamp: lineClamp} = textStyle;
26
26
  if ("rich" === textType || (0, vutils_1.isValid)(textStyle.character)) {
27
27
  const attr = Object.assign({
28
28
  x: x,
29
29
  y: y,
30
- width: null !== (_a = null != mainTitleWidth ? mainTitleWidth : width) && void 0 !== _a ? _a : 0,
31
- height: null !== (_b = null != mainTitleHeight ? mainTitleHeight : height) && void 0 !== _b ? _b : 0,
30
+ width: null !== (_b = null != mainTitleWidth ? mainTitleWidth : width) && void 0 !== _b ? _b : 0,
31
+ height: null != fixedMainTitleHeight ? fixedMainTitleHeight : 0,
32
32
  ellipsis: null == ellipsis || ellipsis,
33
33
  wordBreak: null != wordBreak ? wordBreak : "break-word",
34
34
  maxHeight: null != mainTitleMaxHeight ? mainTitleMaxHeight : maxHeight,
@@ -44,7 +44,7 @@ class Title extends base_1.AbstractComponent {
44
44
  x: x,
45
45
  y: y,
46
46
  width: null !== (_d = null != mainTitleWidth ? mainTitleWidth : width) && void 0 !== _d ? _d : 0,
47
- height: null !== (_e = null != mainTitleHeight ? mainTitleHeight : height) && void 0 !== _e ? _e : 0,
47
+ height: null != fixedMainTitleHeight ? fixedMainTitleHeight : 0,
48
48
  ellipsis: ellipsis,
49
49
  wordBreak: wordBreak,
50
50
  maxHeight: null != mainTitleMaxHeight ? mainTitleMaxHeight : maxHeight,
@@ -56,17 +56,17 @@ class Title extends base_1.AbstractComponent {
56
56
  text: (0, vutils_1.isArray)(text) ? text : [ text ],
57
57
  whiteSpace: "normal"
58
58
  }, textStyle), {
59
- maxLineWidth: null !== (_g = null !== (_f = textStyle.maxLineWidth) && void 0 !== _f ? _f : mainTitleWidth) && void 0 !== _g ? _g : width,
60
- heightLimit: null != mainTitleHeight ? mainTitleHeight : maxHeight,
59
+ maxLineWidth: null !== (_f = null !== (_e = textStyle.maxLineWidth) && void 0 !== _e ? _e : mainTitleWidth) && void 0 !== _f ? _f : width,
60
+ heightLimit: null !== (_g = textStyle.height) && void 0 !== _g ? _g : maxHeight,
61
61
  lineClamp: lineClamp,
62
62
  ellipsis: ellipsis,
63
63
  x: x,
64
64
  y: y
65
65
  }), "text"));
66
66
  }
67
- const maintextHeight = this._mainTitle ? this._mainTitle.AABBBounds.height() : 0, maintextWidth = this._mainTitle ? this._mainTitle.AABBBounds.width() : 0;
67
+ const mainTextBoundsHeight = this._mainTitle ? this._mainTitle.AABBBounds.height() : 0, mainTextBoundsWidth = this._mainTitle ? this._mainTitle.AABBBounds.width() : 0;
68
68
  if (!1 !== this.attribute.visible && !1 !== subtextStyle.visible) {
69
- const {width: subTitleWidth, height: subTitleHeight, maxWidth: subTitleMaxWidth, maxHeight: subTitleMaxHeight, x: x = 0, y: y = 0, ellipsis: ellipsis = !0, wordBreak: wordBreak = "break-word", lineClamp: lineClamp} = subtextStyle, maxSubTextHeight = Math.max(Number.MIN_VALUE, maxHeight - maintextHeight);
69
+ const {width: subTitleWidth, height: subTitleHeight, maxWidth: subTitleMaxWidth, maxHeight: subTitleMaxHeight, x: x = 0, y: y = 0, ellipsis: ellipsis = !0, wordBreak: wordBreak = "break-word", lineClamp: lineClamp} = subtextStyle, maxSubTextHeight = Math.max(Number.MIN_VALUE, maxHeight - mainTextBoundsHeight);
70
70
  if ("rich" === subtextType || (0, vutils_1.isValid)(subtextStyle.character)) {
71
71
  const attr = Object.assign({
72
72
  x: x,
@@ -105,45 +105,45 @@ class Title extends base_1.AbstractComponent {
105
105
  lineClamp: lineClamp,
106
106
  ellipsis: ellipsis,
107
107
  x: 0,
108
- y: maintextHeight
108
+ y: mainTextBoundsHeight
109
109
  }), "text"));
110
110
  }
111
- const subtextHeight = this._subTitle ? this._subTitle.AABBBounds.height() : 0, subtextWidth = this._subTitle ? this._subTitle.AABBBounds.width() : 0;
112
- let titleWidth = Math.max(maintextWidth, subtextWidth), titleHeight = maintextHeight + (null !== (_q = subtextStyle.height) && void 0 !== _q ? _q : subtextHeight);
113
- if ((0, vutils_1.isValid)(width) && (titleWidth = width), (0, vutils_1.isValid)(height) && (titleHeight = height),
114
- (0, vutils_1.isValid)(minWidth) && titleWidth < minWidth && (titleWidth = minWidth),
115
- (0, vutils_1.isValid)(maxWidth) && titleWidth > maxWidth && (titleWidth = maxWidth),
116
- (0, vutils_1.isValid)(minHeight) && titleHeight < minHeight && (titleHeight = minHeight),
117
- (0, vutils_1.isValid)(maxHeight) && titleHeight > maxHeight && (titleHeight = maxHeight),
118
- group.attribute.width = titleWidth, group.attribute.height = titleHeight, group.attribute.boundsPadding = parsedPadding,
111
+ const subTextBoundsHeight = this._subTitle ? this._subTitle.AABBBounds.height() : 0, subTextBoundsWidth = this._subTitle ? this._subTitle.AABBBounds.width() : 0;
112
+ let totalWidth = Math.max(mainTextBoundsWidth, subTextBoundsWidth), totalHeight = mainTextBoundsHeight + (null !== (_q = subtextStyle.height) && void 0 !== _q ? _q : subTextBoundsHeight);
113
+ if ((0, vutils_1.isValid)(width) && (totalWidth = width), (0, vutils_1.isValid)(height) && (totalHeight = height),
114
+ (0, vutils_1.isValid)(minWidth) && totalWidth < minWidth && (totalWidth = minWidth),
115
+ (0, vutils_1.isValid)(maxWidth) && totalWidth > maxWidth && (totalWidth = maxWidth),
116
+ (0, vutils_1.isValid)(minHeight) && totalHeight < minHeight && (totalHeight = minHeight),
117
+ (0, vutils_1.isValid)(maxHeight) && totalHeight > maxHeight && (totalHeight = maxHeight),
118
+ group.attribute.width = totalWidth, group.attribute.height = totalHeight, group.attribute.boundsPadding = parsedPadding,
119
119
  this._mainTitle) {
120
120
  if ((0, vutils_1.isValid)(align) || (0, vutils_1.isValid)(textStyle.align)) {
121
- const mainTitleAlign = textStyle.align ? textStyle.align : align, mainTitleWidth = null !== (_r = textStyle.width) && void 0 !== _r ? _r : maintextWidth;
122
- "left" === mainTitleAlign ? (this._mainTitle.setAttribute("x", 0), this._mainTitle.setAttribute("textAlign", "left")) : "center" === mainTitleAlign ? (this._mainTitle.setAttribute("x", mainTitleWidth / 2),
123
- this._mainTitle.setAttribute("textAlign", "center")) : "right" === mainTitleAlign && (this._mainTitle.setAttribute("x", mainTitleWidth),
124
- this._mainTitle.setAttribute("textAlign", "right"));
125
- }
126
- if ((0, vutils_1.isValid)(verticalAlign) || (0, vutils_1.isValid)(textStyle.verticalAlign)) {
127
- const mainTitleVerticalAlign = textStyle.verticalAlign ? textStyle.verticalAlign : verticalAlign, mainTitleHeight = textStyle.height ? textStyle.height : titleHeight;
128
- "top" === mainTitleVerticalAlign ? (this._mainTitle.setAttribute("y", 0), this._mainTitle.setAttribute("textBaseline", "top")) : "middle" === mainTitleVerticalAlign ? (this._mainTitle.setAttribute("y", mainTitleHeight / 2),
129
- this._mainTitle.setAttribute("textBaseline", "middle")) : "bottom" === mainTitleVerticalAlign && (this._mainTitle.setAttribute("y", mainTitleHeight),
130
- this._mainTitle.setAttribute("textBaseline", "bottom"));
121
+ const mainTitleAlign = textStyle.align ? textStyle.align : align, mainTitleWidth = null !== (_r = textStyle.width) && void 0 !== _r ? _r : totalWidth;
122
+ "center" === mainTitleAlign ? (this._mainTitle.setAttribute("x", mainTitleWidth / 2),
123
+ this._mainTitle.setAttribute("textAlign", "center")) : "right" === mainTitleAlign ? (this._mainTitle.setAttribute("x", mainTitleWidth),
124
+ this._mainTitle.setAttribute("textAlign", "right")) : (this._mainTitle.setAttribute("x", 0),
125
+ this._mainTitle.setAttribute("textAlign", "left"));
131
126
  }
127
+ const mainTitleVerticalAlign = textStyle.verticalAlign ? textStyle.verticalAlign : verticalAlign, mainTitleHeight = null != fixedMainTitleHeight ? fixedMainTitleHeight : this._mainTitle.AABBBounds.empty() ? 0 : this._mainTitle.AABBBounds.height();
128
+ "middle" === mainTitleVerticalAlign ? (this._mainTitle.setAttribute("y", mainTitleHeight / 2),
129
+ this._mainTitle.setAttribute("textBaseline", "middle")) : "bottom" === mainTitleVerticalAlign ? (this._mainTitle.setAttribute("y", mainTitleHeight),
130
+ this._mainTitle.setAttribute("textBaseline", "bottom")) : (this._mainTitle.setAttribute("y", 0),
131
+ this._mainTitle.setAttribute("textBaseline", "top"));
132
132
  }
133
133
  if (this._subTitle) {
134
134
  if ((0, vutils_1.isValid)(align) || (0, vutils_1.isValid)(subtextStyle.align)) {
135
- const subTitleAlign = subtextStyle.align ? subtextStyle.align : align, subTitleWidth = null !== (_s = subtextStyle.width) && void 0 !== _s ? _s : subtextWidth;
136
- "left" === subTitleAlign ? (this._subTitle.setAttribute("x", 0), this._subTitle.setAttribute("textAlign", "left")) : "center" === subTitleAlign ? (this._subTitle.setAttribute("x", subTitleWidth / 2),
137
- this._subTitle.setAttribute("textAlign", "center")) : "right" === subTitleAlign && (this._subTitle.setAttribute("x", subTitleWidth),
138
- this._subTitle.setAttribute("textAlign", "right"));
139
- }
140
- if ((0, vutils_1.isValid)(verticalAlign) || (0, vutils_1.isValid)(textStyle.verticalAlign)) {
141
- const subTitleVerticalAlign = subtextStyle.verticalAlign ? subtextStyle.verticalAlign : verticalAlign, subTitleYStart = maintextHeight, subTitleHeight = null !== (_t = subtextStyle.height) && void 0 !== _t ? _t : 0;
142
- "top" === subTitleVerticalAlign ? (this._subTitle.setAttribute("y", subTitleYStart),
143
- this._subTitle.setAttribute("textBaseline", "top")) : "middle" === subTitleVerticalAlign ? (this._subTitle.setAttribute("y", subTitleYStart + subTitleHeight / 2),
144
- this._subTitle.setAttribute("textBaseline", "middle")) : "bottom" === subTitleVerticalAlign && (this._subTitle.setAttribute("y", subTitleYStart + subTitleHeight),
145
- this._subTitle.setAttribute("textBaseline", "bottom"));
135
+ const subTitleAlign = subtextStyle.align ? subtextStyle.align : align, subTitleWidth = null !== (_t = null !== (_s = subtextStyle.width) && void 0 !== _s ? _s : textStyle.width) && void 0 !== _t ? _t : totalWidth;
136
+ "center" === subTitleAlign ? (this._subTitle.setAttribute("x", subTitleWidth / 2),
137
+ this._subTitle.setAttribute("textAlign", "center")) : "right" === subTitleAlign ? (this._subTitle.setAttribute("x", subTitleWidth),
138
+ this._subTitle.setAttribute("textAlign", "right")) : (this._subTitle.setAttribute("x", 0),
139
+ this._subTitle.setAttribute("textAlign", "left"));
146
140
  }
141
+ const subTitleVerticalAlign = subtextStyle.verticalAlign ? subtextStyle.verticalAlign : verticalAlign, subTitleYStart = this._mainTitle ? (0,
142
+ vutils_1.isValid)(fixedMainTitleHeight) ? this._mainTitle.AABBBounds.y1 + Math.max(this._mainTitle.AABBBounds.empty() ? 0 : this._mainTitle.AABBBounds.height(), fixedMainTitleHeight) : this._mainTitle.AABBBounds.y2 : 0, subTitleHeight = null !== (_v = null !== (_u = subtextStyle.height) && void 0 !== _u ? _u : height) && void 0 !== _v ? _v : this._subTitle.AABBBounds.empty() ? 0 : this._subTitle.AABBBounds.height();
143
+ "middle" === subTitleVerticalAlign ? (this._subTitle.setAttribute("y", subTitleYStart + subTitleHeight / 2),
144
+ this._subTitle.setAttribute("textBaseline", "middle")) : "bottom" === subTitleVerticalAlign ? (this._subTitle.setAttribute("y", subTitleYStart + subTitleHeight),
145
+ this._subTitle.setAttribute("textBaseline", "bottom")) : (this._subTitle.setAttribute("y", subTitleYStart),
146
+ this._subTitle.setAttribute("textBaseline", "top"));
147
147
  }
148
148
  }
149
149
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/title/title.ts"],"names":[],"mappings":";;;AAIA,6CAA6E;AAC7E,uCAAiD;AAGjD,0CAAqD;AACrD,yCAAgD;AAEhD,IAAA,6BAAkB,GAAE,CAAC;AACrB,MAAa,KAAM,SAAQ,wBAAuC;IAyBhE,YAAY,UAAsB,EAAE,OAA0B;QAC5D,KAAK,CAAC,CAAA,OAAO,aA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AI,CAAC,SAAS,CAAC,YAAY,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;iBACpD;qBAAM,IAAI,qBAAqB,KAAK,QAAQ,EAAE;oBAC7C,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC;oBACtE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;iBACvD;qBAAM,IAAI,qBAAqB,KAAK,QAAQ,EAAE;oBAC7C,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,CAAC,CAAC;oBAClE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;iBACvD;aACF;SACF;IACH,CAAC;;AAxSH,sBAySC;AAnSQ,uBAAiB,GAAwB;IAC9C,SAAS,EAAE;QACT,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,MAAM;QAClB,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;CACF,CAAC","file":"title.js","sourcesContent":["/**\n * @description 标题组件\n */\nimport type { IGroup, IText, IRichText, IRichTextCharacter } from '@visactor/vrender-core';\nimport { merge, isValid, normalizePadding, isArray } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { TitleAttrs } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { DEFAULT_HTML_TEXT_SPEC } from '../constant';\nimport { loadTitleComponent } from './register';\n\nloadTitleComponent();\nexport class Title extends AbstractComponent<Required<TitleAttrs>> {\n name = 'title';\n\n private _mainTitle?: IText | IRichText;\n private _subTitle?: IText | IRichText;\n\n static defaultAttributes: Partial<TitleAttrs> = {\n textStyle: {\n ellipsis: '...',\n fill: '#333',\n fontSize: 20,\n fontWeight: 'bold',\n textAlign: 'left',\n textBaseline: 'top'\n },\n subtextStyle: {\n ellipsis: '...',\n fill: '#6F6F6F',\n fontSize: 16,\n fontWeight: 'normal',\n textAlign: 'left',\n textBaseline: 'top'\n }\n };\n\n constructor(attributes: TitleAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Title.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n textType,\n text,\n subtextType,\n textStyle = {},\n subtext,\n subtextStyle = {},\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n align,\n verticalAlign,\n padding = 0\n } = this.attribute as TitleAttrs;\n\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild(\n 'title-container',\n { x: parsedPadding[3], y: parsedPadding[0], zIndex: 1 },\n 'group'\n ) as IGroup;\n\n if (this.attribute.visible !== false && textStyle.visible !== false) {\n const {\n width: mainTitleWidth,\n height: mainTitleHeight,\n maxHeight: mainTitleMaxHeight,\n maxWidth: mainTitleMaxWidth,\n x = 0,\n y = 0,\n ellipsis = true,\n wordBreak = 'break-word',\n maxWidth,\n lineClamp\n } = textStyle;\n if (textType === 'rich' || isValid(textStyle.character)) {\n const attr = {\n x,\n y,\n width: mainTitleWidth ?? width ?? 0,\n height: mainTitleHeight ?? height ?? 0,\n ellipsis: ellipsis ?? true,\n wordBreak: wordBreak ?? 'break-word',\n maxHeight: mainTitleMaxHeight ?? maxHeight,\n maxWidth: mainTitleMaxWidth ?? maxWidth,\n // 兼容旧版富文本配置,如果未设置textType === 'rich',text内容为string 易报错\n textConfig: textStyle.character ?? (text as IRichTextCharacter[]),\n ...textStyle\n };\n this._mainTitle = group.createOrUpdateChild('mainTitle', attr, 'richtext') as IRichText;\n } else if (textType === 'html') {\n const attr = {\n html: {\n dom: text as string,\n ...DEFAULT_HTML_TEXT_SPEC,\n ...textStyle\n },\n x,\n y,\n width: mainTitleWidth ?? width ?? 0,\n height: mainTitleHeight ?? height ?? 0,\n ellipsis,\n wordBreak,\n maxHeight: mainTitleMaxHeight ?? maxHeight,\n maxWidth: mainTitleMaxWidth ?? maxWidth,\n textConfig: [] as any[],\n ...textStyle\n };\n this._mainTitle = group.createOrUpdateChild('mainTitle', attr, 'richtext') as IRichText;\n } else if (isValid(text)) {\n this._mainTitle = group.createOrUpdateChild(\n 'mainTitle',\n {\n text: isArray(text) ? (text as any) : [text as string],\n whiteSpace: 'normal',\n ...textStyle,\n maxLineWidth: textStyle.maxLineWidth ?? mainTitleWidth ?? width,\n heightLimit: mainTitleHeight ?? maxHeight,\n lineClamp,\n ellipsis,\n x,\n y\n },\n 'text'\n ) as IText;\n }\n }\n\n const maintextHeight = this._mainTitle ? this._mainTitle.AABBBounds.height() : 0;\n const maintextWidth = this._mainTitle ? this._mainTitle.AABBBounds.width() : 0;\n\n // 目前 height 限制等于 0 时,相当于 Infinity,无限制\n\n if (this.attribute.visible !== false && subtextStyle.visible !== false) {\n const {\n width: subTitleWidth,\n height: subTitleHeight,\n maxWidth: subTitleMaxWidth,\n maxHeight: subTitleMaxHeight,\n x = 0,\n y = 0,\n ellipsis = true,\n wordBreak = 'break-word',\n lineClamp\n } = subtextStyle;\n const maxSubTextHeight = Math.max(Number.MIN_VALUE, maxHeight - maintextHeight);\n\n if (subtextType === 'rich' || isValid(subtextStyle.character)) {\n const attr: any = {\n x,\n y,\n width: subTitleWidth ?? width ?? 0,\n height: subTitleHeight ?? height ?? 0,\n ellipsis,\n wordBreak,\n maxHeight: subTitleMaxHeight ?? maxSubTextHeight,\n maxWidth: subTitleMaxWidth ?? maxWidth,\n // 兼容旧版富文本配置,如果未设置textType === 'rich',text内容为string 易报错\n textConfig: subtextStyle.character ?? (subtext as IRichTextCharacter[]),\n ...subtextStyle\n };\n this._subTitle = group.createOrUpdateChild('subTitle', attr, 'richtext') as IRichText;\n } else if (subtextType === 'html') {\n const attr: any = {\n html: {\n dom: subtext as string,\n ...DEFAULT_HTML_TEXT_SPEC,\n ...subtextStyle\n },\n x,\n y,\n width: subTitleWidth ?? width ?? 0,\n height: subTitleHeight ?? height ?? 0,\n ellipsis,\n wordBreak,\n maxHeight: subTitleMaxHeight ?? maxSubTextHeight,\n maxWidth: subTitleMaxWidth ?? maxWidth,\n textConfig: [] as any[],\n ...subtextStyle\n };\n this._subTitle = group.createOrUpdateChild('subTitle', attr, 'richtext') as IRichText;\n } else if (isValid(subtext)) {\n this._subTitle = group.createOrUpdateChild(\n 'subTitle',\n {\n text: isArray(subtext) ? (subtext as any) : [subtext as string],\n whiteSpace: 'normal',\n ...subtextStyle,\n maxLineWidth: subtextStyle.maxLineWidth ?? width,\n heightLimit: subtextStyle.heightLimit ?? maxSubTextHeight,\n lineClamp,\n ellipsis,\n x: 0,\n y: maintextHeight\n },\n 'text'\n ) as IText;\n }\n }\n\n const subtextHeight = this._subTitle ? this._subTitle.AABBBounds.height() : 0;\n const subtextWidth = this._subTitle ? this._subTitle.AABBBounds.width() : 0;\n\n // 设置宽高\n let titleWidth = Math.max(maintextWidth, subtextWidth);\n let titleHeight = maintextHeight + (subtextStyle.height ?? subtextHeight);\n\n if (isValid(width)) {\n titleWidth = width;\n }\n\n if (isValid(height)) {\n titleHeight = height;\n }\n\n if (isValid(minWidth) && titleWidth < minWidth) {\n titleWidth = minWidth;\n }\n if (isValid(maxWidth)) {\n if (titleWidth > maxWidth) {\n titleWidth = maxWidth;\n }\n }\n\n if (isValid(minHeight) && titleHeight < minHeight) {\n titleHeight = minHeight;\n }\n\n if (isValid(maxHeight)) {\n if (titleHeight > maxHeight) {\n titleHeight = maxHeight;\n }\n }\n group.attribute.width = titleWidth;\n group.attribute.height = titleHeight;\n group.attribute.boundsPadding = parsedPadding;\n\n // 设置对齐\n if (this._mainTitle) {\n if (isValid(align) || isValid(textStyle.align)) {\n const mainTitleAlign = textStyle.align ? textStyle.align : align;\n const mainTitleWidth = textStyle.width ?? maintextWidth;\n if (mainTitleAlign === 'left') {\n this._mainTitle.setAttribute('x', 0);\n this._mainTitle.setAttribute('textAlign', 'left');\n } else if (mainTitleAlign === 'center') {\n this._mainTitle.setAttribute('x', mainTitleWidth / 2);\n this._mainTitle.setAttribute('textAlign', 'center');\n } else if (mainTitleAlign === 'right') {\n this._mainTitle.setAttribute('x', mainTitleWidth);\n this._mainTitle.setAttribute('textAlign', 'right');\n }\n }\n\n if (isValid(verticalAlign) || isValid(textStyle.verticalAlign)) {\n const mainTitleVerticalAlign = textStyle.verticalAlign ? textStyle.verticalAlign : verticalAlign;\n const mainTitleHeight = textStyle.height ? textStyle.height : titleHeight;\n if (mainTitleVerticalAlign === 'top') {\n this._mainTitle.setAttribute('y', 0);\n this._mainTitle.setAttribute('textBaseline', 'top');\n } else if (mainTitleVerticalAlign === 'middle') {\n this._mainTitle.setAttribute('y', mainTitleHeight / 2);\n this._mainTitle.setAttribute('textBaseline', 'middle');\n } else if (mainTitleVerticalAlign === 'bottom') {\n this._mainTitle.setAttribute('y', mainTitleHeight);\n this._mainTitle.setAttribute('textBaseline', 'bottom');\n }\n }\n }\n\n if (this._subTitle) {\n if (isValid(align) || isValid(subtextStyle.align)) {\n const subTitleAlign = subtextStyle.align ? subtextStyle.align : align;\n const subTitleWidth = subtextStyle.width ?? subtextWidth;\n if (subTitleAlign === 'left') {\n this._subTitle.setAttribute('x', 0);\n this._subTitle.setAttribute('textAlign', 'left');\n } else if (subTitleAlign === 'center') {\n this._subTitle.setAttribute('x', subTitleWidth / 2);\n this._subTitle.setAttribute('textAlign', 'center');\n } else if (subTitleAlign === 'right') {\n this._subTitle.setAttribute('x', subTitleWidth);\n this._subTitle.setAttribute('textAlign', 'right');\n }\n }\n\n if (isValid(verticalAlign) || isValid(textStyle.verticalAlign)) {\n const subTitleVerticalAlign = subtextStyle.verticalAlign ? subtextStyle.verticalAlign : verticalAlign;\n const subTitleYStart = maintextHeight;\n const subTitleHeight = subtextStyle.height ?? 0;\n if (subTitleVerticalAlign === 'top') {\n this._subTitle.setAttribute('y', subTitleYStart);\n this._subTitle.setAttribute('textBaseline', 'top');\n } else if (subTitleVerticalAlign === 'middle') {\n this._subTitle.setAttribute('y', subTitleYStart + subTitleHeight / 2);\n this._subTitle.setAttribute('textBaseline', 'middle');\n } else if (subTitleVerticalAlign === 'bottom') {\n this._subTitle.setAttribute('y', subTitleYStart + subTitleHeight);\n this._subTitle.setAttribute('textBaseline', 'bottom');\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/title/title.ts"],"names":[],"mappings":";;;AAIA,6CAA6E;AAC7E,uCAAiD;AAGjD,0CAAqD;AACrD,yCAAgD;AAGhD,IAAA,6BAAkB,GAAE,CAAC;AACrB,MAAa,KAAM,SAAQ,wBAAuC;IAyBhE,YAAY,UAAsB,EAAE,OAA0B;QAC5D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,KAAK,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAzB5F,SAAI,GAAG,OAAO,CAAC;IA0Bf,CAAC;IAES,MAAM;;QACd,MAAM,EACJ,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,SAAS,GAAG,EAAE,EACd,OAAO,EACP,YAAY,GAAG,EAAE,EACjB,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,KAAK,EACL,aAAa,EACb,OAAO,GAAG,CAAC,EACZ,GAAG,IAAI,CAAC,SAAuB,CAAC;QAEjC,MAAM,aAAa,GAAG,IAAA,yBAAgB,EAAC,OAAO,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CACpC,iBAAiB,EACjB,EAAE,CAAC,EAAE,aAAa,CAAC,C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AG,EAAE,cAAc,GAAG,cAAc,CAAC,CAAC;gBAClE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;aACvD;iBAAM;gBACL,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;gBACjD,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;aACpD;SACF;IACH,CAAC;;AAjTH,sBAkTC;AA5SQ,uBAAiB,GAAwB;IAC9C,SAAS,EAAE;QACT,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,MAAM;QAClB,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;CACF,CAAC","file":"title.js","sourcesContent":["/**\n * @description 标题组件\n */\nimport type { IGroup, IText, IRichText, IRichTextCharacter } from '@visactor/vrender-core';\nimport { merge, isValid, normalizePadding, isArray } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { TitleAttrs } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { DEFAULT_HTML_TEXT_SPEC } from '../constant';\nimport { loadTitleComponent } from './register';\nimport { Text } from '@visactor/vrender-core';\n\nloadTitleComponent();\nexport class Title extends AbstractComponent<Required<TitleAttrs>> {\n name = 'title';\n\n private _mainTitle?: IText | IRichText;\n private _subTitle?: IText | IRichText;\n\n static defaultAttributes: Partial<TitleAttrs> = {\n textStyle: {\n ellipsis: '...',\n fill: '#333',\n fontSize: 20,\n fontWeight: 'bold',\n textAlign: 'left',\n textBaseline: 'top'\n },\n subtextStyle: {\n ellipsis: '...',\n fill: '#6F6F6F',\n fontSize: 16,\n fontWeight: 'normal',\n textAlign: 'left',\n textBaseline: 'top'\n }\n };\n\n constructor(attributes: TitleAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Title.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n textType,\n text,\n subtextType,\n textStyle = {},\n subtext,\n subtextStyle = {},\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n align,\n verticalAlign,\n padding = 0\n } = this.attribute as TitleAttrs;\n\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild(\n 'title-container',\n { x: parsedPadding[3], y: parsedPadding[0], zIndex: 1 },\n 'group'\n ) as IGroup;\n\n const fixedMainTitleHeight = textStyle.height ?? height;\n if (this.attribute.visible !== false && textStyle.visible !== false) {\n const {\n width: mainTitleWidth,\n maxHeight: mainTitleMaxHeight,\n maxWidth: mainTitleMaxWidth,\n x = 0,\n y = 0,\n ellipsis = true,\n wordBreak = 'break-word',\n maxWidth,\n lineClamp\n } = textStyle;\n if (textType === 'rich' || isValid(textStyle.character)) {\n const attr = {\n x,\n y,\n width: mainTitleWidth ?? width ?? 0,\n height: fixedMainTitleHeight ?? 0,\n ellipsis: ellipsis ?? true,\n wordBreak: wordBreak ?? 'break-word',\n maxHeight: mainTitleMaxHeight ?? maxHeight,\n maxWidth: mainTitleMaxWidth ?? maxWidth,\n // 兼容旧版富文本配置,如果未设置textType === 'rich',text内容为string 易报错\n textConfig: textStyle.character ?? (text as IRichTextCharacter[]),\n ...textStyle\n };\n this._mainTitle = group.createOrUpdateChild('mainTitle', attr, 'richtext') as IRichText;\n } else if (textType === 'html') {\n const attr = {\n html: {\n dom: text as string,\n ...DEFAULT_HTML_TEXT_SPEC,\n ...textStyle\n },\n x,\n y,\n width: mainTitleWidth ?? width ?? 0,\n height: fixedMainTitleHeight ?? 0,\n ellipsis,\n wordBreak,\n maxHeight: mainTitleMaxHeight ?? maxHeight,\n maxWidth: mainTitleMaxWidth ?? maxWidth,\n textConfig: [] as any[],\n ...textStyle\n };\n this._mainTitle = group.createOrUpdateChild('mainTitle', attr, 'richtext') as IRichText;\n } else if (isValid(text)) {\n this._mainTitle = group.createOrUpdateChild(\n 'mainTitle',\n {\n text: isArray(text) ? (text as any) : [text as string],\n whiteSpace: 'normal',\n ...textStyle,\n maxLineWidth: textStyle.maxLineWidth ?? mainTitleWidth ?? width,\n heightLimit: textStyle.height ?? maxHeight,\n lineClamp,\n ellipsis,\n x,\n y\n },\n 'text'\n ) as IText;\n }\n }\n\n const mainTextBoundsHeight = this._mainTitle ? this._mainTitle.AABBBounds.height() : 0;\n const mainTextBoundsWidth = this._mainTitle ? this._mainTitle.AABBBounds.width() : 0;\n\n // 目前 height 限制等于 0 时,相当于 Infinity,无限制\n\n if (this.attribute.visible !== false && subtextStyle.visible !== false) {\n const {\n width: subTitleWidth,\n height: subTitleHeight,\n maxWidth: subTitleMaxWidth,\n maxHeight: subTitleMaxHeight,\n x = 0,\n y = 0,\n ellipsis = true,\n wordBreak = 'break-word',\n lineClamp\n } = subtextStyle;\n const maxSubTextHeight = Math.max(Number.MIN_VALUE, maxHeight - mainTextBoundsHeight);\n\n if (subtextType === 'rich' || isValid(subtextStyle.character)) {\n const attr: any = {\n x,\n y,\n width: subTitleWidth ?? width ?? 0,\n height: subTitleHeight ?? height ?? 0,\n ellipsis,\n wordBreak,\n maxHeight: subTitleMaxHeight ?? maxSubTextHeight,\n maxWidth: subTitleMaxWidth ?? maxWidth,\n // 兼容旧版富文本配置,如果未设置textType === 'rich',text内容为string 易报错\n textConfig: subtextStyle.character ?? (subtext as IRichTextCharacter[]),\n ...subtextStyle\n };\n this._subTitle = group.createOrUpdateChild('subTitle', attr, 'richtext') as IRichText;\n } else if (subtextType === 'html') {\n const attr: any = {\n html: {\n dom: subtext as string,\n ...DEFAULT_HTML_TEXT_SPEC,\n ...subtextStyle\n },\n x,\n y,\n width: subTitleWidth ?? width ?? 0,\n height: subTitleHeight ?? height ?? 0,\n ellipsis,\n wordBreak,\n maxHeight: subTitleMaxHeight ?? maxSubTextHeight,\n maxWidth: subTitleMaxWidth ?? maxWidth,\n textConfig: [] as any[],\n ...subtextStyle\n };\n this._subTitle = group.createOrUpdateChild('subTitle', attr, 'richtext') as IRichText;\n } else if (isValid(subtext)) {\n this._subTitle = group.createOrUpdateChild(\n 'subTitle',\n {\n text: isArray(subtext) ? (subtext as any) : [subtext as string],\n whiteSpace: 'normal',\n ...subtextStyle,\n maxLineWidth: subtextStyle.maxLineWidth ?? width,\n heightLimit: subtextStyle.heightLimit ?? maxSubTextHeight,\n lineClamp,\n ellipsis,\n x: 0,\n y: mainTextBoundsHeight\n },\n 'text'\n ) as IText;\n }\n }\n\n const subTextBoundsHeight = this._subTitle ? this._subTitle.AABBBounds.height() : 0;\n const subTextBoundsWidth = this._subTitle ? this._subTitle.AABBBounds.width() : 0;\n\n // 设置宽高\n let totalWidth = Math.max(mainTextBoundsWidth, subTextBoundsWidth);\n let totalHeight = mainTextBoundsHeight + (subtextStyle.height ?? subTextBoundsHeight);\n\n if (isValid(width)) {\n totalWidth = width;\n }\n\n if (isValid(height)) {\n totalHeight = height;\n }\n\n if (isValid(minWidth) && totalWidth < minWidth) {\n totalWidth = minWidth;\n }\n if (isValid(maxWidth)) {\n if (totalWidth > maxWidth) {\n totalWidth = maxWidth;\n }\n }\n\n if (isValid(minHeight) && totalHeight < minHeight) {\n totalHeight = minHeight;\n }\n\n if (isValid(maxHeight)) {\n if (totalHeight > maxHeight) {\n totalHeight = maxHeight;\n }\n }\n\n group.attribute.width = totalWidth;\n group.attribute.height = totalHeight;\n group.attribute.boundsPadding = parsedPadding;\n\n // 设置对齐\n if (this._mainTitle) {\n if (isValid(align) || isValid(textStyle.align)) {\n const mainTitleAlign = textStyle.align ? textStyle.align : align;\n const mainTitleWidth = textStyle.width ?? totalWidth;\n if (mainTitleAlign === 'center') {\n this._mainTitle.setAttribute('x', mainTitleWidth / 2);\n this._mainTitle.setAttribute('textAlign', 'center');\n } else if (mainTitleAlign === 'right') {\n this._mainTitle.setAttribute('x', mainTitleWidth);\n this._mainTitle.setAttribute('textAlign', 'right');\n } else {\n this._mainTitle.setAttribute('x', 0);\n this._mainTitle.setAttribute('textAlign', 'left');\n }\n }\n\n const mainTitleVerticalAlign = textStyle.verticalAlign ? textStyle.verticalAlign : verticalAlign;\n const mainTitleHeight =\n fixedMainTitleHeight ?? (this._mainTitle.AABBBounds.empty() ? 0 : this._mainTitle.AABBBounds.height());\n\n if (mainTitleVerticalAlign === 'middle') {\n this._mainTitle.setAttribute('y', mainTitleHeight / 2);\n this._mainTitle.setAttribute('textBaseline', 'middle');\n } else if (mainTitleVerticalAlign === 'bottom') {\n this._mainTitle.setAttribute('y', mainTitleHeight);\n this._mainTitle.setAttribute('textBaseline', 'bottom');\n } else {\n // 如果没有显示的设置verticalAlign,默认top\n this._mainTitle.setAttribute('y', 0);\n this._mainTitle.setAttribute('textBaseline', 'top');\n }\n }\n\n if (this._subTitle) {\n if (isValid(align) || isValid(subtextStyle.align)) {\n const subTitleAlign = subtextStyle.align ? subtextStyle.align : align;\n // 当subText没有设置显示的宽度,但是mainText设置了显示的宽度的时候,为mainText为主,因为默认subText要和mainText对齐\n const subTitleWidth = subtextStyle.width ?? textStyle.width ?? totalWidth;\n if (subTitleAlign === 'center') {\n this._subTitle.setAttribute('x', subTitleWidth / 2);\n this._subTitle.setAttribute('textAlign', 'center');\n } else if (subTitleAlign === 'right') {\n this._subTitle.setAttribute('x', subTitleWidth);\n this._subTitle.setAttribute('textAlign', 'right');\n } else {\n this._subTitle.setAttribute('x', 0);\n this._subTitle.setAttribute('textAlign', 'left');\n }\n }\n\n const subTitleVerticalAlign = subtextStyle.verticalAlign ? subtextStyle.verticalAlign : verticalAlign;\n\n const subTitleYStart = this._mainTitle\n ? isValid(fixedMainTitleHeight)\n ? // 如果是用户指定的高度,根据bounds的height 和指定高度求最大值\n this._mainTitle.AABBBounds.y1 +\n Math.max(this._mainTitle.AABBBounds.empty() ? 0 : this._mainTitle.AABBBounds.height(), fixedMainTitleHeight)\n : this._mainTitle.AABBBounds.y2\n : 0;\n const subTitleHeight =\n subtextStyle.height ?? height ?? (this._subTitle.AABBBounds.empty() ? 0 : this._subTitle.AABBBounds.height());\n if (subTitleVerticalAlign === 'middle') {\n this._subTitle.setAttribute('y', subTitleYStart + subTitleHeight / 2);\n this._subTitle.setAttribute('textBaseline', 'middle');\n } else if (subTitleVerticalAlign === 'bottom') {\n this._subTitle.setAttribute('y', subTitleYStart + subTitleHeight);\n this._subTitle.setAttribute('textBaseline', 'bottom');\n } else {\n this._subTitle.setAttribute('y', subTitleYStart);\n this._subTitle.setAttribute('textBaseline', 'top');\n }\n }\n }\n}\n"]}