@visactor/vrender-components 0.16.17-alpha.3 → 0.16.17-alpha.8

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 (107) hide show
  1. package/cjs/axis/base.js +7 -11
  2. package/cjs/axis/base.js.map +1 -1
  3. package/cjs/axis/circle.d.ts +1 -2
  4. package/cjs/axis/circle.js.map +1 -1
  5. package/cjs/axis/type.d.ts +6 -10
  6. package/cjs/axis/type.js.map +1 -1
  7. package/cjs/constant.d.ts +6 -0
  8. package/cjs/constant.js +6 -1
  9. package/cjs/constant.js.map +1 -1
  10. package/cjs/core/type.d.ts +15 -0
  11. package/cjs/core/type.js.map +1 -1
  12. package/cjs/index.d.ts +1 -1
  13. package/cjs/index.js +1 -1
  14. package/cjs/index.js.map +1 -1
  15. package/cjs/indicator/indicator.js +7 -15
  16. package/cjs/indicator/indicator.js.map +1 -1
  17. package/cjs/indicator/type.d.ts +3 -5
  18. package/cjs/indicator/type.js.map +1 -1
  19. package/cjs/label/area.d.ts +1 -1
  20. package/cjs/label/area.js +2 -2
  21. package/cjs/label/area.js.map +1 -1
  22. package/cjs/label/base.d.ts +1 -1
  23. package/cjs/label/base.js +16 -14
  24. package/cjs/label/base.js.map +1 -1
  25. package/cjs/label/index.d.ts +1 -0
  26. package/cjs/label/index.js +2 -1
  27. package/cjs/label/index.js.map +1 -1
  28. package/cjs/label/line.d.ts +1 -1
  29. package/cjs/label/line.js +3 -3
  30. package/cjs/label/line.js.map +1 -1
  31. package/cjs/label/type.d.ts +1 -0
  32. package/cjs/label/type.js.map +1 -1
  33. package/cjs/legend/discrete/discrete.js +2 -2
  34. package/cjs/legend/discrete/discrete.js.map +1 -1
  35. package/cjs/marker/area.js.map +1 -1
  36. package/cjs/marker/line.js.map +1 -1
  37. package/cjs/marker/point.js.map +1 -1
  38. package/cjs/marker/type.d.ts +14 -14
  39. package/cjs/marker/type.js.map +1 -1
  40. package/cjs/tag/tag.js +5 -9
  41. package/cjs/tag/tag.js.map +1 -1
  42. package/cjs/tag/type.d.ts +3 -5
  43. package/cjs/tag/type.js.map +1 -1
  44. package/cjs/title/title.js +67 -99
  45. package/cjs/title/title.js.map +1 -1
  46. package/cjs/tooltip/tooltip.js +7 -15
  47. package/cjs/tooltip/tooltip.js.map +1 -1
  48. package/cjs/tooltip/util.js +5 -5
  49. package/cjs/tooltip/util.js.map +1 -1
  50. package/cjs/util/label-smartInvert.d.ts +2 -2
  51. package/cjs/util/label-smartInvert.js +9 -5
  52. package/cjs/util/label-smartInvert.js.map +1 -1
  53. package/dist/index.js +180 -152
  54. package/dist/index.min.js +1 -1
  55. package/es/axis/base.js +8 -10
  56. package/es/axis/base.js.map +1 -1
  57. package/es/axis/circle.d.ts +1 -2
  58. package/es/axis/circle.js.map +1 -1
  59. package/es/axis/type.d.ts +6 -10
  60. package/es/axis/type.js.map +1 -1
  61. package/es/constant.d.ts +6 -0
  62. package/es/constant.js +7 -0
  63. package/es/constant.js.map +1 -1
  64. package/es/core/type.d.ts +15 -0
  65. package/es/core/type.js.map +1 -1
  66. package/es/index.d.ts +1 -1
  67. package/es/index.js +1 -1
  68. package/es/index.js.map +1 -1
  69. package/es/indicator/indicator.js +8 -14
  70. package/es/indicator/indicator.js.map +1 -1
  71. package/es/indicator/type.d.ts +3 -5
  72. package/es/indicator/type.js.map +1 -1
  73. package/es/label/area.d.ts +1 -1
  74. package/es/label/area.js +2 -2
  75. package/es/label/area.js.map +1 -1
  76. package/es/label/base.d.ts +1 -1
  77. package/es/label/base.js +16 -13
  78. package/es/label/base.js.map +1 -1
  79. package/es/label/index.d.ts +1 -0
  80. package/es/label/index.js +2 -0
  81. package/es/label/index.js.map +1 -1
  82. package/es/label/line.d.ts +1 -1
  83. package/es/label/line.js +3 -3
  84. package/es/label/line.js.map +1 -1
  85. package/es/label/type.d.ts +1 -0
  86. package/es/label/type.js.map +1 -1
  87. package/es/legend/discrete/discrete.js +2 -2
  88. package/es/legend/discrete/discrete.js.map +1 -1
  89. package/es/marker/area.js.map +1 -1
  90. package/es/marker/line.js.map +1 -1
  91. package/es/marker/point.js.map +1 -1
  92. package/es/marker/type.d.ts +14 -14
  93. package/es/marker/type.js.map +1 -1
  94. package/es/tag/tag.js +6 -8
  95. package/es/tag/tag.js.map +1 -1
  96. package/es/tag/type.d.ts +3 -5
  97. package/es/tag/type.js.map +1 -1
  98. package/es/title/title.js +66 -98
  99. package/es/title/title.js.map +1 -1
  100. package/es/tooltip/tooltip.js +8 -14
  101. package/es/tooltip/tooltip.js.map +1 -1
  102. package/es/tooltip/util.js +5 -5
  103. package/es/tooltip/util.js.map +1 -1
  104. package/es/util/label-smartInvert.d.ts +2 -2
  105. package/es/util/label-smartInvert.js +9 -5
  106. package/es/util/label-smartInvert.js.map +1 -1
  107. package/package.json +8 -8
@@ -37,16 +37,16 @@ export type IMarkBackgroundAttributes = {
37
37
  autoHeight?: boolean;
38
38
  autoWidth?: boolean;
39
39
  } & Partial<SymbolAttributes>;
