@visactor/vrender-components 0.20.1-alpha.5 → 0.20.1

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.
Files changed (64) hide show
  1. package/cjs/axis/util.js +2 -1
  2. package/cjs/brush/type.js +1 -2
  3. package/cjs/checkbox/checkbox.d.ts +2 -0
  4. package/cjs/checkbox/checkbox.js +4 -0
  5. package/cjs/checkbox/checkbox.js.map +1 -1
  6. package/cjs/index.d.ts +1 -1
  7. package/cjs/index.js +1 -1
  8. package/cjs/index.js.map +1 -1
  9. package/cjs/label/arc.d.ts +2 -2
  10. package/cjs/label/arc.js +18 -4
  11. package/cjs/label/arc.js.map +1 -1
  12. package/cjs/label/base.js +15 -2
  13. package/cjs/label/base.js.map +1 -1
  14. package/cjs/label/dataLabel.js +14 -2
  15. package/cjs/label/dataLabel.js.map +1 -1
  16. package/cjs/label/line.js +14 -2
  17. package/cjs/label/line.js.map +1 -1
  18. package/cjs/label/polygon.js +14 -2
  19. package/cjs/label/polygon.js.map +1 -1
  20. package/cjs/label/rect.js +14 -1
  21. package/cjs/label/rect.js.map +1 -1
  22. package/cjs/label/symbol.js +14 -2
  23. package/cjs/label/symbol.js.map +1 -1
  24. package/cjs/label/type.d.ts +1 -1
  25. package/cjs/label/type.js.map +1 -1
  26. package/cjs/radio/radio.d.ts +2 -0
  27. package/cjs/radio/radio.js +4 -0
  28. package/cjs/radio/radio.js.map +1 -1
  29. package/cjs/tag/tag.d.ts +10 -0
  30. package/cjs/tag/tag.js +32 -2
  31. package/cjs/tag/tag.js.map +1 -1
  32. package/dist/index.es.js +86 -10
  33. package/es/axis/util.js +2 -1
  34. package/es/brush/type.js +1 -2
  35. package/es/checkbox/checkbox.d.ts +2 -0
  36. package/es/checkbox/checkbox.js +4 -0
  37. package/es/checkbox/checkbox.js.map +1 -1
  38. package/es/index.d.ts +1 -1
  39. package/es/index.js +1 -1
  40. package/es/index.js.map +1 -1
  41. package/es/label/arc.d.ts +2 -2
  42. package/es/label/arc.js +18 -4
  43. package/es/label/arc.js.map +1 -1
  44. package/es/label/base.js +15 -2
  45. package/es/label/base.js.map +1 -1
  46. package/es/label/dataLabel.js +14 -2
  47. package/es/label/dataLabel.js.map +1 -1
  48. package/es/label/line.js +14 -2
  49. package/es/label/line.js.map +1 -1
  50. package/es/label/polygon.js +14 -2
  51. package/es/label/polygon.js.map +1 -1
  52. package/es/label/rect.js +14 -1
  53. package/es/label/rect.js.map +1 -1
  54. package/es/label/symbol.js +14 -2
  55. package/es/label/symbol.js.map +1 -1
  56. package/es/label/type.d.ts +1 -1
  57. package/es/label/type.js.map +1 -1
  58. package/es/radio/radio.d.ts +2 -0
  59. package/es/radio/radio.js +4 -0
  60. package/es/radio/radio.js.map +1 -1
  61. package/es/tag/tag.d.ts +10 -0
  62. package/es/tag/tag.js +32 -2
  63. package/es/tag/tag.js.map +1 -1
  64. package/package.json +5 -5
@@ -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} 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 animationEnter?: ILabelUpdateAnimation;\n animationUpdate?: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[];\n animationExit?: ILabelExitAnimation;\n\n // 排序 or 删减\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 */\n strategy?: Strategy[];\n\n /**\n * 文字在防重叠计算中预留的边距。\n * @default 0\n */\n overlapPadding?: 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\nexport type PositionStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type BoundStrategy = {\n /**\n * 标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n position?: Functional<LabelPosition[]>;\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 */\n position?: Functional<BoundsAnchorType>;\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 */\n position?: Functional<'inside' | 'outside' | 'inside-inner' | 'inside-outer'>;\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?: (\n text: ITextGraphicAttribute,\n attrs: Partial<ILineGraphicAttribute>,\n path: ICustomPath2D\n ) => 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 */\n line2MinLength?: 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 * @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} 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 animationEnter?: ILabelUpdateAnimation;\n animationUpdate?: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[];\n animationExit?: ILabelExitAnimation;\n\n // 排序 or 删减\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 */\n strategy?: Strategy[];\n\n /**\n * 文字在防重叠计算中预留的边距。\n * @default 0\n */\n overlapPadding?: 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\nexport type PositionStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type BoundStrategy = {\n /**\n * 标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n position?: Functional<LabelPosition[]>;\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 */\n position?: Functional<BoundsAnchorType>;\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?: (\n text: ITextGraphicAttribute,\n attrs: Partial<ILineGraphicAttribute>,\n path: ICustomPath2D\n ) => 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 */\n line2MinLength?: 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 * @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"]}
@@ -6,6 +6,7 @@ export declare class Radio extends AbstractComponent<Required<RadioAttributes>>
6
6
  static defaultAttributes: Partial<RadioAttributes>;
7
7
  _circle: Arc;
8
8
  _text: WrapText;
9
+ name: 'radio';
9
10
  constructor(attributes: RadioAttributes, options?: ComponentOptions);
10
11
  render(): void;
11
12
  renderCircle(): void;
@@ -13,4 +14,5 @@ export declare class Radio extends AbstractComponent<Required<RadioAttributes>>
13
14
  renderGroup(): void;
14
15
  layout(): void;
15
16
  private _handlePointerUp;
17
+ initAttributes(params: RadioAttributes, options?: ComponentOptions): void;
16
18
  }
@@ -53,6 +53,10 @@ class Radio extends base_1.AbstractComponent {
53
53
  y: textY
54
54
  });
55
55
  }
56
+ initAttributes(params, options) {
57
+ params = (null == options ? void 0 : options.skipDefault) ? params : (0, vutils_1.merge)({}, Radio.defaultAttributes, params),
58
+ super.initAttributes(params), this.renderGroup(), this.render();
59
+ }
56
60
  }
57
61
 
58
62
  exports.Radio = Radio, Radio.defaultAttributes = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/radio/radio.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,uCAAiD;AAEjD,yDAAuD;AAEvD,yCAAgD;AAEhD,IAAA,6BAAkB,GAAE,CAAC;AACrB,MAAa,KAAM,SAAQ,wBAA4C;IAmCrE,YAAY,UAA2B,EAAE,OAA0B;QACjE,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;QAgFpF,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,IAA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EAAE,SAAS;IACjB,aAAa,EAAE,aAAa;IAC5B,uBAAuB,EAAE,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,MAAM,EAAE;QACN,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;QACrB,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,kBAAkB;QAC1B,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,kBAAkB;QAC/B,aAAa,EAAE,kBAAkB;QACjC,kBAAkB,EAAE,oBAAoB;QACxC,oBAAoB,EAAE,oBAAoB;QAC1C,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC","file":"radio.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { RadioAttributes } from './type';\nimport { Arc, WrapText } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadRadioComponent } from './register';\n\nloadRadioComponent();\nexport class Radio extends AbstractComponent<Required<RadioAttributes>> {\n static defaultAttributes: Partial<RadioAttributes> = {\n interactive: true,\n disabled: false,\n checked: false,\n cursor: 'pointer',\n disableCursor: 'not-allowed',\n spaceBetweenTextAndIcon: 8,\n text: {\n text: 'text',\n fontSize: 14,\n fill: '#000',\n disableFill: 'rgb(201,205,212)',\n textBaseline: 'top',\n pickable: false\n },\n circle: {\n outerRadius: 7,\n innerRadius: 3,\n startAngle: 0,\n endAngle: 2 * Math.PI,\n lineWidth: 1,\n fill: '#fff',\n stroke: 'rgb(229,230,235)',\n disableFill: 'rgb(242,243,245)',\n checkedFill: 'rgb(22, 93, 255)',\n checkedStroke: 'rgb(22, 93, 255)',\n disableCheckedFill: 'rgb(148, 191, 255)',\n disableCheckedStroke: 'rgb(148, 191, 255)',\n pickable: false\n }\n };\n _circle: Arc;\n _text: WrapText;\n\n constructor(attributes: RadioAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Radio.defaultAttributes, attributes));\n this.renderGroup();\n\n this.onBeforeAttributeUpdate = (val: any, attributes: any, key: null | string | string[]) => {\n if ('interactive' in val) {\n this.setAttribute('pickable', val.interactive);\n }\n if ('disabled' in val) {\n this.setAttribute('cursor', val.disable ? this.attribute.disableCursor : this.attribute.cursor);\n }\n return undefined;\n };\n\n this.addEventListener('pointerup', this._handlePointerUp);\n }\n\n render() {\n this.removeAllChild(true);\n\n this.renderCircle();\n this.renderText();\n this.layout();\n }\n\n renderCircle() {\n this._circle = new Arc(merge({}, this.attribute.circle));\n const isChecked = this.attribute.checked;\n if (isChecked && this.attribute.disabled) {\n this._circle.setAttributes({\n fill: this.attribute.circle.disableCheckedFill,\n stroke: this.attribute.circle.disableCheckedStroke\n });\n } else if (isChecked) {\n this._circle.setAttributes({\n fill: this.attribute.circle.checkedFill,\n stroke: this.attribute.circle.checkedStroke\n });\n }\n this.appendChild(this._circle);\n }\n\n renderText() {\n this._text = new WrapText(merge({}, this.attribute.text));\n if (this.attribute.disabled) {\n this._text.setAttribute('fill', this.attribute.text.disableFill);\n }\n this.appendChild(this._text);\n }\n\n renderGroup() {\n if (!this.attribute.interactive) {\n this.setAttribute('pickable', false);\n }\n if (this.attribute.disabled) {\n this.setAttribute('cursor', this.attribute.disableCursor);\n }\n }\n\n layout() {\n const circleHeight = (this.attribute.circle.outerRadius + this.attribute.circle.lineWidth) * 2;\n const textHeight = this._text.AABBBounds.height();\n const maxHeight = Math.max(circleHeight, textHeight);\n const circleY =\n maxHeight / 2 - circleHeight / 2 + this.attribute.circle.outerRadius + this.attribute.circle.lineWidth;\n const textY = maxHeight / 2 - textHeight / 2;\n\n const circleWidth = (this.attribute.circle.outerRadius + this.attribute.circle.lineWidth) * 2;\n const circleX = this.attribute.circle.outerRadius + this.attribute.circle.lineWidth;\n const textX = circleWidth + this.attribute.spaceBetweenTextAndIcon;\n\n this._circle.setAttributes({\n x: circleX,\n y: circleY\n });\n this._text.setAttributes({\n x: textX,\n y: textY\n });\n }\n\n private _handlePointerUp = () => {\n if (this.attribute.disabled || this.attribute.checked) {\n // checked do nothing\n return;\n }\n this.setAttribute('checked', true);\n\n this._dispatchEvent('radio_checked', {\n eventType: 'radio_checked',\n target: this\n });\n\n this.stage.renderNextFrame();\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/radio/radio.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,uCAAiD;AAEjD,yDAAuD;AAEvD,yCAAgD;AAEhD,IAAA,6BAAkB,GAAE,CAAC;AACrB,MAAa,KAAM,SAAQ,wBAA4C;IAqCrE,YAAY,UAA2B,EAAE,OAA0B;QACjE,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;QAgFpF,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;gBAErD,OAAO;aACR;YACD,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAEnC,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE;gBACnC,SAAS,EAAE,eAAe;gBAC1B,MAAM,EAAE,IAAI;aACb,CAAC,CAAC;YAEH,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC/B,CAAC,CAAC;QA5FA,IAAI,CAAC,WAAW,EAAE,CAAC;QAEnB,IAAI,CAAC,uBAAuB,GAAG,CAAC,GAAQ,EAAE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AE,aAAa;IAC5B,uBAAuB,EAAE,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,MAAM,EAAE;QACN,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;QACrB,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,kBAAkB;QAC1B,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,kBAAkB;QAC/B,aAAa,EAAE,kBAAkB;QACjC,kBAAkB,EAAE,oBAAoB;QACxC,oBAAoB,EAAE,oBAAoB;QAC1C,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC","file":"radio.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { RadioAttributes } from './type';\nimport { Arc, WrapText } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadRadioComponent } from './register';\n\nloadRadioComponent();\nexport class Radio extends AbstractComponent<Required<RadioAttributes>> {\n static defaultAttributes: Partial<RadioAttributes> = {\n interactive: true,\n disabled: false,\n checked: false,\n cursor: 'pointer',\n disableCursor: 'not-allowed',\n spaceBetweenTextAndIcon: 8,\n text: {\n text: 'text',\n fontSize: 14,\n fill: '#000',\n disableFill: 'rgb(201,205,212)',\n textBaseline: 'top',\n pickable: false\n },\n circle: {\n outerRadius: 7,\n innerRadius: 3,\n startAngle: 0,\n endAngle: 2 * Math.PI,\n lineWidth: 1,\n fill: '#fff',\n stroke: 'rgb(229,230,235)',\n disableFill: 'rgb(242,243,245)',\n checkedFill: 'rgb(22, 93, 255)',\n checkedStroke: 'rgb(22, 93, 255)',\n disableCheckedFill: 'rgb(148, 191, 255)',\n disableCheckedStroke: 'rgb(148, 191, 255)',\n pickable: false\n }\n };\n _circle: Arc;\n _text: WrapText;\n\n name: 'radio';\n\n constructor(attributes: RadioAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Radio.defaultAttributes, attributes));\n this.renderGroup();\n\n this.onBeforeAttributeUpdate = (val: any, attributes: any, key: null | string | string[]) => {\n if ('interactive' in val) {\n this.setAttribute('pickable', val.interactive);\n }\n if ('disabled' in val) {\n this.setAttribute('cursor', val.disable ? this.attribute.disableCursor : this.attribute.cursor);\n }\n return undefined;\n };\n\n this.addEventListener('pointerup', this._handlePointerUp);\n }\n\n render() {\n this.removeAllChild(true);\n\n this.renderCircle();\n this.renderText();\n this.layout();\n }\n\n renderCircle() {\n this._circle = new Arc(merge({}, this.attribute.circle));\n const isChecked = this.attribute.checked;\n if (isChecked && this.attribute.disabled) {\n this._circle.setAttributes({\n fill: this.attribute.circle.disableCheckedFill,\n stroke: this.attribute.circle.disableCheckedStroke\n });\n } else if (isChecked) {\n this._circle.setAttributes({\n fill: this.attribute.circle.checkedFill,\n stroke: this.attribute.circle.checkedStroke\n });\n }\n this.appendChild(this._circle);\n }\n\n renderText() {\n this._text = new WrapText(merge({}, this.attribute.text));\n if (this.attribute.disabled) {\n this._text.setAttribute('fill', this.attribute.text.disableFill);\n }\n this.appendChild(this._text);\n }\n\n renderGroup() {\n if (!this.attribute.interactive) {\n this.setAttribute('pickable', false);\n }\n if (this.attribute.disabled) {\n this.setAttribute('cursor', this.attribute.disableCursor);\n }\n }\n\n layout() {\n const circleHeight = (this.attribute.circle.outerRadius + this.attribute.circle.lineWidth) * 2;\n const textHeight = this._text.AABBBounds.height();\n const maxHeight = Math.max(circleHeight, textHeight);\n const circleY =\n maxHeight / 2 - circleHeight / 2 + this.attribute.circle.outerRadius + this.attribute.circle.lineWidth;\n const textY = maxHeight / 2 - textHeight / 2;\n\n const circleWidth = (this.attribute.circle.outerRadius + this.attribute.circle.lineWidth) * 2;\n const circleX = this.attribute.circle.outerRadius + this.attribute.circle.lineWidth;\n const textX = circleWidth + this.attribute.spaceBetweenTextAndIcon;\n\n this._circle.setAttributes({\n x: circleX,\n y: circleY\n });\n this._text.setAttributes({\n x: textX,\n y: textY\n });\n }\n\n private _handlePointerUp = () => {\n if (this.attribute.disabled || this.attribute.checked) {\n // checked do nothing\n return;\n }\n this.setAttribute('checked', true);\n\n this._dispatchEvent('radio_checked', {\n eventType: 'radio_checked',\n target: this\n });\n\n this.stage.renderNextFrame();\n };\n\n initAttributes(params: RadioAttributes, options?: ComponentOptions) {\n params = options?.skipDefault ? params : merge({}, Radio.defaultAttributes, params);\n super.initAttributes(params);\n this.renderGroup();\n this.render();\n }\n}\n"]}
package/cjs/tag/tag.d.ts CHANGED
@@ -6,9 +6,19 @@ export declare class Tag extends AbstractComponent<Required<TagAttributes>> {
6
6
  name: string;
7
7
  private _bgRect;
8
8
  private _textShape;
9
+ private _symbol;
10
+ private _tagStates;
11
+ private _rectStates;
12
+ private _symbolStates;
13
+ private _textStates;
9
14
  getBgRect(): IRect;
10
15
  getTextShape(): IRichText | IText;
11
16
  static defaultAttributes: Partial<TagAttributes>;
12
17
  constructor(attributes: TagAttributes, options?: ComponentOptions);
13
18
  protected render(): void;
19
+ initAttributes(params: TagAttributes, options?: ComponentOptions): void;
20
+ addState(stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean): void;
21
+ removeState(stateName: string, hasAnimation?: boolean): void;
22
+ cacheStates(): void;
23
+ resetStates(): void;
14
24
  }
package/cjs/tag/tag.js CHANGED
@@ -27,10 +27,12 @@ class Tag extends base_1.AbstractComponent {
27
27
  }
28
28
  constructor(attributes, options) {
29
29
  super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, Tag.defaultAttributes, attributes)),
30
- this.name = "tag";
30
+ this.name = "tag", this._tagStates = [], this._rectStates = [], this._symbolStates = [],
31
+ this._textStates = [];
31
32
  }