40
- export interface IMarkLabel extends Omit<TagAttributes, 'x' | 'y' | 'panel'> {
40
+ export type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {
41
41
  panel?: IMarkBackgroundAttributes;
42
- }
43
- export interface IMarkRef {
42
+ };
43
+ export type IMarkRef = {
44
44
  autoRotate?: boolean;
45
45
  refX?: number;
46
46
  refY?: number;
47
47
  refAngle?: number;
48
- }
49
- export interface MarkerAttrs extends IGroupGraphicAttribute {
48
+ };
49
+ export type MarkerAttrs = IGroupGraphicAttribute & {
50
50
  type?: 'line' | 'area' | 'point';
51
51
  interactive?: boolean;
52
52
  visible?: boolean;
@@ -57,16 +57,16 @@ export interface MarkerAttrs extends IGroupGraphicAttribute {
57
57
  width: number;
58
58
  height: number;
59
59
  };
60
- }
61
- export interface MarkLineAttrs extends MarkerAttrs, SegmentAttributes {
60
+ };
61
+ export type MarkLineAttrs = MarkerAttrs & SegmentAttributes & {
62
62
  type?: 'line';
63
63
  points: Point[] | Point[][];
64
64
  label?: {
65
65
  position?: keyof typeof IMarkLineLabelPosition;
66
66
  confine?: boolean;
67
67
  } & IMarkRef & IMarkLabel;
68
- }
69
- export interface MarkAreaAttrs extends MarkerAttrs {
68
+ };
69
+ export type MarkAreaAttrs = MarkerAttrs & {
70
70
  type?: 'area';
71
71
  points: Point[];
72
72
  label?: {
@@ -74,8 +74,8 @@ export interface MarkAreaAttrs extends MarkerAttrs {
74
74
  confine?: boolean;
75
75
  } & IMarkLabel;
76
76
  areaStyle?: IPolygonAttribute;
77
- }
78
- export interface IItemContent extends IMarkRef {
77
+ };
78
+ export type IItemContent = IMarkRef & {
79
79
  type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';
80
80
  position?: keyof typeof IMarkPointItemPosition;
81
81
  offsetX?: number;
@@ -85,7 +85,7 @@ export interface IItemContent extends IMarkRef {
85
85
  textStyle?: IMarkLabel;
86
86
  richTextStyle?: IRichTextGraphicAttribute;
87
87
  renderCustomCallback?: () => IGroup;
88
- }
88
+ };
89
89
  export type IItemLine = {
90
90
  type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';
91
91
  visible?: boolean;
@@ -94,8 +94,8 @@ export type IItemLine = {
94
94
  length?: number;
95
95
  };
96
96
  } & Omit<SegmentAttributes, 'points'>;
97
- export interface MarkPointAttrs extends Omit<MarkerAttrs, 'labelStyle'> {
97
+ export type MarkPointAttrs = Omit<MarkerAttrs, 'labelStyle'> & {
98
98
  position: Point;
99
99
  itemLine?: IItemLine;
100
100
  itemContent?: IItemContent;
101
- }
101
+ };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":";;;AAYA,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,qCAAW,CAAA;IACX,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IACvC,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IACzC,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAVW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAUjC;AAED,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;AAC/B,CAAC,EAVW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAUjC;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 IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n IPolygonAttribute,\n IRichTextGraphicAttribute,\n ISymbolGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { SegmentAttributes, SymbolAttributes } from '../segment';\nimport type { TagAttributes } from '../tag';\nimport type { Point } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n middle = 'middle',\n end = 'end',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom'\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<SymbolAttributes>;\n\nexport interface IMarkLabel extends Omit<TagAttributes, 'x' | 'y' | 'panel'> {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n}\n\nexport interface IMarkRef {\n /**\n * 自动旋转,沿着线的方向,默认 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 interface MarkerAttrs extends IGroupGraphicAttribute {\n type?: 'line' | 'area' | 'point';\n /**\n * 是否支持交互\n * @default false\n */\n interactive?: 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}\n\nexport interface MarkLineAttrs extends MarkerAttrs, SegmentAttributes {\n type?: 'line';\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为曲线\n */\n points: Point[] | Point[][];\n\n /**\n * 标签\n */\n label?: {\n /**\n * label 相对line的位置\n */\n position?: keyof typeof IMarkLineLabelPosition;\n /**\n * 当 mark 配置了 clip 之后,label 是否自动调整位置\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n}\n\nexport interface MarkAreaAttrs extends MarkerAttrs {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: Point[];\n /**\n * 标签\n */\n label?: {\n position?: keyof typeof IMarkAreaLabelPosition;\n /**\n * 当 mark 配置了 clip 之后,label 是否自动调整位置\n */\n confine?: boolean;\n } & IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\n}\n\nexport interface IItemContent extends 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 配置了 clip 之后,label 是否自动调整位置\n // */\n // confine?: boolean;\n}\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';\n visible?: boolean;\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 interface MarkPointAttrs extends Omit<MarkerAttrs, 'labelStyle'> {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: Point;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n}\n"]}
1
+ {"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":";;;AAYA,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,qCAAW,CAAA;IACX,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IACvC,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IACzC,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAVW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAUjC;AAED,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;AAC/B,CAAC,EAVW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAUjC;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 IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n IPolygonAttribute,\n IRichTextGraphicAttribute,\n ISymbolGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { SegmentAttributes, SymbolAttributes } from '../segment';\nimport type { TagAttributes } from '../tag';\nimport type { Point } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n middle = 'middle',\n end = 'end',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom'\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<SymbolAttributes>;\n\nexport type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n};\n\nexport type IMarkRef = {\n /**\n * 自动旋转,沿着线的方向,默认 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 = IGroupGraphicAttribute & {\n type?: 'line' | 'area' | 'point';\n /**\n * 是否支持交互\n * @default false\n */\n interactive?: 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};\n\nexport type MarkLineAttrs = MarkerAttrs &\n SegmentAttributes & {\n type?: 'line';\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为曲线\n */\n points: Point[] | Point[][];\n\n /**\n * 标签\n */\n label?: {\n /**\n * label 相对line的位置\n */\n position?: keyof typeof IMarkLineLabelPosition;\n /**\n * 当 mark 配置了 clip 之后,label 是否自动调整位置\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n };\n\nexport type MarkAreaAttrs = MarkerAttrs & {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: Point[];\n /**\n * 标签\n */\n label?: {\n position?: keyof typeof IMarkAreaLabelPosition;\n /**\n * 当 mark 配置了 clip 之后,label 是否自动调整位置\n */\n confine?: boolean;\n } & IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\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 配置了 clip 之后,label 是否自动调整位置\n // */\n // confine?: boolean;\n};\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';\n visible?: boolean;\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, 'labelStyle'> & {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: Point;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n};\n"]}
package/cjs/tag/tag.js CHANGED
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", {
14
14
  value: !0
15
15
  }), exports.Tag = void 0;
16
16
 