32
33
  render() {
33
34
  var _a, _b, _c;
35
+ this.cacheStates();
34
36
  const {text: text = "", textStyle: textStyle = {}, shape: shape = {}, panel: panel = {}, space: space = 4, minWidth: minWidth, maxWidth: maxWidth, padding: padding = 4, visible: visible, state: state, type: type, textAlwaysCenter: textAlwaysCenter, containerTextAlign: containerTextAlign} = this.attribute, parsedPadding = (0,
35
37
  vutils_1.normalizePadding)(padding), group = this.createOrUpdateChild("tag-content", {
36
38
  x: 0,
@@ -165,7 +167,35 @@ class Tag extends base_1.AbstractComponent {
165
167
  this._bgRect = bgRect;
166
168
  }
167
169
  }
168
- this._textShape = textShape;
170
+ this._textShape = textShape, this._symbol = symbol, this.resetStates();
171
+ }
172
+ initAttributes(params, options) {
173
+ params = (null == options ? void 0 : options.skipDefault) ? params : (0, vutils_1.merge)({}, Tag.defaultAttributes, params),
174
+ super.initAttributes(params), this.render();
175
+ }
176
+ addState(stateName, keepCurrentStates, hasAnimation) {
177
+ super.addState(stateName, keepCurrentStates, hasAnimation), this._textShape && this._textShape.addState(stateName, keepCurrentStates, hasAnimation),
178
+ this._bgRect && this._bgRect.addState(stateName, keepCurrentStates, hasAnimation),
179
+ this._symbol && this._symbol.addState(stateName, keepCurrentStates, hasAnimation);
180
+ }
181
+ removeState(stateName, hasAnimation) {
182
+ super.removeState(stateName, hasAnimation), this._textShape && this._textShape.removeState(stateName, hasAnimation),
183
+ this._bgRect && this._bgRect.removeState(stateName, hasAnimation), this._symbol && this._symbol.removeState(stateName, hasAnimation);
184
+ }
185
+ cacheStates() {
186
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
187
+ this._tagStates = null !== (_b = null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.slice()) && void 0 !== _b ? _b : [],
188
+ this._rectStates = null !== (_e = null === (_d = null === (_c = this._bgRect) || void 0 === _c ? void 0 : _c.currentStates) || void 0 === _d ? void 0 : _d.slice()) && void 0 !== _e ? _e : [],
189
+ this._symbolStates = null !== (_h = null === (_g = null === (_f = this._symbol) || void 0 === _f ? void 0 : _f.currentStates) || void 0 === _g ? void 0 : _g.slice()) && void 0 !== _h ? _h : [],
190
+ this._textStates = null !== (_l = null === (_k = null === (_j = this._textShape) || void 0 === _j ? void 0 : _j.currentStates) || void 0 === _k ? void 0 : _k.slice()) && void 0 !== _l ? _l : [],
191
+ this.clearStates(), null === (_m = this._bgRect) || void 0 === _m || _m.clearStates(),
192
+ null === (_o = this._symbol) || void 0 === _o || _o.clearStates(), null === (_p = this._textShape) || void 0 === _p || _p.clearStates();
193
+ }
194
+ resetStates() {
195
+ var _a, _b, _c;
196
+ this._tagStates.length && this.useStates(this._tagStates), this._rectStates.length && (null === (_a = this._bgRect) || void 0 === _a || _a.useStates(this._rectStates)),
197
+ this._symbolStates.length && (null === (_b = this._symbol) || void 0 === _b || _b.useStates(this._symbolStates)),
198
+ this._textStates.length && (null === (_c = this._textShape) || void 0 === _c || _c.useStates(this._textStates));
169
199
  }
170
200
  }
171
201
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tag/tag.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,yDAWgC;AAChC,6CAAmH;AACnH,uCAAiD;AACjD,kCAAkF;AAGlF,yCAA8C;AAG9C,IAAA,2BAAgB,GAAE,CAAC;AACnB,MAAa,GAAI,SAAQ,wBAA0C;IAMjE,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAkBD,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,GAAG,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QA9B1F,SAAI,GAAG,KAAK,CAAC;IA+Bb,CAAC;IAES,MAAM;;QACd,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AC1B,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;iBAC7B;gBACD,IAAI,eAAe,CAAC,WAAW,EAAE;oBAC/B,MAAM,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC;oBAChD,MAAM,CAAC,SAAS,GAAG,CAAC,KAAiC,EAAE,EAAE;wBACvD,OAAO,WAAW,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,2BAAY,EAAE,CAAC,CAAC;oBACrE,CAAC,CAAC;iBACH;gBACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;aACvB;SACF;QACD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;;AAjTH,kBAkTC;AApSQ,qBAAiB,GAA2B;IACjD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IAEV,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;KACb;CACF,CAAC","file":"tag.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport {\n type IGroup,\n type IRect,\n type ISymbol,\n type IText,\n type ITextAttribute,\n type ITextGraphicAttribute,\n type IRichTextGraphicAttribute,\n type IRichText,\n type IGraphicAttribute,\n CustomPath2D\n} from '@visactor/vrender-core';\nimport { isBoolean, isEmpty, isNil, isNumber, isObject, isValid, merge, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { isRichText, measureTextSize, richTextAttributeTransform } from '../util';\nimport type { BackgroundAttributes, ComponentOptions } from '../interface';\nimport type { TagAttributes, TagShapeAttributes } from './type';\nimport { loadTagComponent } from './register';\nimport type { TextContent } from '../core/type';\n\nloadTagComponent();\nexport class Tag extends AbstractComponent<Required<TagAttributes>> {\n name = 'tag';\n\n private _bgRect!: IRect;\n private _textShape!: IText | IRichText;\n\n getBgRect() {\n return this._bgRect;\n }\n\n getTextShape() {\n return this._textShape;\n }\n\n static defaultAttributes: Partial<TagAttributes> = {\n visible: true,\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n space: 4,\n padding: 4,\n // @ts-ignore\n shape: {\n fill: '#000'\n }\n };\n\n constructor(attributes: TagAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Tag.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n text = '',\n textStyle = {} as ITextGraphicAttribute | IRichTextGraphicAttribute,\n shape = {} as TagShapeAttributes,\n panel = {} as BackgroundAttributes,\n space = 4,\n minWidth,\n maxWidth,\n padding = 4,\n visible,\n state,\n type,\n textAlwaysCenter,\n containerTextAlign\n } = this.attribute as TagAttributes;\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n let symbol;\n let tagWidth = parsedPadding[1] + parsedPadding[3];\n let tagHeight = parsedPadding[0] + parsedPadding[2];\n let textX = 0;\n let symbolPlaceWidth = 0;\n const { visible: shapeVisible, ...shapeStyle } = shape;\n if (isBoolean(shapeVisible)) {\n const size = shapeStyle?.size || 10;\n const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1])) as number;\n\n symbol = group.createOrUpdateChild(\n 'tag-shape',\n {\n symbolType: 'circle',\n size,\n strokeBoundsBuffer: 0,\n ...shapeStyle,\n visible: shapeVisible,\n x: maxSize / 2,\n y: maxSize / 2\n },\n 'symbol'\n ) as ISymbol;\n if (!isEmpty(state?.shape)) {\n symbol.states = state.shape;\n }\n\n if (shapeVisible) {\n symbolPlaceWidth = maxSize + space;\n }\n }\n\n tagWidth += symbolPlaceWidth;\n textX += symbolPlaceWidth;\n\n let textShape: IRichText | IText;\n const isRich = isRichText({ text } as TextContent) || type === 'rich';\n if (isRich) {\n const richTextAttrs = {\n ...richTextAttributeTransform({ type, text, ...textStyle } as any),\n ...(textStyle as IRichTextGraphicAttribute),\n visible: isValid(text) && visible !== false,\n x: textX,\n y: 0\n };\n textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext') as IRichText;\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x: textShape.AABBBounds.x1,\n y: textShape.AABBBounds.y1,\n width: textShape.AABBBounds.width(),\n height: textShape.AABBBounds.height()\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n if (backgroundStyle.customShape) {\n const customShape = backgroundStyle.customShape;\n bgRect.pathProxy = (attrs: Partial<IGraphicAttribute>) => {\n return customShape(textShape.attribute, attrs, new CustomPath2D());\n };\n }\n this._bgRect = bgRect;\n }\n } else {\n const textAttrs = {\n text: isObject(text) && 'type' in text && text.type === 'text' ? text.text : text,\n visible: isValid(text) && visible !== false,\n lineHeight: (textStyle as ITextGraphicAttribute)?.fontSize,\n ...(textStyle as ITextGraphicAttribute),\n x: textX,\n y: 0\n };\n if (isNil(textAttrs.lineHeight)) {\n textAttrs.lineHeight = (textStyle as ITextGraphicAttribute).fontSize;\n }\n textShape = group.createOrUpdateChild('tag-text', textAttrs as ITextGraphicAttribute, 'text') as IText;\n if (!isEmpty(state?.text)) {\n textShape.states = state.text;\n }\n\n // 因为文本可能发生旋转,所以需要使用 measureTextSize 方法\n const textBounds = measureTextSize(textAttrs.text as string, textStyle, this.stage?.getTheme()?.text);\n const textWidth = textBounds.width;\n const textHeight = textBounds.height;\n tagWidth += textWidth;\n const size = shape.size ?? 10;\n const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1])) as number;\n tagHeight += Math.max(textHeight, shape.visible ? maxSize : 0);\n\n const { textAlign, textBaseline } = textStyle as ITextAttribute;\n\n if (isValid(minWidth) || isValid(maxWidth)) {\n if (isValid(minWidth) && tagWidth < minWidth) {\n tagWidth = minWidth;\n }\n if (isValid(maxWidth) && tagWidth > maxWidth) {\n tagWidth = maxWidth;\n textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);\n }\n }\n\n let x = 0;\n let y = 0;\n let flag = 0;\n if (textAlign === 'left' || textAlign === 'start') {\n flag = 1;\n } else if (textAlign === 'right' || textAlign === 'end') {\n flag = -1;\n } else if (textAlign === 'center') {\n flag = 0;\n }\n if (!flag) {\n x -= tagWidth / 2;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);\n }\n\n group.setAttribute('x', -symbolPlaceWidth / 2);\n } else if (flag < 0) {\n x -= tagWidth;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);\n }\n\n group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);\n } else if (flag > 0) {\n group.setAttribute('x', parsedPadding[3]);\n }\n\n const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;\n const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';\n const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';\n\n if (shouldCenter && flag) {\n // 文本容器内居中\n // 剔除padding后的内宽度\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const tsWidth = textWidth + symbolPlaceWidth;\n const textX =\n flag === 1\n ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2\n : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'center'\n });\n if (symbol) {\n const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (shouldLeft && flag !== 1) {\n // 文本容器内朝左展示\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const offset =\n flag === 0\n ? -containerWidth / 2 + symbolPlaceWidth / 2\n : -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;\n const textX = offset + symbolPlaceWidth;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'left'\n });\n\n if (symbol) {\n const symbolX = offset + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (shouldRight && flag !== -1) {\n // 文本容器内朝右展示\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const textX = flag === 0 ? containerWidth / 2 + symbolPlaceWidth / 2 : containerWidth;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'right'\n });\n if (symbol) {\n const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (textBaseline === 'middle') {\n y -= tagHeight / 2;\n if (symbol) {\n symbol.setAttribute('y', 0);\n }\n } else if (textBaseline === 'bottom') {\n y -= tagHeight;\n if (symbol) {\n symbol.setAttribute('y', -textHeight / 2);\n }\n\n group.setAttribute('y', -parsedPadding[2]);\n } else if (textBaseline === 'top') {\n group.setAttribute('y', parsedPadding[0]);\n if (symbol) {\n symbol.setAttribute('y', textHeight / 2);\n }\n }\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x,\n y,\n width: tagWidth,\n height: tagHeight\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n if (backgroundStyle.customShape) {\n const customShape = backgroundStyle.customShape;\n bgRect.pathProxy = (attrs: Partial<IGraphicAttribute>) => {\n return customShape(textShape.attribute, attrs, new CustomPath2D());\n };\n }\n this._bgRect = bgRect;\n }\n }\n this._textShape = textShape;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/tag/tag.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AAA,CAAC;IAC1E,CAAC;;AA3WH,kBA4WC;AAzVQ,qBAAiB,GAA2B;IACjD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IAEV,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;KACb;CACF,CAAC","file":"tag.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport {\n type IGroup,\n type IRect,\n type ISymbol,\n type IText,\n type ITextAttribute,\n type ITextGraphicAttribute,\n type IRichTextGraphicAttribute,\n type IRichText,\n type IGraphicAttribute,\n CustomPath2D\n} from '@visactor/vrender-core';\nimport { isBoolean, isEmpty, isNil, isNumber, isObject, isValid, merge, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { isRichText, measureTextSize, richTextAttributeTransform } from '../util';\nimport type { BackgroundAttributes, ComponentOptions } from '../interface';\nimport type { TagAttributes, TagShapeAttributes } from './type';\nimport { loadTagComponent } from './register';\nimport type { TextContent } from '../core/type';\n\nloadTagComponent();\nexport class Tag extends AbstractComponent<Required<TagAttributes>> {\n name = 'tag';\n\n private _bgRect!: IRect;\n private _textShape!: IText | IRichText;\n private _symbol!: ISymbol;\n private _tagStates: string[] = [];\n private _rectStates: string[] = [];\n private _symbolStates: string[] = [];\n private _textStates: string[] = [];\n\n getBgRect() {\n return this._bgRect;\n }\n\n getTextShape() {\n return this._textShape;\n }\n\n static defaultAttributes: Partial<TagAttributes> = {\n visible: true,\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n space: 4,\n padding: 4,\n // @ts-ignore\n shape: {\n fill: '#000'\n }\n };\n\n constructor(attributes: TagAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Tag.defaultAttributes, attributes));\n }\n\n protected render() {\n this.cacheStates();\n const {\n text = '',\n textStyle = {} as ITextGraphicAttribute | IRichTextGraphicAttribute,\n shape = {} as TagShapeAttributes,\n panel = {} as BackgroundAttributes,\n space = 4,\n minWidth,\n maxWidth,\n padding = 4,\n visible,\n state,\n type,\n textAlwaysCenter,\n containerTextAlign\n } = this.attribute as TagAttributes;\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n let symbol;\n let tagWidth = parsedPadding[1] + parsedPadding[3];\n let tagHeight = parsedPadding[0] + parsedPadding[2];\n let textX = 0;\n let symbolPlaceWidth = 0;\n const { visible: shapeVisible, ...shapeStyle } = shape;\n if (isBoolean(shapeVisible)) {\n const size = shapeStyle?.size || 10;\n const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1])) as number;\n\n symbol = group.createOrUpdateChild(\n 'tag-shape',\n {\n symbolType: 'circle',\n size,\n strokeBoundsBuffer: 0,\n ...shapeStyle,\n visible: shapeVisible,\n x: maxSize / 2,\n y: maxSize / 2\n },\n 'symbol'\n ) as ISymbol;\n if (!isEmpty(state?.shape)) {\n symbol.states = state.shape;\n }\n\n if (shapeVisible) {\n symbolPlaceWidth = maxSize + space;\n }\n }\n\n tagWidth += symbolPlaceWidth;\n textX += symbolPlaceWidth;\n\n let textShape: IRichText | IText;\n const isRich = isRichText({ text } as TextContent) || type === 'rich';\n if (isRich) {\n const richTextAttrs = {\n ...richTextAttributeTransform({ type, text, ...textStyle } as any),\n ...(textStyle as IRichTextGraphicAttribute),\n visible: isValid(text) && visible !== false,\n x: textX,\n y: 0\n };\n textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext') as IRichText;\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x: textShape.AABBBounds.x1,\n y: textShape.AABBBounds.y1,\n width: textShape.AABBBounds.width(),\n height: textShape.AABBBounds.height()\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n if (backgroundStyle.customShape) {\n const customShape = backgroundStyle.customShape;\n bgRect.pathProxy = (attrs: Partial<IGraphicAttribute>) => {\n return customShape(textShape.attribute, attrs, new CustomPath2D());\n };\n }\n this._bgRect = bgRect;\n }\n } else {\n const textAttrs = {\n text: isObject(text) && 'type' in text && text.type === 'text' ? text.text : text,\n visible: isValid(text) && visible !== false,\n lineHeight: (textStyle as ITextGraphicAttribute)?.fontSize,\n ...(textStyle as ITextGraphicAttribute),\n x: textX,\n y: 0\n };\n if (isNil(textAttrs.lineHeight)) {\n textAttrs.lineHeight = (textStyle as ITextGraphicAttribute).fontSize;\n }\n textShape = group.createOrUpdateChild('tag-text', textAttrs as ITextGraphicAttribute, 'text') as IText;\n if (!isEmpty(state?.text)) {\n textShape.states = state.text;\n }\n\n // 因为文本可能发生旋转,所以需要使用 measureTextSize 方法\n const textBounds = measureTextSize(textAttrs.text as string, textStyle, this.stage?.getTheme()?.text);\n const textWidth = textBounds.width;\n const textHeight = textBounds.height;\n tagWidth += textWidth;\n const size = shape.size ?? 10;\n const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1])) as number;\n tagHeight += Math.max(textHeight, shape.visible ? maxSize : 0);\n\n const { textAlign, textBaseline } = textStyle as ITextAttribute;\n\n if (isValid(minWidth) || isValid(maxWidth)) {\n if (isValid(minWidth) && tagWidth < minWidth) {\n tagWidth = minWidth;\n }\n if (isValid(maxWidth) && tagWidth > maxWidth) {\n tagWidth = maxWidth;\n textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);\n }\n }\n\n let x = 0;\n let y = 0;\n let flag = 0;\n if (textAlign === 'left' || textAlign === 'start') {\n flag = 1;\n } else if (textAlign === 'right' || textAlign === 'end') {\n flag = -1;\n } else if (textAlign === 'center') {\n flag = 0;\n }\n if (!flag) {\n x -= tagWidth / 2;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);\n }\n\n group.setAttribute('x', -symbolPlaceWidth / 2);\n } else if (flag < 0) {\n x -= tagWidth;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);\n }\n\n group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);\n } else if (flag > 0) {\n group.setAttribute('x', parsedPadding[3]);\n }\n\n const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;\n const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';\n const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';\n\n if (shouldCenter && flag) {\n // 文本容器内居中\n // 剔除padding后的内宽度\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const tsWidth = textWidth + symbolPlaceWidth;\n const textX =\n flag === 1\n ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2\n : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'center'\n });\n if (symbol) {\n const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (shouldLeft && flag !== 1) {\n // 文本容器内朝左展示\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const offset =\n flag === 0\n ? -containerWidth / 2 + symbolPlaceWidth / 2\n : -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;\n const textX = offset + symbolPlaceWidth;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'left'\n });\n\n if (symbol) {\n const symbolX = offset + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (shouldRight && flag !== -1) {\n // 文本容器内朝右展示\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const textX = flag === 0 ? containerWidth / 2 + symbolPlaceWidth / 2 : containerWidth;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'right'\n });\n if (symbol) {\n const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (textBaseline === 'middle') {\n y -= tagHeight / 2;\n if (symbol) {\n symbol.setAttribute('y', 0);\n }\n } else if (textBaseline === 'bottom') {\n y -= tagHeight;\n if (symbol) {\n symbol.setAttribute('y', -textHeight / 2);\n }\n\n group.setAttribute('y', -parsedPadding[2]);\n } else if (textBaseline === 'top') {\n group.setAttribute('y', parsedPadding[0]);\n if (symbol) {\n symbol.setAttribute('y', textHeight / 2);\n }\n }\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x,\n y,\n width: tagWidth,\n height: tagHeight\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n if (backgroundStyle.customShape) {\n const customShape = backgroundStyle.customShape;\n bgRect.pathProxy = (attrs: Partial<IGraphicAttribute>) => {\n return customShape(textShape.attribute, attrs, new CustomPath2D());\n };\n }\n this._bgRect = bgRect;\n }\n }\n this._textShape = textShape;\n this._symbol = symbol;\n\n this.resetStates();\n }\n\n initAttributes(params: TagAttributes, options?: ComponentOptions) {\n params = options?.skipDefault ? params : merge({}, Tag.defaultAttributes, params);\n super.initAttributes(params);\n this.render();\n }\n\n addState(stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean): void {\n super.addState(stateName, keepCurrentStates, hasAnimation);\n if (this._textShape) {\n this._textShape.addState(stateName, keepCurrentStates, hasAnimation);\n }\n if (this._bgRect) {\n this._bgRect.addState(stateName, keepCurrentStates, hasAnimation);\n }\n if (this._symbol) {\n this._symbol.addState(stateName, keepCurrentStates, hasAnimation);\n }\n }\n\n removeState(stateName: string, hasAnimation?: boolean): void {\n super.removeState(stateName, hasAnimation);\n if (this._textShape) {\n this._textShape.removeState(stateName, hasAnimation);\n }\n if (this._bgRect) {\n this._bgRect.removeState(stateName, hasAnimation);\n }\n if (this._symbol) {\n this._symbol.removeState(stateName, hasAnimation);\n }\n }\n\n cacheStates() {\n this._tagStates = this.currentStates?.slice() ?? [];\n this._rectStates = this._bgRect?.currentStates?.slice() ?? [];\n this._symbolStates = this._symbol?.currentStates?.slice() ?? [];\n this._textStates = this._textShape?.currentStates?.slice() ?? [];\n this.clearStates();\n this._bgRect?.clearStates();\n this._symbol?.clearStates();\n this._textShape?.clearStates();\n }\n resetStates() {\n this._tagStates.length && this.useStates(this._tagStates);\n this._rectStates.length && this._bgRect?.useStates(this._rectStates);\n this._symbolStates.length && this._symbol?.useStates(this._symbolStates);\n this._textStates.length && this._textShape?.useStates(this._textStates);\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -4343,7 +4343,7 @@ class ResourceLoader {
4343
4343
  var _a;
4344
4344
  data.loadState = (null == res ? void 0 : res.data) ? "success" : "fail", data.data = null == res ? void 0 : res.data, null === (_a = data.waitingMark) || void 0 === _a || _a.map((mark, index) => {
4345
4345
  (null == res ? void 0 : res.data) ? (data.loadState = "success", data.data = res.data, mark.imageLoadSuccess(svgStr, res.data)) : (data.loadState = "fail", mark.imageLoadFail(svgStr));
4346
- });
4346
+ }), data.waitingMark && (data.waitingMark = []);
4347
4347
  })) : (data.loadState = "fail", mark.imageLoadFail(svgStr)));