17
- const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), util_1 = require("../util");
17
+ const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), util_1 = require("../util"), constant_1 = require("../constant");
18
18
 
19
19
  class Tag extends base_1.AbstractComponent {
20
20
  constructor(attributes) {
@@ -22,7 +22,7 @@ class Tag extends base_1.AbstractComponent {
22
22
  }
23
23
  render() {
24
24
  var _a, _b, _c;
25
- 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 = "text"} = this.attribute, parsedPadding = (0,
25
+ 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} = this.attribute, parsedPadding = (0,
26
26
  vutils_1.normalizePadding)(padding), group = this.createOrUpdateChild("tag-content", {
27
27
  x: 0,
28
28
  y: 0,
@@ -71,13 +71,9 @@ class Tag extends base_1.AbstractComponent {
71
71
  const richTextAttrs = Object.assign(Object.assign({
72
72
  textConfig: [],
73
73
  visible: (0, vutils_1.isValid)(text) && !1 !== visible,
74
- html: Object.assign({
75
- dom: text,
76
- container: "",
77
- width: 30,
78
- height: 30,
79
- style: {}
80
- }, textStyle)
74
+ html: Object.assign(Object.assign({
75
+ dom: text
76
+ }, constant_1.DEFAULT_HTML_TEXT_SPEC), textStyle)
81
77
  }, textStyle), {
82
78
  x: textX,
83
79
  y: 0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tag/tag.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAcA,6CAAyG;AACzG,uCAAiD;AACjD,kCAA0C;AAI1C,MAAa,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,CAAC,YAAY,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1C,IAAI,MAAM,EAAE;oBACV,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;iBAC1C;aACF;YAGD,MAAM,EAAE,OAAO,EAAE,SAAS,KAAyB,KAAK,EAAzB,eAAe,UAAK,KAAK,EAAlD,WAA0C,CAAQ,CAAC;YACzD,IAAI,OAAO,IAAI,IAAA,kBAAS,EAAC,SAAS,CAAC,EAAE;gBACnC,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CACrC,WAAW,kCAEN,eAAe,KAClB,OAAO,EAAE,SAAS,IAAI,CAAC,CAAC,IAAI,EAC5B,CAAC;oBACD,CAAC,EACD,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,KAEnB,MAAM,CACE,CAAC;gBACX,IAAI,CAAC,IAAA,gBAAO,EAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,EAAE;oBAC1B,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;iBAC7B;aACF;SACF;IACH,CAAC;;AAjPH,kBAkPC;AA/OQ,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 type {\n IGroup,\n IRect,\n ISymbol,\n IText,\n ITextAttribute,\n ITextGraphicAttribute,\n IRichTextGraphicAttribute,\n IRichText,\n IRichTextCharacter\n} from '@visactor/vrender-core';\nimport { isBoolean, isEmpty, isNil, isNumber, isValid, merge, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport type { BackgroundAttributes } from '../interface';\nimport type { TagAttributes, TagShapeAttributes } from './type';\n\nexport class Tag extends AbstractComponent<Required<TagAttributes>> {\n name = 'tag';\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) {\n super(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 = 'text'\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]);\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;\n if (type === 'rich') {\n const richTextAttrs = {\n textConfig: text as IRichTextCharacter[],\n visible: isValid(text) && visible !== false,\n ...(textStyle as IRichTextGraphicAttribute),\n x: textX,\n y: 0,\n width: (textStyle as IRichTextGraphicAttribute).width ?? 0,\n height: (textStyle as IRichTextGraphicAttribute).height ?? 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 }\n } else if (type === 'html') {\n const richTextAttrs = {\n textConfig: [] as IRichTextCharacter[],\n visible: isValid(text) && visible !== false,\n html: {\n dom: text as string,\n container: '',\n width: 30,\n height: 30,\n style: {},\n ...textStyle\n },\n ...(textStyle as IRichTextGraphicAttribute),\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 }\n } else {\n const textAttrs = {\n text: text as string | number | string[] | number[],\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, '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);\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]);\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 if (textAlign === 'center') {\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 (textAlign === 'right' || textAlign === 'end') {\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 (textAlign === 'left' || textAlign === 'start') {\n group.setAttribute('x', parsedPadding[3]);\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 }\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/tag/tag.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAcA,6CAAyG;AACzG,uCAAiD;AACjD,kCAA0C;AAG1C,0CAAqD;AAErD,MAAa,GAAI,SAAQ,wBAA0C;IAmBjE,YAAY,UAAyB;QACnC,KAAK,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,GAAG,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAnBtD,SAAI,GAAG,KAAK,CAAC;IAoBb,CAAC;IAES,MAAM;;QACd,MAAM,EACJ,IAAI,GAAG,EAAE,EACT,SAAS,GAAG,EAAuD,EACnE,KAAK,GAAG,EAAwB,EAChC,KAAK,GAAG,EAA0B,EAClC,KAAK,GAAG,CAAC,EACT,QAAQ,EACR,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,OAAO,EACP,KAAK,EACL,IAAI,EACL,GAAG,IAAI,CAAC,SAA0B,CAAC;QACpC,MAAM,aAAa,GAAG,IAAA,yBAAgB,EAAC,OAAO,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,OAAO,CAAW,CAAC;QAEpG,IAAI,MAAM,CAAC;QACX,IAAI,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAA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R,OAAO,EAAE,CAAC;IAEV,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;KACb;CACF,CAAC","file":"tag.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport type {\n IGroup,\n IRect,\n ISymbol,\n IText,\n ITextAttribute,\n ITextGraphicAttribute,\n IRichTextGraphicAttribute,\n IRichText,\n IRichTextCharacter\n} from '@visactor/vrender-core';\nimport { isBoolean, isEmpty, isNil, isNumber, isValid, merge, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport type { BackgroundAttributes } from '../interface';\nimport type { TagAttributes, TagShapeAttributes } from './type';\nimport { DEFAULT_HTML_TEXT_SPEC } from '../constant';\n\nexport class Tag extends AbstractComponent<Required<TagAttributes>> {\n name = 'tag';\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) {\n super(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 } = 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]);\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;\n if (type === 'rich') {\n const richTextAttrs = {\n textConfig: text as IRichTextCharacter[],\n visible: isValid(text) && visible !== false,\n ...(textStyle as IRichTextGraphicAttribute),\n x: textX,\n y: 0,\n width: (textStyle as IRichTextGraphicAttribute).width ?? 0,\n height: (textStyle as IRichTextGraphicAttribute).height ?? 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 }\n } else if (type === 'html') {\n const richTextAttrs = {\n textConfig: [] as IRichTextCharacter[],\n visible: isValid(text) && visible !== false,\n html: {\n dom: text as string,\n ...DEFAULT_HTML_TEXT_SPEC,\n ...textStyle\n },\n ...(textStyle as IRichTextGraphicAttribute),\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 }\n } else {\n const textAttrs = {\n text: text as string | number | string[] | number[],\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, '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);\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]);\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 if (textAlign === 'center') {\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 (textAlign === 'right' || textAlign === 'end') {\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 (textAlign === 'left' || textAlign === 'start') {\n group.setAttribute('x', parsedPadding[3]);\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 }\n }\n }\n}\n"]}
package/cjs/tag/type.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { ITextGraphicAttribute, ISymbolGraphicAttribute, IGroupGraphicAttribute, IRectGraphicAttribute, IRichTextCharacter, IRichTextGraphicAttribute } from '@visactor/vrender-core';
2
- import type { Padding, State } from '../core/type';
1
+ import type { ITextGraphicAttribute, ISymbolGraphicAttribute, IGroupGraphicAttribute, IRectGraphicAttribute, IRichTextGraphicAttribute } from '@visactor/vrender-core';
2
+ import type { Padding, State, TextContent } from '../core/type';
3
3
  import type { BackgroundAttributes } from '../interface';
4
4
  type StateStyle = {
5
5
  text?: State<Partial<ITextGraphicAttribute>>;
@@ -7,8 +7,6 @@ type StateStyle = {
7
7
  panel?: State<Partial<IRectGraphicAttribute>>;
8
8
  };
9
9
  export type TagAttributes = {
10
- type?: string;
11
- text?: string | string[] | number | number[] | IRichTextCharacter[];
12
10
  textStyle?: Partial<ITextGraphicAttribute> | Partial<IRichTextGraphicAttribute>;
13
11
  shape?: TagShapeAttributes;
14
12
  space?: number;
@@ -18,7 +16,7 @@ export type TagAttributes = {
18
16
  maxWidth?: number;
19
17
  visible?: boolean;
20
18
  state?: StateStyle;
21
- } & Omit<IGroupGraphicAttribute, 'background'>;
19
+ } & Omit<IGroupGraphicAttribute, 'background'> & TextContent;
22
20
  export type TagShapeAttributes = {
23
21
  visible: boolean;
24
22
  } & Partial<ISymbolGraphicAttribute>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tag/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n ITextGraphicAttribute,\n ISymbolGraphicAttribute,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextCharacter,\n IRichTextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { Padding, State } from '../core/type';\nimport type { BackgroundAttributes } from '../interface';\n\ntype StateStyle = {\n /**\n * text 文本的状态配置\n */\n text?: State<Partial<ITextGraphicAttribute>>;\n /**\n * shape 标记的状态配置\n */\n shape?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * panel 背景的状态配置ß\n */\n panel?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type TagAttributes = {\n /**\n * 文本类型:text, rich, html\n */\n type?: string;\n /**\n * 文本内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n * 支持富文本内容, 如textConfig, html\n */\n text?: string | string[] | number | number[] | IRichTextCharacter[];\n /** 文本样式 */\n textStyle?: Partial<ITextGraphicAttribute> | Partial<IRichTextGraphicAttribute>;\n // & {\n // /** 富文本或html时配置生效 */\n // width?: number;\n // height?: number;\n // };\n /** 文本前 mark 图元 */\n shape?: TagShapeAttributes;\n /**\n * shape 同文本之间的间距\n */\n space?: number;\n /**\n * 内部边距\n */\n padding?: Padding;\n /**\n * 标签的背景面板配置, TODO: 支持symbol形状\n */\n panel?: BackgroundAttributes;\n /**\n * 最小宽度,像素值\n * @default 30\n */\n minWidth?: number;\n /**\n * 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n visible?: boolean;\n state?: StateStyle;\n} & Omit<IGroupGraphicAttribute, 'background'>;\n\nexport type TagShapeAttributes = {\n /**\n * 是否展示 shape\n */\n visible: boolean;\n} & Partial<ISymbolGraphicAttribute>;\n"]}
1
+ {"version":3,"sources":["../src/tag/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n ITextGraphicAttribute,\n ISymbolGraphicAttribute,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextCharacter,\n IRichTextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { Padding, State, TextContent } from '../core/type';\nimport type { BackgroundAttributes } from '../interface';\n\ntype StateStyle = {\n /**\n * text 文本的状态配置\n */\n text?: State<Partial<ITextGraphicAttribute>>;\n /**\n * shape 标记的状态配置\n */\n shape?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * panel 背景的状态配置ß\n */\n panel?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type TagAttributes = {\n /** 文本样式 */\n textStyle?: Partial<ITextGraphicAttribute> | Partial<IRichTextGraphicAttribute>;\n /** 文本前 mark 图元 */\n shape?: TagShapeAttributes;\n /**\n * shape 同文本之间的间距\n */\n space?: number;\n /**\n * 内部边距\n */\n padding?: Padding;\n /**\n * 标签的背景面板配置, TODO: 支持symbol形状\n */\n panel?: BackgroundAttributes;\n /**\n * 最小宽度,像素值\n * @default 30\n */\n minWidth?: number;\n /**\n * 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n visible?: boolean;\n state?: StateStyle;\n} & Omit<IGroupGraphicAttribute, 'background'> &\n TextContent;\n\nexport type TagShapeAttributes = {\n /**\n * 是否展示 shape\n */\n visible: boolean;\n} & Partial<ISymbolGraphicAttribute>;\n"]}
@@ -4,21 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Title = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base");
7
+ const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), constant_1 = require("../constant");
8
8
 
9
9
  class Title extends base_1.AbstractComponent {
10
10
  constructor(attributes) {
11
11
  super((0, vutils_1.merge)({}, Title.defaultAttributes, attributes)), this.name = "title";
12
12
  }
13
13
  render() {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69;
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55;
15
15
  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,
16
16
  vutils_1.normalizePadding)(padding), group = this.createOrUpdateChild("title-container", {
17
17
  x: parsedPadding[3],
18
18
  y: parsedPadding[0],
19
19
  zIndex: 1
20
20
  }, "group");
21
- if (!1 !== (null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.visible) && !1 !== (null == textStyle ? void 0 : textStyle.visible)) if ("rich" === textType) {
21
+ if (!1 !== (null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.visible) && !1 !== (null == textStyle ? void 0 : textStyle.visible)) if ("rich" === textType || (0,
22
+ vutils_1.isValid)(textStyle.character)) {
22
23
  const attr = Object.assign({
23
24
  x: null !== (_b = textStyle.x) && void 0 !== _b ? _b : 0,
24
25
  y: null !== (_c = textStyle.y) && void 0 !== _c ? _c : 0,
@@ -28,150 +29,117 @@ class Title extends base_1.AbstractComponent {
28
29
  wordBreak: null !== (_j = textStyle.wordBreak) && void 0 !== _j ? _j : "break-word",
29
30
  maxHeight: textStyle.maxHeight,
30
31
  maxWidth: textStyle.maxWidth,
31
- textConfig: text
32
+ textConfig: null !== (_k = textStyle.character) && void 0 !== _k ? _k : text
32
33
  }, textStyle);
33
34
  this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
34
35
  } else if ("html" === textType) {
35
36
  const attr = Object.assign({
36
- html: Object.assign({
37
- dom: text,
38
- container: "",
39
- width: 30,
40
- height: 30,
41
- style: ""
42
- }, textStyle),
43
- x: null !== (_k = textStyle.x) && void 0 !== _k ? _k : 0,
44
- y: null !== (_l = textStyle.y) && void 0 !== _l ? _l : 0,
45
- width: null !== (_o = null !== (_m = textStyle.width) && void 0 !== _m ? _m : width) && void 0 !== _o ? _o : 0,
46
- height: null !== (_q = null !== (_p = textStyle.height) && void 0 !== _p ? _p : height) && void 0 !== _q ? _q : 0,
47
- ellipsis: null === (_r = textStyle.ellipsis) || void 0 === _r || _r,
48
- wordBreak: null !== (_s = textStyle.wordBreak) && void 0 !== _s ? _s : "break-word",
37
+ html: Object.assign(Object.assign({
38
+ dom: text
39
+ }, constant_1.DEFAULT_HTML_TEXT_SPEC), textStyle),
40
+ x: null !== (_l = textStyle.x) && void 0 !== _l ? _l : 0,
41
+ y: null !== (_m = textStyle.y) && void 0 !== _m ? _m : 0,
42
+ width: null !== (_p = null !== (_o = textStyle.width) && void 0 !== _o ? _o : width) && void 0 !== _p ? _p : 0,
43
+ height: null !== (_r = null !== (_q = textStyle.height) && void 0 !== _q ? _q : height) && void 0 !== _r ? _r : 0,
44
+ ellipsis: null === (_s = textStyle.ellipsis) || void 0 === _s || _s,
45
+ wordBreak: null !== (_t = textStyle.wordBreak) && void 0 !== _t ? _t : "break-word",
49
46
  maxHeight: textStyle.maxHeight,
50
47
  maxWidth: textStyle.maxWidth,
51
48
  textConfig: []
52
49
  }, textStyle);
53
50
  this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
54
- } else if (textStyle && (0, vutils_1.isValid)(null == textStyle ? void 0 : textStyle.character)) {
55
- const attr = {
56
- x: null !== (_t = textStyle.x) && void 0 !== _t ? _t : 0,
57
- y: null !== (_u = textStyle.y) && void 0 !== _u ? _u : 0,
58
- width: null !== (_w = null !== (_v = textStyle.width) && void 0 !== _v ? _v : width) && void 0 !== _w ? _w : 0,
59
- height: null !== (_y = null !== (_x = textStyle.height) && void 0 !== _x ? _x : height) && void 0 !== _y ? _y : 0,
60
- ellipsis: null === (_z = textStyle.ellipsis) || void 0 === _z || _z,
61
- wordBreak: null !== (_0 = textStyle.wordBreak) && void 0 !== _0 ? _0 : "break-word",
62
- maxHeight: textStyle.maxHeight,
63
- maxWidth: textStyle.maxWidth,
64
- textConfig: textStyle.character
65
- };
66
- this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
67
51
  } else (0, vutils_1.isValid)(text) && (this._mainTitle = group.createOrUpdateChild("mainTitle", Object.assign(Object.assign({
68
52
  text: [ text ]
69
53
  }, textStyle), {
70
- maxLineWidth: null !== (_1 = null == textStyle ? void 0 : textStyle.maxLineWidth) && void 0 !== _1 ? _1 : width,
54
+ maxLineWidth: null !== (_u = null == textStyle ? void 0 : textStyle.maxLineWidth) && void 0 !== _u ? _u : width,
71
55
  heightLimit: null == textStyle ? void 0 : textStyle.heightLimit,
72
56
  lineClamp: null == textStyle ? void 0 : textStyle.lineClamp,
73
- ellipsis: null === (_2 = null == textStyle ? void 0 : textStyle.ellipsis) || void 0 === _2 || _2,
57
+ ellipsis: null === (_v = null == textStyle ? void 0 : textStyle.ellipsis) || void 0 === _v || _v,
74
58
  x: 0,
75
59
  y: 0
76
60
  }), "wrapText"));
77
- const maintextHeight = this._mainTitle ? null === (_3 = this._mainTitle) || void 0 === _3 ? void 0 : _3.AABBBounds.height() : 0, maintextWidth = this._mainTitle ? null === (_4 = this._mainTitle) || void 0 === _4 ? void 0 : _4.AABBBounds.width() : 0;
78
- if (!1 !== (null === (_5 = this.attribute) || void 0 === _5 ? void 0 : _5.visible) && !1 !== (null == subtextStyle ? void 0 : subtextStyle.visible)) if ("rich" === subtextType) {
61
+ const maintextHeight = this._mainTitle ? null === (_w = this._mainTitle) || void 0 === _w ? void 0 : _w.AABBBounds.height() : 0, maintextWidth = this._mainTitle ? null === (_x = this._mainTitle) || void 0 === _x ? void 0 : _x.AABBBounds.width() : 0;
62
+ if (!1 !== (null === (_y = this.attribute) || void 0 === _y ? void 0 : _y.visible) && !1 !== (null == subtextStyle ? void 0 : subtextStyle.visible)) if ("rich" === subtextType || (0,
63
+ vutils_1.isValid)(subtextStyle.character)) {
79
64
  const attr = Object.assign({
80
- x: null !== (_6 = subtextStyle.x) && void 0 !== _6 ? _6 : 0,
81
- y: null !== (_7 = subtextStyle.y) && void 0 !== _7 ? _7 : 0,
82
- width: null !== (_9 = null !== (_8 = subtextStyle.width) && void 0 !== _8 ? _8 : width) && void 0 !== _9 ? _9 : 0,
83
- height: null !== (_11 = null !== (_10 = subtextStyle.height) && void 0 !== _10 ? _10 : height) && void 0 !== _11 ? _11 : 0,
84
- ellipsis: null === (_12 = subtextStyle.ellipsis) || void 0 === _12 || _12,
85
- wordBreak: null !== (_13 = subtextStyle.wordBreak) && void 0 !== _13 ? _13 : "break-word",
65
+ x: null !== (_z = subtextStyle.x) && void 0 !== _z ? _z : 0,
66
+ y: null !== (_0 = subtextStyle.y) && void 0 !== _0 ? _0 : 0,
67
+ width: null !== (_2 = null !== (_1 = subtextStyle.width) && void 0 !== _1 ? _1 : width) && void 0 !== _2 ? _2 : 0,
68
+ height: null !== (_4 = null !== (_3 = subtextStyle.height) && void 0 !== _3 ? _3 : height) && void 0 !== _4 ? _4 : 0,
69
+ ellipsis: null === (_5 = subtextStyle.ellipsis) || void 0 === _5 || _5,
70
+ wordBreak: null !== (_6 = subtextStyle.wordBreak) && void 0 !== _6 ? _6 : "break-word",
86
71
  maxHeight: subtextStyle.maxHeight,
87
72
  maxWidth: subtextStyle.maxWidth,
88
- textConfig: subtext
73
+ textConfig: null !== (_7 = subtextStyle.character) && void 0 !== _7 ? _7 : subtext
89
74
  }, subtextStyle);
90
75
  this._subTitle = group.createOrUpdateChild("subTitle", attr, "richtext");
91
- } else if ("html" === textType) {
76
+ } else if ("html" === subtextType) {
92
77
  const attr = Object.assign({
93
- html: Object.assign({
94
- dom: subtext,
95
- container: "",
96
- width: 30,
97
- height: 30,
98
- style: {}
99
- }, subtextStyle),
100
- x: null !== (_14 = subtextStyle.x) && void 0 !== _14 ? _14 : 0,
101
- y: null !== (_15 = subtextStyle.y) && void 0 !== _15 ? _15 : 0,
102
- width: null !== (_17 = null !== (_16 = subtextStyle.width) && void 0 !== _16 ? _16 : width) && void 0 !== _17 ? _17 : 0,
103
- height: null !== (_19 = null !== (_18 = subtextStyle.height) && void 0 !== _18 ? _18 : height) && void 0 !== _19 ? _19 : 0,
104
- ellipsis: null === (_20 = subtextStyle.ellipsis) || void 0 === _20 || _20,
105
- wordBreak: null !== (_21 = subtextStyle.wordBreak) && void 0 !== _21 ? _21 : "break-word",
78
+ html: Object.assign(Object.assign({
79
+ dom: subtext
80
+ }, constant_1.DEFAULT_HTML_TEXT_SPEC), subtextStyle),
81
+ x: null !== (_8 = subtextStyle.x) && void 0 !== _8 ? _8 : 0,
82
+ y: null !== (_9 = subtextStyle.y) && void 0 !== _9 ? _9 : 0,
83
+ width: null !== (_11 = null !== (_10 = subtextStyle.width) && void 0 !== _10 ? _10 : width) && void 0 !== _11 ? _11 : 0,
84
+ height: null !== (_13 = null !== (_12 = subtextStyle.height) && void 0 !== _12 ? _12 : height) && void 0 !== _13 ? _13 : 0,
85
+ ellipsis: null === (_14 = subtextStyle.ellipsis) || void 0 === _14 || _14,
86
+ wordBreak: null !== (_15 = subtextStyle.wordBreak) && void 0 !== _15 ? _15 : "break-word",
106
87
  maxHeight: subtextStyle.maxHeight,
107
88
  maxWidth: subtextStyle.maxWidth,
108
89
  textConfig: []
109
90
  }, subtextStyle);
110
91
  this._subTitle = group.createOrUpdateChild("subTitle", attr, "richtext");
111
- } else if (subtextStyle && (0, vutils_1.isValid)(null == subtextStyle ? void 0 : subtextStyle.character)) {
112
- const attr = {
113
- x: null !== (_22 = subtextStyle.x) && void 0 !== _22 ? _22 : 0,
114
- y: null !== (_23 = subtextStyle.y) && void 0 !== _23 ? _23 : maintextHeight,
115
- width: null !== (_25 = null !== (_24 = subtextStyle.width) && void 0 !== _24 ? _24 : width) && void 0 !== _25 ? _25 : 0,
116
- height: null !== (_27 = null !== (_26 = subtextStyle.height) && void 0 !== _26 ? _26 : height) && void 0 !== _27 ? _27 : 0,
117
- ellipsis: null === (_28 = subtextStyle.ellipsis) || void 0 === _28 || _28,
118
- wordBreak: null !== (_29 = subtextStyle.wordBreak) && void 0 !== _29 ? _29 : "break-word",
119
- maxHeight: subtextStyle.maxHeight,
120
- maxWidth: subtextStyle.maxWidth,
121
- textConfig: subtextStyle.character
122
- };
123
- this._subTitle = group.createOrUpdateChild("subTitle", attr, "richtext");
124
92
  } else (0, vutils_1.isValid)(subtext) && (this._subTitle = group.createOrUpdateChild("subTitle", Object.assign(Object.assign({
125
93
  text: [ subtext ]
126
94
  }, subtextStyle), {
127
- maxLineWidth: null !== (_30 = null == subtextStyle ? void 0 : subtextStyle.maxLineWidth) && void 0 !== _30 ? _30 : width,
95
+ maxLineWidth: null !== (_16 = null == subtextStyle ? void 0 : subtextStyle.maxLineWidth) && void 0 !== _16 ? _16 : width,
128
96
  heightLimit: null == subtextStyle ? void 0 : subtextStyle.heightLimit,
129
97
  lineClamp: null == subtextStyle ? void 0 : subtextStyle.lineClamp,
130
- ellipsis: null === (_31 = null == subtextStyle ? void 0 : subtextStyle.ellipsis) || void 0 === _31 || _31,
98
+ ellipsis: null === (_17 = null == subtextStyle ? void 0 : subtextStyle.ellipsis) || void 0 === _17 || _17,
131
99
  x: 0,
132
100
  y: maintextHeight
133
101
  }), "wrapText"));
134
- const subtextHeight = this._subTitle ? null === (_32 = this._subTitle) || void 0 === _32 ? void 0 : _32.AABBBounds.height() : 0, subtextWidth = this._subTitle ? null === (_33 = this._subTitle) || void 0 === _33 ? void 0 : _33.AABBBounds.width() : 0;
135
- let titleWidth = Math.max(maintextWidth, subtextWidth), titleHeight = maintextHeight + (null !== (_34 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _34 ? _34 : subtextHeight);
136
- if ((0, vutils_1.isValid)(width) && (titleWidth = width, null === (_35 = this._mainTitle) || void 0 === _35 || _35.setAttribute("maxLineWidth", width),
137
- null === (_36 = this._subTitle) || void 0 === _36 || _36.setAttribute("maxLineWidth", width)),
102
+ const subtextHeight = this._subTitle ? null === (_18 = this._subTitle) || void 0 === _18 ? void 0 : _18.AABBBounds.height() : 0, subtextWidth = this._subTitle ? null === (_19 = this._subTitle) || void 0 === _19 ? void 0 : _19.AABBBounds.width() : 0;
103
+ let titleWidth = Math.max(maintextWidth, subtextWidth), titleHeight = maintextHeight + (null !== (_20 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _20 ? _20 : subtextHeight);
104
+ if ((0, vutils_1.isValid)(width) && (titleWidth = width, null === (_21 = this._mainTitle) || void 0 === _21 || _21.setAttribute("maxLineWidth", width),
105
+ null === (_22 = this._subTitle) || void 0 === _22 || _22.setAttribute("maxLineWidth", width)),
138
106
  (0, vutils_1.isValid)(height) && (titleHeight = height), (0, vutils_1.isValid)(minWidth) && titleWidth < minWidth && (titleWidth = minWidth),
139
- (0, vutils_1.isValid)(maxWidth) && (null === (_37 = this._mainTitle) || void 0 === _37 || _37.setAttribute("maxLineWidth", maxWidth),
140
- null === (_38 = this._subTitle) || void 0 === _38 || _38.setAttribute("maxLineWidth", maxWidth),
141
- null === (_39 = this._mainTitle) || void 0 === _39 || _39.setAttribute("maxWidth", maxWidth),
142
- null === (_40 = this._subTitle) || void 0 === _40 || _40.setAttribute("maxWidth", maxWidth),
107
+ (0, vutils_1.isValid)(maxWidth) && (null === (_23 = this._mainTitle) || void 0 === _23 || _23.setAttribute("maxLineWidth", maxWidth),
108
+ null === (_24 = this._subTitle) || void 0 === _24 || _24.setAttribute("maxLineWidth", maxWidth),
109
+ null === (_25 = this._mainTitle) || void 0 === _25 || _25.setAttribute("maxWidth", maxWidth),
110
+ null === (_26 = this._subTitle) || void 0 === _26 || _26.setAttribute("maxWidth", maxWidth),
143
111
  titleWidth > maxWidth && (titleWidth = maxWidth)), (0, vutils_1.isValid)(minHeight) && titleHeight < minHeight && (titleHeight = minHeight),
144
- (0, vutils_1.isValid)(maxHeight) && (null === (_41 = this._mainTitle) || void 0 === _41 || _41.setAttribute("maxHeight", maxHeight),
145
- null === (_42 = this._subTitle) || void 0 === _42 || _42.setAttribute("maxHeight", maxHeight - maintextHeight),
112
+ (0, vutils_1.isValid)(maxHeight) && (null === (_27 = this._mainTitle) || void 0 === _27 || _27.setAttribute("maxHeight", maxHeight),
113
+ null === (_28 = this._subTitle) || void 0 === _28 || _28.setAttribute("maxHeight", maxHeight - maintextHeight),
146
114
  titleHeight > maxHeight && (titleHeight = maxHeight)), group.attribute.width = titleWidth,
147
115
  group.attribute.height = titleHeight, group.attribute.boundsPadding = parsedPadding,
148
116
  (0, vutils_1.isValid)(align) || (0, vutils_1.isValid)(null == textStyle ? void 0 : textStyle.align)) {
149
- const mainTitleAlign = (null == textStyle ? void 0 : textStyle.align) ? null == textStyle ? void 0 : textStyle.align : align, mainTitleWidth = null !== (_43 = null == textStyle ? void 0 : textStyle.width) && void 0 !== _43 ? _43 : maintextWidth;
150
- "left" === mainTitleAlign ? (null === (_44 = this._mainTitle) || void 0 === _44 || _44.setAttribute("x", 0),
151
- null === (_45 = this._mainTitle) || void 0 === _45 || _45.setAttribute("textAlign", "left")) : "center" === mainTitleAlign ? (null === (_46 = this._mainTitle) || void 0 === _46 || _46.setAttribute("x", mainTitleWidth / 2),
152
- null === (_47 = this._mainTitle) || void 0 === _47 || _47.setAttribute("textAlign", "center")) : "right" === mainTitleAlign && (null === (_48 = this._mainTitle) || void 0 === _48 || _48.setAttribute("x", mainTitleWidth),
153
- null === (_49 = this._mainTitle) || void 0 === _49 || _49.setAttribute("textAlign", "right"));
117
+ const mainTitleAlign = (null == textStyle ? void 0 : textStyle.align) ? null == textStyle ? void 0 : textStyle.align : align, mainTitleWidth = null !== (_29 = null == textStyle ? void 0 : textStyle.width) && void 0 !== _29 ? _29 : maintextWidth;
118
+ "left" === mainTitleAlign ? (null === (_30 = this._mainTitle) || void 0 === _30 || _30.setAttribute("x", 0),
119
+ null === (_31 = this._mainTitle) || void 0 === _31 || _31.setAttribute("textAlign", "left")) : "center" === mainTitleAlign ? (null === (_32 = this._mainTitle) || void 0 === _32 || _32.setAttribute("x", mainTitleWidth / 2),
120
+ null === (_33 = this._mainTitle) || void 0 === _33 || _33.setAttribute("textAlign", "center")) : "right" === mainTitleAlign && (null === (_34 = this._mainTitle) || void 0 === _34 || _34.setAttribute("x", mainTitleWidth),
121
+ null === (_35 = this._mainTitle) || void 0 === _35 || _35.setAttribute("textAlign", "right"));
154
122
  }
155
123
  if ((0, vutils_1.isValid)(verticalAlign) || (0, vutils_1.isValid)(null == textStyle ? void 0 : textStyle.verticalAlign)) {
156
124
  const mainTitleVerticalAlign = (null == textStyle ? void 0 : textStyle.verticalAlign) ? null == textStyle ? void 0 : textStyle.verticalAlign : verticalAlign, mainTitleHeight = (null == textStyle ? void 0 : textStyle.height) ? null == textStyle ? void 0 : textStyle.height : titleHeight;
157
- "top" === mainTitleVerticalAlign ? (null === (_50 = this._mainTitle) || void 0 === _50 || _50.setAttribute("y", 0),
158
- null === (_51 = this._mainTitle) || void 0 === _51 || _51.setAttribute("textBaseline", "top")) : "middle" === mainTitleVerticalAlign ? (null === (_52 = this._mainTitle) || void 0 === _52 || _52.setAttribute("y", mainTitleHeight / 2),
159
- null === (_53 = this._mainTitle) || void 0 === _53 || _53.setAttribute("textBaseline", "middle")) : "bottom" === mainTitleVerticalAlign && (null === (_54 = this._mainTitle) || void 0 === _54 || _54.setAttribute("y", mainTitleHeight),
160
- null === (_55 = this._mainTitle) || void 0 === _55 || _55.setAttribute("textBaseline", "bottom"));
125
+ "top" === mainTitleVerticalAlign ? (null === (_36 = this._mainTitle) || void 0 === _36 || _36.setAttribute("y", 0),
126
+ null === (_37 = this._mainTitle) || void 0 === _37 || _37.setAttribute("textBaseline", "top")) : "middle" === mainTitleVerticalAlign ? (null === (_38 = this._mainTitle) || void 0 === _38 || _38.setAttribute("y", mainTitleHeight / 2),
127
+ null === (_39 = this._mainTitle) || void 0 === _39 || _39.setAttribute("textBaseline", "middle")) : "bottom" === mainTitleVerticalAlign && (null === (_40 = this._mainTitle) || void 0 === _40 || _40.setAttribute("y", mainTitleHeight),
128
+ null === (_41 = this._mainTitle) || void 0 === _41 || _41.setAttribute("textBaseline", "bottom"));
161
129
  }
162
130
  if ((0, vutils_1.isValid)(align) || (0, vutils_1.isValid)(null == subtextStyle ? void 0 : subtextStyle.align)) {
163
- const subTitleAlign = (null == subtextStyle ? void 0 : subtextStyle.align) ? null == subtextStyle ? void 0 : subtextStyle.align : align, subTitleWidth = null !== (_56 = null == subtextStyle ? void 0 : subtextStyle.width) && void 0 !== _56 ? _56 : subtextWidth;
164
- "left" === subTitleAlign ? (null === (_57 = this._subTitle) || void 0 === _57 || _57.setAttribute("x", 0),
165
- null === (_58 = this._subTitle) || void 0 === _58 || _58.setAttribute("textAlign", "left")) : "center" === subTitleAlign ? (null === (_59 = this._subTitle) || void 0 === _59 || _59.setAttribute("x", subTitleWidth / 2),
166
- null === (_60 = this._subTitle) || void 0 === _60 || _60.setAttribute("textAlign", "center")) : "right" === subTitleAlign && (null === (_61 = this._subTitle) || void 0 === _61 || _61.setAttribute("x", subTitleWidth),
167
- null === (_62 = this._subTitle) || void 0 === _62 || _62.setAttribute("textAlign", "right"));
131
+ const subTitleAlign = (null == subtextStyle ? void 0 : subtextStyle.align) ? null == subtextStyle ? void 0 : subtextStyle.align : align, subTitleWidth = null !== (_42 = null == subtextStyle ? void 0 : subtextStyle.width) && void 0 !== _42 ? _42 : subtextWidth;
132
+ "left" === subTitleAlign ? (null === (_43 = this._subTitle) || void 0 === _43 || _43.setAttribute("x", 0),
133
+ null === (_44 = this._subTitle) || void 0 === _44 || _44.setAttribute("textAlign", "left")) : "center" === subTitleAlign ? (null === (_45 = this._subTitle) || void 0 === _45 || _45.setAttribute("x", subTitleWidth / 2),
134
+ null === (_46 = this._subTitle) || void 0 === _46 || _46.setAttribute("textAlign", "center")) : "right" === subTitleAlign && (null === (_47 = this._subTitle) || void 0 === _47 || _47.setAttribute("x", subTitleWidth),
135
+ null === (_48 = this._subTitle) || void 0 === _48 || _48.setAttribute("textAlign", "right"));
168
136
  }
169
137
  if ((0, vutils_1.isValid)(verticalAlign) || (0, vutils_1.isValid)(null == textStyle ? void 0 : textStyle.verticalAlign)) {
170
- const subTitleVerticalAlign = (null == subtextStyle ? void 0 : subtextStyle.verticalAlign) ? null == subtextStyle ? void 0 : subtextStyle.verticalAlign : verticalAlign, subTitleYStart = maintextHeight, subTitleHeight = null !== (_63 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _63 ? _63 : 0;
171
- "top" === subTitleVerticalAlign ? (null === (_64 = this._subTitle) || void 0 === _64 || _64.setAttribute("y", subTitleYStart),
172
- null === (_65 = this._subTitle) || void 0 === _65 || _65.setAttribute("textBaseline", "top")) : "middle" === subTitleVerticalAlign ? (null === (_66 = this._subTitle) || void 0 === _66 || _66.setAttribute("y", subTitleYStart + subTitleHeight / 2),
173
- null === (_67 = this._subTitle) || void 0 === _67 || _67.setAttribute("textBaseline", "middle")) : "bottom" === subTitleVerticalAlign && (null === (_68 = this._subTitle) || void 0 === _68 || _68.setAttribute("y", subTitleYStart + subTitleHeight),
174
- null === (_69 = this._subTitle) || void 0 === _69 || _69.setAttribute("textBaseline", "bottom"));
138
+ const subTitleVerticalAlign = (null == subtextStyle ? void 0 : subtextStyle.verticalAlign) ? null == subtextStyle ? void 0 : subtextStyle.verticalAlign : verticalAlign, subTitleYStart = maintextHeight, subTitleHeight = null !== (_49 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _49 ? _49 : 0;
139
+ "top" === subTitleVerticalAlign ? (null === (_50 = this._subTitle) || void 0 === _50 || _50.setAttribute("y", subTitleYStart),
140
+ null === (_51 = this._subTitle) || void 0 === _51 || _51.setAttribute("textBaseline", "top")) : "middle" === subTitleVerticalAlign ? (null === (_52 = this._subTitle) || void 0 === _52 || _52.setAttribute("y", subTitleYStart + subTitleHeight / 2),
141
+ null === (_53 = this._subTitle) || void 0 === _53 || _53.setAttribute("textBaseline", "middle")) : "bottom" === subTitleVerticalAlign && (null === (_54 = this._subTitle) || void 0 === _54 || _54.setAttribute("y", subTitleYStart + subTitleHeight),
142
+ null === (_55 = this._subTitle) || void 0 === _55 || _55.setAttribute("textBaseline", "bottom"));
175
143
  }
176
144
  }
177
145
  }