4348
4348
  }
4349
4349
  static GetFile(url, type) {
@@ -4374,7 +4374,7 @@ class ResourceLoader {
4374
4374
  var _a;
4375
4375
  data.loadState = (null == res ? void 0 : res.data) ? "success" : "fail", data.data = null == res ? void 0 : res.data, null === (_a = data.waitingMark) || void 0 === _a || _a.map((mark, index) => {
4376
4376
  (null == res ? void 0 : res.data) ? (data.loadState = "success", data.data = res.data, mark.imageLoadSuccess(url, res.data)) : (data.loadState = "fail", mark.imageLoadFail(url));
4377
- });
4377
+ }), data.waitingMark && (data.waitingMark = []);
4378
4378
  });
4379
4379
  promises.push(end);
4380
4380
  } else data.loadState = "fail", marks.forEach(mark => mark.imageLoadFail(url));
@@ -14734,9 +14734,14 @@ class Tag extends AbstractComponent {
14734
14734
  constructor(attributes, options) {
14735
14735
  super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, Tag.defaultAttributes, attributes));
14736
14736
  this.name = 'tag';
14737
+ this._tagStates = [];
14738
+ this._rectStates = [];
14739
+ this._symbolStates = [];
14740
+ this._textStates = [];
14737
14741
  }
14738
14742
  render() {
14739
14743
  var _a, _b, _c;
14744
+ this.cacheStates();
14740
14745
  const { text = '', textStyle = {}, shape = {}, panel = {}, space = 4, minWidth, maxWidth, padding = 4, visible, state, type, textAlwaysCenter, containerTextAlign } = this.attribute;
14741
14746
  const parsedPadding = normalizePadding(padding);
14742
14747
  const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group');
@@ -14921,6 +14926,55 @@ class Tag extends AbstractComponent {
14921
14926
  }
14922
14927
  }
14923
14928
  this._textShape = textShape;
14929
+ this._symbol = symbol;
14930
+ this.resetStates();
14931
+ }
14932
+ initAttributes(params, options) {
14933
+ params = (options === null || options === void 0 ? void 0 : options.skipDefault) ? params : merge({}, Tag.defaultAttributes, params);
14934
+ super.initAttributes(params);
14935
+ this.render();
14936
+ }
14937
+ addState(stateName, keepCurrentStates, hasAnimation) {
14938
+ super.addState(stateName, keepCurrentStates, hasAnimation);
14939
+ if (this._textShape) {
14940
+ this._textShape.addState(stateName, keepCurrentStates, hasAnimation);
14941
+ }
14942
+ if (this._bgRect) {
14943
+ this._bgRect.addState(stateName, keepCurrentStates, hasAnimation);
14944
+ }
14945
+ if (this._symbol) {
14946
+ this._symbol.addState(stateName, keepCurrentStates, hasAnimation);
14947
+ }
14948
+ }
14949
+ removeState(stateName, hasAnimation) {
14950
+ super.removeState(stateName, hasAnimation);
14951
+ if (this._textShape) {
14952
+ this._textShape.removeState(stateName, hasAnimation);
14953
+ }
14954
+ if (this._bgRect) {
14955
+ this._bgRect.removeState(stateName, hasAnimation);
14956
+ }
14957
+ if (this._symbol) {
14958
+ this._symbol.removeState(stateName, hasAnimation);
14959
+ }
14960
+ }
14961
+ cacheStates() {
14962
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
14963
+ this._tagStates = (_b = (_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
14964
+ this._rectStates = (_e = (_d = (_c = this._bgRect) === null || _c === void 0 ? void 0 : _c.currentStates) === null || _d === void 0 ? void 0 : _d.slice()) !== null && _e !== void 0 ? _e : [];
14965
+ this._symbolStates = (_h = (_g = (_f = this._symbol) === null || _f === void 0 ? void 0 : _f.currentStates) === null || _g === void 0 ? void 0 : _g.slice()) !== null && _h !== void 0 ? _h : [];
14966
+ this._textStates = (_l = (_k = (_j = this._textShape) === null || _j === void 0 ? void 0 : _j.currentStates) === null || _k === void 0 ? void 0 : _k.slice()) !== null && _l !== void 0 ? _l : [];
14967
+ this.clearStates();
14968
+ (_m = this._bgRect) === null || _m === void 0 ? void 0 : _m.clearStates();
14969
+ (_o = this._symbol) === null || _o === void 0 ? void 0 : _o.clearStates();
14970
+ (_p = this._textShape) === null || _p === void 0 ? void 0 : _p.clearStates();
14971
+ }
14972
+ resetStates() {
14973
+ var _a, _b, _c;
14974
+ this._tagStates.length && this.useStates(this._tagStates);
14975
+ this._rectStates.length && ((_a = this._bgRect) === null || _a === void 0 ? void 0 : _a.useStates(this._rectStates));
14976
+ this._symbolStates.length && ((_b = this._symbol) === null || _b === void 0 ? void 0 : _b.useStates(this._symbolStates));
14977
+ this._textStates.length && ((_c = this._textShape) === null || _c === void 0 ? void 0 : _c.useStates(this._textStates));
14924
14978
  }
14925
14979
  }
14926
14980
  Tag.defaultAttributes = {
@@ -16071,7 +16125,8 @@ class LabelBase extends AbstractComponent {
16071
16125
  this._bmpTool = bmpTool;
16072
16126
  }
16073
16127
  constructor(attributes, options) {
16074
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, LabelBase.defaultAttributes, attributes));
16128
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16129
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, LabelBase.defaultAttributes, restAttributes)));
16075
16130
  this.name = 'label';
16076
16131
  this._onHover = (e) => {
16077
16132
  const target = e.target;
@@ -16773,7 +16828,8 @@ const getLabelComponent = (type) => {
16773
16828
 
16774
16829
  class SymbolLabel extends LabelBase {
16775
16830
  constructor(attributes, options) {
16776
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, SymbolLabel.defaultAttributes, attributes));
16831
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16832
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, SymbolLabel.defaultAttributes, restAttributes)));
16777
16833
  this.name = 'symbol-label';
16778
16834
  }
16779
16835
  labeling(textBounds, graphicBounds, position = 'top', offset = 0) {
@@ -16794,7 +16850,8 @@ const registerSymbolDataLabel = () => {
16794
16850
 
16795
16851
  class RectLabel extends LabelBase {
16796
16852
  constructor(attributes, options) {
16797
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, RectLabel.defaultAttributes, attributes));
16853
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16854
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, RectLabel.defaultAttributes, restAttributes)));
16798
16855
  }
16799
16856
  labeling(textBounds, graphicBounds, position = 'top', offset = 0) {
16800
16857
  if (!textBounds || !graphicBounds) {
@@ -16848,7 +16905,8 @@ const registerRectDataLabel = () => {
16848
16905
 
16849
16906
  class LineLabel extends LabelBase {
16850
16907
  constructor(attributes, options) {
16851
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, LineLabel.defaultAttributes, attributes));
16908
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16909
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, LineLabel.defaultAttributes, restAttributes)));
16852
16910
  this.name = 'line-label';
16853
16911
  }
16854
16912
  getGraphicBounds(graphic, point = {}, position = 'end') {
@@ -16921,7 +16979,8 @@ class ArcInfo {
16921
16979
  }
16922
16980
  class ArcLabel extends LabelBase {
16923
16981
  constructor(attributes, options) {
16924
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, ArcLabel.defaultAttributes, attributes));
16982
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16983
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, ArcLabel.defaultAttributes, restAttributes)));
16925
16984
  this.name = 'arc-label';
16926
16985
  this._ellipsisWidth = 0;
16927
16986
  this._arcLeft = new Map();
@@ -17018,6 +17077,7 @@ class ArcLabel extends LabelBase {
17018
17077
  case 'inside':
17019
17078
  case 'inside-inner':
17020
17079
  case 'inside-outer':
17080
+ case 'inside-center':
17021
17081
  arcs.push(...this._layoutInsideLabels(rightArcs, attribute, currentMarks));
17022
17082
  arcs.push(...this._layoutInsideLabels(leftArcs, attribute, currentMarks));
17023
17083
  break;
@@ -17070,6 +17130,9 @@ class ArcLabel extends LabelBase {
17070
17130
  if (position === 'inside-inner') {
17071
17131
  labelRadius = innerRadius - offsetRadius + alignOffset;
17072
17132
  }
17133
+ else if (position === 'inside-center') {
17134
+ labelRadius = innerRadius + (outerRadius - innerRadius) / 2;
17135
+ }
17073
17136
  else {
17074
17137
  labelRadius = outerRadius + offsetRadius - alignOffset;
17075
17138
  }
@@ -17602,7 +17665,7 @@ class ArcLabel extends LabelBase {
17602
17665
  return Math.min(width / 2, height / 2);
17603
17666
  }
17604
17667
  _canPlaceInside(textBound, shapeBound) {
17605
- return this.attribute.position === 'inside';
17668
+ return this.attribute.position === 'inside' || this.attribute.position === 'inside-center';
17606
17669
  }
17607
17670
  computeLayoutOuterRadius(r, width, height) {
17608
17671
  return r / (Math.min(width, height) / 2);
@@ -17642,7 +17705,8 @@ const registerArcDataLabel = () => {
17642
17705
 
17643
17706
  class DataLabel extends AbstractComponent {
17644
17707
  constructor(attributes, options) {
17645
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, DataLabel.defaultAttributes, attributes));
17708
+ const { dataLabels } = attributes, restAttributes = __rest(attributes, ["dataLabels"]);
17709
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ dataLabels }, merge({}, DataLabel.defaultAttributes, restAttributes)));
17646
17710
  this.name = 'data-label';
17647
17711
  }
17648
17712
  render() {
@@ -28291,6 +28355,12 @@ class CheckBox extends AbstractComponent {
28291
28355
  y: textY
28292
28356
  });
28293
28357
  }
28358
+ initAttributes(params, options) {
28359
+ params = (options === null || options === void 0 ? void 0 : options.skipDefault) ? params : merge({}, CheckBox.defaultAttributes, params);
28360
+ super.initAttributes(params);
28361
+ this.renderGroup();
28362
+ this.render();
28363
+ }
28294
28364
  }
28295
28365
  CheckBox.defaultAttributes = {
28296
28366
  interactive: true,
@@ -28420,6 +28490,12 @@ class Radio extends AbstractComponent {
28420
28490
  y: textY
28421
28491
  });
28422
28492
  }
28493
+ initAttributes(params, options) {
28494
+ params = (options === null || options === void 0 ? void 0 : options.skipDefault) ? params : merge({}, Radio.defaultAttributes, params);
28495
+ super.initAttributes(params);
28496
+ this.renderGroup();
28497
+ this.render();
28498
+ }
28423
28499
  }
28424
28500
  Radio.defaultAttributes = {
28425
28501
  interactive: true,
@@ -28509,6 +28585,6 @@ EmptyTip.defaultAttributes = {
28509
28585
  }
28510
28586
  };
28511
28587
 
28512
- const version = "0.20.1-alpha.5";
28588
+ const version = "0.20.1";
28513
28589
 
28514
28590
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
package/es/axis/util.js CHANGED
@@ -81,4 +81,5 @@ export function getPolygonPath(points, closed) {
81
81
  return 0 === points.length || (points.forEach(((point, index) => {
82
82
  0 === index ? path = `M${point.x},${point.y}` : path += `L${point.x},${point.y}`;
83
83
  })), closed && (path += "Z")), path;
84
- }
84
+ }
85
+ //# sourceMappingURL=util.js.map
package/es/brush/type.js CHANGED
@@ -4,5 +4,4 @@ export var IOperateType;
4
4
  IOperateType.drawStart = "drawStart", IOperateType.drawEnd = "drawEnd", IOperateType.drawing = "drawing",
5
5
  IOperateType.moving = "moving", IOperateType.moveStart = "moveStart", IOperateType.moveEnd = "moveEnd",
6
6
  IOperateType.brushClear = "brushClear";
7
- }(IOperateType || (IOperateType = {}));
8
- //# sourceMappingURL=type.js.map
7
+ }(IOperateType || (IOperateType = {}));
@@ -8,6 +8,7 @@ export declare class CheckBox extends AbstractComponent<Required<CheckboxAttribu
8
8
  _checkIcon: Image;
9
9
  _indeterminateIcon: Image;
10
10
  _text: Text;
11
+ name: 'checkbox';
11
12
  constructor(attributes: CheckboxAttributes, options?: ComponentOptions);
12
13
  render(): void;
13
14
  renderBox(): void;
@@ -16,4 +17,5 @@ export declare class CheckBox extends AbstractComponent<Required<CheckboxAttribu
16
17
  renderGroup(): void;
17
18
  layout(): void;
18
19
  private _handlePointerUp;
20
+ initAttributes(params: CheckboxAttributes, options?: ComponentOptions): void;
19
21
  }
@@ -74,6 +74,10 @@ export class CheckBox extends AbstractComponent {
74
74
  y: textY
75
75
  });
76
76
  }
77
+ initAttributes(params, options) {
78
+ params = (null == options ? void 0 : options.skipDefault) ? params : merge({}, CheckBox.defaultAttributes, params),
79
+ super.initAttributes(params), this.renderGroup(), this.render();
80
+ }
77
81
  }
78
82
 
79
83
  CheckBox.defaultAttributes = {