@visactor/vrender-components 0.20.1-alpha.4 → 0.20.1-alpha.6

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 (80) hide show
  1. package/cjs/axis/base.d.ts +1 -0
  2. package/cjs/axis/base.js +4 -3
  3. package/cjs/axis/base.js.map +1 -1
  4. package/cjs/axis/constant.d.ts +1 -0
  5. package/cjs/axis/constant.js +1 -1
  6. package/cjs/axis/constant.js.map +1 -1
  7. package/cjs/axis/line.js +30 -23
  8. package/cjs/axis/line.js.map +1 -1
  9. package/cjs/axis/overlap/auto-rotate.js +3 -3
  10. package/cjs/axis/overlap/auto-rotate.js.map +1 -1
  11. package/cjs/axis/tick-data/continuous.js +6 -8
  12. package/cjs/axis/tick-data/continuous.js.map +1 -1
  13. package/cjs/axis/type.d.ts +1 -0
  14. package/cjs/axis/type.js.map +1 -1
  15. package/cjs/crosshair/polygon.js +1 -2
  16. package/cjs/data-zoom/config.js +2 -1
  17. package/cjs/index.d.ts +1 -1
  18. package/cjs/index.js +1 -1
  19. package/cjs/index.js.map +1 -1
  20. package/cjs/indicator/indicator.js +4 -3
  21. package/cjs/indicator/indicator.js.map +1 -1
  22. package/cjs/label/arc.js +15 -2
  23. package/cjs/label/arc.js.map +1 -1
  24. package/cjs/label/base.js +15 -2
  25. package/cjs/label/base.js.map +1 -1
  26. package/cjs/label/dataLabel.js +14 -2
  27. package/cjs/label/dataLabel.js.map +1 -1
  28. package/cjs/label/line.js +21 -3
  29. package/cjs/label/line.js.map +1 -1
  30. package/cjs/label/polygon.js +14 -2
  31. package/cjs/label/polygon.js.map +1 -1
  32. package/cjs/label/rect.js +14 -1
  33. package/cjs/label/rect.js.map +1 -1
  34. package/cjs/label/symbol.js +14 -2
  35. package/cjs/label/symbol.js.map +1 -1
  36. package/cjs/poptip/contribution.js +3 -3
  37. package/cjs/poptip/contribution.js.map +1 -1
  38. package/cjs/util/align.js +31 -51
  39. package/cjs/util/align.js.map +1 -1
  40. package/dist/index.es.js +100 -95
  41. package/es/axis/base.d.ts +1 -0
  42. package/es/axis/base.js +4 -3
  43. package/es/axis/base.js.map +1 -1
  44. package/es/axis/constant.d.ts +1 -0
  45. package/es/axis/constant.js +1 -1
  46. package/es/axis/constant.js.map +1 -1
  47. package/es/axis/line.js +30 -22
  48. package/es/axis/line.js.map +1 -1
  49. package/es/axis/overlap/auto-rotate.js +3 -3
  50. package/es/axis/overlap/auto-rotate.js.map +1 -1
  51. package/es/axis/tick-data/continuous.js +6 -8
  52. package/es/axis/tick-data/continuous.js.map +1 -1
  53. package/es/axis/type.d.ts +1 -0
  54. package/es/axis/type.js.map +1 -1
  55. package/es/crosshair/polygon.js +1 -2
  56. package/es/data-zoom/config.js +2 -1
  57. package/es/index.d.ts +1 -1
  58. package/es/index.js +1 -1
  59. package/es/index.js.map +1 -1
  60. package/es/indicator/indicator.js +4 -3
  61. package/es/indicator/indicator.js.map +1 -1
  62. package/es/label/arc.js +15 -2
  63. package/es/label/arc.js.map +1 -1
  64. package/es/label/base.js +15 -2
  65. package/es/label/base.js.map +1 -1
  66. package/es/label/dataLabel.js +14 -2
  67. package/es/label/dataLabel.js.map +1 -1
  68. package/es/label/line.js +21 -3
  69. package/es/label/line.js.map +1 -1
  70. package/es/label/polygon.js +14 -2
  71. package/es/label/polygon.js.map +1 -1
  72. package/es/label/rect.js +14 -1
  73. package/es/label/rect.js.map +1 -1
  74. package/es/label/symbol.js +14 -2
  75. package/es/label/symbol.js.map +1 -1
  76. package/es/poptip/contribution.js +3 -3
  77. package/es/poptip/contribution.js.map +1 -1
  78. package/es/util/align.js +31 -51
  79. package/es/util/align.js.map +1 -1
  80. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/poptip/contribution.ts"],"names":[],"mappings":";;;;;;;;;AAQA,yDAAoD;AACpD,qCAAkC;AAClC,6CAAyC;AACzC,mCAAgC;AAEhC,SAAS,UAAU,CAAC,MAA2B,EAAE,MAA2B;IA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AAC;gBACf,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;gBACxB,MAAM,GAAG,GAAG,CAAC;gBACb,MAAM,CAAC,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAK,OAAO,CAAC,SAAiB,CAAC,IAAI,CAAC;aACpE;YACD,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;YACzC,IAAI,CAAC,eAAe,CAAC,aAAa,+BAChC,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,KAAK,EACf,gBAAgB,EAAE,KAAK,IACpB,MAAM,KACT,CAAC,EAAE,MAAM,CAAC,CAAC,EACX,CAAC,EAAE,MAAM,CAAC,CAAC,IACX,CAAC;YAEH,WAAW,CAAC,KAAK,CAAC,uBAAuB,EAAE,CAAC;YAC5C,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;YAC5E,IAAI,gBAAgB,EAAE;gBACpB,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aAC5C;SACF;aAAM,IAAI,OAAO,CAAC,WAAW,KAAK,CAAC,EAAE;YACpC,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC;YACxB,IAAI,CAAC,eAAe;gBAClB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;oBACjC,UAAU,EAAE,KAAK;iBAClB,CAAC,CAAC;SACN;IACH,CAAC;CACF,CAAA;AAhEY,wBAAwB;IADpC,IAAA,yBAAU,GAAE;GACA,wBAAwB,CAgEpC;AAhEY,4DAAwB","file":"contribution.js","sourcesContent":["import type {\n IContext2d,\n IGraphic,\n IGraphicAttribute,\n IInteractiveSubRenderContribution,\n IThemeAttribute,\n IDrawContext\n} from '@visactor/vrender-core';\nimport { injectable } from '@visactor/vrender-core';\nimport { PopTip } from './poptip';\nimport { merge } from '@visactor/vutils';\nimport { theme } from './theme';\n\nfunction wrapPoptip(target: Record<string, any>, source: Record<string, any>) {\n merge(target, theme.poptip, source);\n return target;\n}\n\n@injectable()\nexport class PopTipRenderContribution implements IInteractiveSubRenderContribution {\n declare poptipComponent: PopTip;\n render(\n graphic: IGraphic<Partial<IGraphicAttribute>>,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ): void {\n if (graphic._showPoptip === 1) {\n const { visible, visibleCb } = (graphic.attribute as any).poptip || {};\n if (visible === false || (visibleCb && visibleCb(graphic) === false)) {\n return;\n }\n const attribute = {};\n merge(\n attribute,\n PopTip.defaultAttributes,\n (graphic.attribute as any).poptip ? (graphic.attribute as any).poptip : {}\n );\n if (!this.poptipComponent) {\n this.poptipComponent = new PopTip(attribute);\n } else {\n this.poptipComponent.initAttributes(attribute);\n }\n // 如果text图元没有配置title和content的话\n let poptip = (graphic.attribute as any).poptip || {};\n if (graphic.type === 'text' && poptip.title == null && poptip.content == null) {\n const out = {};\n wrapPoptip(out, poptip);\n poptip = out;\n poptip.content = poptip.content ?? (graphic.attribute as any).text;\n }\n const matrix = graphic.globalTransMatrix;\n this.poptipComponent.setAttributes({\n visibleAll: true,\n pickable: false,\n childrenPickable: false,\n ...poptip,\n x: matrix.e,\n y: matrix.f\n });\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n interactiveLayer.add(this.poptipComponent);\n }\n } else if (graphic._showPoptip === 2) {\n graphic._showPoptip = 0;\n this.poptipComponent &&\n this.poptipComponent.setAttributes({\n visibleAll: false\n });\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../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EY,4DAAwB","file":"contribution.js","sourcesContent":["import type {\n IContext2d,\n IGraphic,\n IGraphicAttribute,\n IInteractiveSubRenderContribution,\n IThemeAttribute,\n IDrawContext\n} from '@visactor/vrender-core';\nimport { injectable } from '@visactor/vrender-core';\nimport { PopTip } from './poptip';\nimport { merge } from '@visactor/vutils';\nimport { theme } from './theme';\n\nfunction wrapPoptip(target: Record<string, any>, source: Record<string, any>) {\n merge(target, theme.poptip, source);\n return target;\n}\n\n@injectable()\nexport class PopTipRenderContribution implements IInteractiveSubRenderContribution {\n declare poptipComponent: PopTip;\n render(\n graphic: IGraphic<Partial<IGraphicAttribute>>,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ): void {\n if (graphic._showPoptip === 1) {\n const { visible, visibleCb } = (graphic.attribute as any).poptip || {};\n if (visible === false || (visibleCb && visibleCb(graphic) === false)) {\n return;\n }\n const attribute = {};\n merge(\n attribute,\n PopTip.defaultAttributes,\n (graphic.attribute as any).poptip ? (graphic.attribute as any).poptip : {}\n );\n if (!this.poptipComponent) {\n this.poptipComponent = new PopTip(attribute);\n } else {\n this.poptipComponent.initAttributes(attribute);\n }\n // 如果text图元没有配置title和content的话\n let poptip = (graphic.attribute as any).poptip || {};\n if (graphic.type === 'text' && poptip.title == null && poptip.content == null) {\n const out = {};\n wrapPoptip(out, poptip);\n poptip = out;\n poptip.content = poptip.content ?? (graphic.attribute as any).text;\n }\n const matrix = graphic.globalTransMatrix;\n this.poptipComponent.setAttributes({\n visibleAll: true,\n pickable: false,\n childrenPickable: false,\n ...poptip,\n x: matrix.e,\n y: matrix.f\n });\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n interactiveLayer.add(this.poptipComponent);\n }\n } else if (graphic._showPoptip === 2) {\n graphic._showPoptip = 0;\n if (this.poptipComponent) {\n this.poptipComponent.setAttributes({\n visibleAll: false\n });\n this.poptipComponent.parent?.removeChild(this.poptipComponent);\n }\n }\n }\n}\n"]}
package/cjs/util/align.js CHANGED
@@ -1,57 +1,37 @@
1
1
  "use strict";
2
2
 
3
3
  function alignAxisLabels(labels, start, containerSize, orient, align) {
4
- if ("right" === orient || "left" === orient) {
5
- if ("left" === align) {
6
- const flag = "right" === orient ? 0 : -1;
7
- labels.forEach((label => {
8
- label.setAttributes({
9
- x: start + containerSize * flag,
10
- textAlign: "left"
11
- });
12
- }));
13
- } else if ("right" === align) {
14
- const flag = "right" === orient ? 1 : 0;
15
- labels.forEach((label => {
16
- label.setAttributes({
17
- x: start + containerSize * flag,
18
- textAlign: "right"
19
- });
20
- }));
21
- } else if ("center" === align) {
22
- const flag = "right" === orient ? 1 : -1;
23
- labels.forEach((label => {
24
- label.setAttributes({
25
- x: start + .5 * containerSize * flag,
26
- textAlign: "center"
27
- });
28
- }));
29
- }
30
- } else if ("bottom" === orient || "top" === orient) if ("top" === align) {
31
- const flag = "bottom" === orient ? 0 : -1;
32
- labels.forEach((label => {
33
- label.setAttributes({
34
- y: start + containerSize * flag,
35
- textBaseline: "top"
36
- });
37
- }));
38
- } else if ("bottom" === align) {
39
- const flag = "bottom" === orient ? 1 : 0;
40
- labels.forEach((label => {
41
- label.setAttributes({
42
- y: start + containerSize * flag,
43
- textBaseline: "bottom"
44
- });
45
- }));
46
- } else if ("middle" === align) {
47
- const flag = "bottom" === orient ? 1 : -1;
48
- labels.forEach((label => {
49
- label.setAttributes({
50
- y: start + .5 * containerSize * flag,
51
- textBaseline: "middle"
52
- });
53
- }));
54
- }
4
+ "left" === orient || "right" === orient ? "left" === align ? labels.forEach((label => {
5
+ var _a;
6
+ label.setAttributes({
7
+ dx: (null !== (_a = label.attribute.dx) && void 0 !== _a ? _a : 0) + start - label.AABBBounds.x1
8
+ });
9
+ })) : "right" === align ? labels.forEach((label => {
10
+ var _a;
11
+ label.setAttributes({
12
+ dx: (null !== (_a = label.attribute.dx) && void 0 !== _a ? _a : 0) + start + containerSize - label.AABBBounds.x2
13
+ });
14
+ })) : "center" === align && labels.forEach((label => {
15
+ var _a;
16
+ label.setAttributes({
17
+ dx: (null !== (_a = label.attribute.dx) && void 0 !== _a ? _a : 0) + start + containerSize / 2 - (label.AABBBounds.x1 + label.AABBBounds.x2) / 2
18
+ });
19
+ })) : "bottom" !== orient && "top" !== orient || ("top" === align ? labels.forEach((label => {
20
+ var _a;
21
+ label.setAttributes({
22
+ dy: (null !== (_a = label.attribute.dy) && void 0 !== _a ? _a : 0) + start - label.AABBBounds.y1
23
+ });
24
+ })) : "bottom" === align ? labels.forEach((label => {
25
+ var _a;
26
+ label.setAttributes({
27
+ dy: (null !== (_a = label.attribute.dy) && void 0 !== _a ? _a : 0) + start + containerSize - label.AABBBounds.y2
28
+ });
29
+ })) : "middle" === align && labels.forEach((label => {
30
+ var _a;
31
+ label.setAttributes({
32
+ dy: (null !== (_a = label.attribute.dy) && void 0 !== _a ? _a : 0) + start + containerSize / 2 - (label.AABBBounds.y1 + label.AABBBounds.y2) / 2
33
+ });
34
+ })));
55
35
  }
56
36
 
57
37
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/util/align.ts"],"names":[],"mappings":";;;AAEA,SAAgB,eAAe,CAAC,MAAe,EAAE,KAAa,EAAE,aAAqB,EAAE,MAAc,EAAE,KAAa;IAClH,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,MAAM,EAAE;QAC3C,IAAI,KAAK,KAAK,MAAM,EAAE;YACpB,MAAM,IAAI,GAAG,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,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EAAE,KAAK,GAAG,aAAa,GAAG,IAAI;oBAC/B,YAAY,EAAE,KAAK;iBACpB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;aAAM,IAAI,KAAK,KAAK,QAAQ,EAAE;YAC7B,MAAM,IAAI,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACrB,KAAK,CAAC,aAAa,CAAC;oBAClB,CAAC,EAAE,KAAK,GAAG,aAAa,GAAG,IAAI;oBAC/B,YAAY,EAAE,QAAQ;iBACvB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;aAAM,IAAI,KAAK,KAAK,QAAQ,EAAE;YAC7B,MAAM,IAAI,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACrB,KAAK,CAAC,aAAa,CAAC;oBAClB,CAAC,EAAE,KAAK,GAAG,aAAa,GAAG,GAAG,GAAG,IAAI;oBACrC,YAAY,EAAE,QAAQ;iBACvB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;KACF;AACH,CAAC;AAtDD,0CAsDC","file":"align.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\n\nexport function alignAxisLabels(labels: IText[], start: number, containerSize: number, orient: string, align: string) {\n if (orient === 'right' || orient === 'left') {\n if (align === 'left') {\n const flag = orient === 'right' ? 0 : -1;\n labels.forEach(label => {\n label.setAttributes({\n x: start + containerSize * flag,\n textAlign: 'left'\n });\n });\n } else if (align === 'right') {\n const flag = orient === 'right' ? 1 : 0;\n labels.forEach(label => {\n label.setAttributes({\n x: start + containerSize * flag,\n textAlign: 'right'\n });\n });\n } else if (align === 'center') {\n const flag = orient === 'right' ? 1 : -1;\n labels.forEach(label => {\n label.setAttributes({\n x: start + containerSize * 0.5 * flag,\n textAlign: 'center'\n });\n });\n }\n } else if (orient === 'bottom' || orient === 'top') {\n if (align === 'top') {\n const flag = orient === 'bottom' ? 0 : -1;\n labels.forEach(label => {\n label.setAttributes({\n y: start + containerSize * flag,\n textBaseline: 'top'\n });\n });\n } else if (align === 'bottom') {\n const flag = orient === 'bottom' ? 1 : 0;\n labels.forEach(label => {\n label.setAttributes({\n y: start + containerSize * flag,\n textBaseline: 'bottom'\n });\n });\n } else if (align === 'middle') {\n const flag = orient === 'bottom' ? 1 : -1;\n labels.forEach(label => {\n label.setAttributes({\n y: start + containerSize * 0.5 * flag,\n textBaseline: 'middle'\n });\n });\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/util/align.ts"],"names":[],"mappings":";;;AAEA,SAAgB,eAAe,CAAC,MAAe,EAAE,KAAa,EAAE,aAAqB,EAAE,MAAc,EAAE,KAAa;IAClH,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,OAAO,EAAE;QAC3C,IAAI,KAAK,KAAK,MAAM,EAAE;YACpB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;;gBACrB,KAAK,CAAC,aAAa,CAAC;oBAClB,EAAE,EAAE,CAAC,MAAA,KAAK,CAAC,SAAS,CAAC,EAAE,mCAAI,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,EAAE;iBAC5D,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;aAAM,IAAI,KAAK,KAAK,OAAO,EAAE;YAC5B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;;gBACrB,KAAK,CAAC,aAAa,CAAC;oBAClB,EAAE,EAAE,CAAC,MAAA,KAAK,CAAC,SAAS,CAAC,EAAE,mCAAI,CAAC,CAAC,GAAG,KAAK,GAAG,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,EAAE;iBAC5E,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;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mCAAI,CAAC,CAAC,GAAG,KAAK,GAAG,aAAa,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC;iBAC5G,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;KACF;AACH,CAAC;AA1CD,0CA0CC","file":"align.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\n\nexport function alignAxisLabels(labels: IText[], start: number, containerSize: number, orient: string, align: string) {\n if (orient === 'left' || orient === 'right') {\n if (align === 'left') {\n labels.forEach(label => {\n label.setAttributes({\n dx: (label.attribute.dx ?? 0) + start - label.AABBBounds.x1\n });\n });\n } else if (align === 'right') {\n labels.forEach(label => {\n label.setAttributes({\n dx: (label.attribute.dx ?? 0) + start + containerSize - label.AABBBounds.x2\n });\n });\n } else if (align === 'center') {\n labels.forEach(label => {\n label.setAttributes({\n dx: (label.attribute.dx ?? 0) + start + containerSize / 2 - (label.AABBBounds.x1 + label.AABBBounds.x2) / 2\n });\n });\n }\n } else if (orient === 'bottom' || orient === 'top') {\n if (align === 'top') {\n labels.forEach(label => {\n label.setAttributes({\n dy: (label.attribute.dy ?? 0) + start - label.AABBBounds.y1\n });\n });\n } else if (align === 'bottom') {\n labels.forEach(label => {\n label.setAttributes({\n dy: (label.attribute.dy ?? 0) + start + containerSize - label.AABBBounds.y2\n });\n });\n } else if (align === 'middle') {\n labels.forEach(label => {\n label.setAttributes({\n dy: (label.attribute.dy ?? 0) + start + containerSize / 2 - (label.AABBBounds.y1 + label.AABBBounds.y2) / 2\n });\n });\n }\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -15166,7 +15166,7 @@ function wrapPoptip(target, source) {
15166
15166
  }
15167
15167
  let PopTipRenderContribution = class PopTipRenderContribution {
15168
15168
  render(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
15169
- var _a;
15169
+ var _a, _b;
15170
15170
  if (graphic._showPoptip === 1) {
15171
15171
  const { visible, visibleCb } = graphic.attribute.poptip || {};
15172
15172
  if (visible === false || (visibleCb && visibleCb(graphic) === false)) {
@@ -15197,10 +15197,12 @@ let PopTipRenderContribution = class PopTipRenderContribution {
15197
15197
  }
15198
15198
  else if (graphic._showPoptip === 2) {
15199
15199
  graphic._showPoptip = 0;
15200
- this.poptipComponent &&
15200
+ if (this.poptipComponent) {
15201
15201
  this.poptipComponent.setAttributes({
15202
15202
  visibleAll: false
15203
15203
  });
15204
+ (_b = this.poptipComponent.parent) === null || _b === void 0 ? void 0 : _b.removeChild(this.poptipComponent);
15205
+ }
15204
15206
  }
15205
15207
  }
15206
15208
  };
@@ -16069,7 +16071,8 @@ class LabelBase extends AbstractComponent {
16069
16071
  this._bmpTool = bmpTool;
16070
16072
  }
16071
16073
  constructor(attributes, options) {
16072
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, LabelBase.defaultAttributes, attributes));
16074
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16075
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, LabelBase.defaultAttributes, restAttributes)));
16073
16076
  this.name = 'label';
16074
16077
  this._onHover = (e) => {
16075
16078
  const target = e.target;
@@ -16771,7 +16774,8 @@ const getLabelComponent = (type) => {
16771
16774
 
16772
16775
  class SymbolLabel extends LabelBase {
16773
16776
  constructor(attributes, options) {
16774
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, SymbolLabel.defaultAttributes, attributes));
16777
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16778
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, SymbolLabel.defaultAttributes, restAttributes)));
16775
16779
  this.name = 'symbol-label';
16776
16780
  }
16777
16781
  labeling(textBounds, graphicBounds, position = 'top', offset = 0) {
@@ -16792,7 +16796,8 @@ const registerSymbolDataLabel = () => {
16792
16796
 
16793
16797
  class RectLabel extends LabelBase {
16794
16798
  constructor(attributes, options) {
16795
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, RectLabel.defaultAttributes, attributes));
16799
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16800
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, RectLabel.defaultAttributes, restAttributes)));
16796
16801
  }
16797
16802
  labeling(textBounds, graphicBounds, position = 'top', offset = 0) {
16798
16803
  if (!textBounds || !graphicBounds) {
@@ -16846,14 +16851,25 @@ const registerRectDataLabel = () => {
16846
16851
 
16847
16852
  class LineLabel extends LabelBase {
16848
16853
  constructor(attributes, options) {
16849
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, LineLabel.defaultAttributes, attributes));
16854
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16855
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, LineLabel.defaultAttributes, restAttributes)));
16850
16856
  this.name = 'line-label';
16851
16857
  }
16852
16858
  getGraphicBounds(graphic, point = {}, position = 'end') {
16853
16859
  if (!graphic || (graphic.type !== 'line' && graphic.type !== 'area')) {
16854
16860
  return super.getGraphicBounds(graphic, point);
16855
16861
  }
16856
- const points = graphic.attribute.points || [point];
16862
+ let points = graphic.attribute.points;
16863
+ const segments = graphic.attribute.segments;
16864
+ if (!points && segments && segments.length) {
16865
+ points = segments.reduce((res, seg) => {
16866
+ var _a;
16867
+ return res.concat((_a = seg.points) !== null && _a !== void 0 ? _a : []);
16868
+ }, []);
16869
+ }
16870
+ if (!points || points.length === 0) {
16871
+ points = [point];
16872
+ }
16857
16873
  const index = position === 'start' ? 0 : points.length - 1;
16858
16874
  if (!points[index]) {
16859
16875
  return;
@@ -16909,7 +16925,8 @@ class ArcInfo {
16909
16925
  }
16910
16926
  class ArcLabel extends LabelBase {
16911
16927
  constructor(attributes, options) {
16912
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, ArcLabel.defaultAttributes, attributes));
16928
+ const { data } = attributes, restAttributes = __rest(attributes, ["data"]);
16929
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ data }, merge({}, ArcLabel.defaultAttributes, restAttributes)));
16913
16930
  this.name = 'arc-label';
16914
16931
  this._ellipsisWidth = 0;
16915
16932
  this._arcLeft = new Map();
@@ -17630,7 +17647,8 @@ const registerArcDataLabel = () => {
17630
17647
 
17631
17648
  class DataLabel extends AbstractComponent {
17632
17649
  constructor(attributes, options) {
17633
- super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, DataLabel.defaultAttributes, attributes));
17650
+ const { dataLabels } = attributes, restAttributes = __rest(attributes, ["dataLabels"]);
17651
+ super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : Object.assign({ dataLabels }, merge({}, DataLabel.defaultAttributes, restAttributes)));
17634
17652
  this.name = 'data-label';
17635
17653
  }
17636
17654
  render() {
@@ -18010,6 +18028,7 @@ var AXIS_ELEMENT_NAME;
18010
18028
  AXIS_ELEMENT_NAME["line"] = "axis-line";
18011
18029
  AXIS_ELEMENT_NAME["background"] = "axis-background";
18012
18030
  AXIS_ELEMENT_NAME["axisLabelBackground"] = "axis-label-background";
18031
+ AXIS_ELEMENT_NAME["axisBreak"] = "axis-break";
18013
18032
  AXIS_ELEMENT_NAME["axisBreakSymbol"] = "axis-break-symbol";
18014
18033
  })(AXIS_ELEMENT_NAME || (AXIS_ELEMENT_NAME = {}));
18015
18034
  var AxisStateValue;
@@ -18366,7 +18385,8 @@ class AxisBase extends AbstractComponent {
18366
18385
  let maxTextHeight = 0;
18367
18386
  let textAlign = 'center';
18368
18387
  let textBaseline = 'middle';
18369
- labels.forEach((label) => {
18388
+ let labelPos = 0;
18389
+ labels.forEach((label, index) => {
18370
18390
  var _a;
18371
18391
  const labelStyle = label.attribute;
18372
18392
  const angle = (_a = labelStyle.angle) !== null && _a !== void 0 ? _a : 0;
@@ -18381,10 +18401,14 @@ class AxisBase extends AbstractComponent {
18381
18401
  maxTextHeight = Math.max(maxTextHeight, textHeight);
18382
18402
  textAlign = labelStyle.textAlign;
18383
18403
  textBaseline = labelStyle.textBaseline;
18404
+ if (index === 0) {
18405
+ labelPos = labelStyle.x;
18406
+ }
18384
18407
  });
18385
18408
  this.axisLabelLayerSize[layer] = {
18386
18409
  width: maxTextWidth,
18387
18410
  height: maxTextHeight,
18411
+ labelPos,
18388
18412
  textAlign,
18389
18413
  textBaseline
18390
18414
  };
@@ -18876,11 +18900,11 @@ function getXAxisLabelAlign(orient, angle = 0) {
18876
18900
  };
18877
18901
  }
18878
18902
  function getYAxisLabelAlign(orient, angle = 0) {
18879
- let align = ['right', 'right', 'center', 'left', 'center', 'left', 'center', 'right', 'right'];
18903
+ let align = ['right', 'right', 'center', 'left', 'left', 'left', 'center', 'right', 'right'];
18880
18904
  let baseline = ['middle', 'middle', 'top', 'top', 'middle', 'middle', 'bottom', 'bottom', 'middle'];
18881
18905
  if (orient === 'right') {
18882
- align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];
18883
- baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
18906
+ align = ['left', 'left', 'center', 'right', 'right', 'right', 'center', 'left', 'left'];
18907
+ baseline = ['middle', 'middle', 'bottom', 'bottom', 'middle', 'middle', 'top', 'middle', 'middle'];
18884
18908
  }
18885
18909
  angle = clampAngle(angle);
18886
18910
  const step = angle / (Math.PI * 0.5);
@@ -18972,60 +18996,54 @@ function autoLimit(labels, config) {
18972
18996
  }
18973
18997
 
18974
18998
  function alignAxisLabels(labels, start, containerSize, orient, align) {
18975
- if (orient === 'right' || orient === 'left') {
18999
+ if (orient === 'left' || orient === 'right') {
18976
19000
  if (align === 'left') {
18977
- const flag = orient === 'right' ? 0 : -1;
18978
19001
  labels.forEach(label => {
19002
+ var _a;
18979
19003
  label.setAttributes({
18980
- x: start + containerSize * flag,
18981
- textAlign: 'left'
19004
+ dx: ((_a = label.attribute.dx) !== null && _a !== void 0 ? _a : 0) + start - label.AABBBounds.x1
18982
19005
  });
18983
19006
  });
18984
19007
  }
18985
19008
  else if (align === 'right') {
18986
- const flag = orient === 'right' ? 1 : 0;
18987
19009
  labels.forEach(label => {
19010
+ var _a;
18988
19011
  label.setAttributes({
18989
- x: start + containerSize * flag,
18990
- textAlign: 'right'
19012
+ dx: ((_a = label.attribute.dx) !== null && _a !== void 0 ? _a : 0) + start + containerSize - label.AABBBounds.x2
18991
19013
  });
18992
19014
  });
18993
19015
  }
18994
19016
  else if (align === 'center') {
18995
- const flag = orient === 'right' ? 1 : -1;
18996
19017
  labels.forEach(label => {
19018
+ var _a;
18997
19019
  label.setAttributes({
18998
- x: start + containerSize * 0.5 * flag,
18999
- textAlign: 'center'
19020
+ dx: ((_a = label.attribute.dx) !== null && _a !== void 0 ? _a : 0) + start + containerSize / 2 - (label.AABBBounds.x1 + label.AABBBounds.x2) / 2
19000
19021
  });
19001
19022
  });
19002
19023
  }
19003
19024
  }
19004
19025
  else if (orient === 'bottom' || orient === 'top') {
19005
19026
  if (align === 'top') {
19006
- const flag = orient === 'bottom' ? 0 : -1;
19007
19027
  labels.forEach(label => {
19028
+ var _a;
19008
19029
  label.setAttributes({
19009
- y: start + containerSize * flag,
19010
- textBaseline: 'top'
19030
+ dy: ((_a = label.attribute.dy) !== null && _a !== void 0 ? _a : 0) + start - label.AABBBounds.y1
19011
19031
  });
19012
19032
  });
19013
19033
  }
19014
19034
  else if (align === 'bottom') {
19015
- const flag = orient === 'bottom' ? 1 : 0;
19016
19035
  labels.forEach(label => {
19036
+ var _a;
19017
19037
  label.setAttributes({
19018
- y: start + containerSize * flag,
19019
- textBaseline: 'bottom'
19038
+ dy: ((_a = label.attribute.dy) !== null && _a !== void 0 ? _a : 0) + start + containerSize - label.AABBBounds.y2
19020
19039
  });
19021
19040
  });
19022
19041
  }
19023
19042
  else if (align === 'middle') {
19024
- const flag = orient === 'bottom' ? 1 : -1;
19025
19043
  labels.forEach(label => {
19044
+ var _a;
19026
19045
  label.setAttributes({
19027
- y: start + containerSize * 0.5 * flag,
19028
- textBaseline: 'middle'
19046
+ dy: ((_a = label.attribute.dy) !== null && _a !== void 0 ? _a : 0) + start + containerSize / 2 - (label.AABBBounds.y1 + label.AABBBounds.y2) / 2
19029
19047
  });
19030
19048
  });
19031
19049
  }
@@ -19088,30 +19106,39 @@ class LineAxis extends AxisBase {
19088
19106
  _renderInner(container) {
19089
19107
  var _a;
19090
19108
  if (this.attribute.breaks && this.attribute.breaks.length) {
19091
- this._breaks = this.attribute.breaks
19092
- .sort((preBreak, currBreak) => preBreak.range[0] - currBreak.range[1])
19093
- .map(breakProps => {
19094
- const { range, breakSymbol } = breakProps;
19095
- return {
19109
+ const transformedBreaks = [];
19110
+ for (let index = 0; index < this.attribute.breaks.length; index++) {
19111
+ const aBreak = this.attribute.breaks[index];
19112
+ const { range, breakSymbol, rawRange } = aBreak;
19113
+ transformedBreaks.push({
19096
19114
  startPoint: this.getTickCoord(range[0]),
19097
19115
  endPoint: this.getTickCoord(range[1]),
19098
19116
  range,
19099
- breakSymbol
19100
- };
19101
- });
19117
+ breakSymbol,
19118
+ rawRange
19119
+ });
19120
+ }
19121
+ this._breaks = transformedBreaks;
19102
19122
  }
19103
19123
  super._renderInner(container);
19104
19124
  if (this._breaks && this._breaks.length) {
19105
- this._breaks.forEach(b => {
19106
- const { startPoint, endPoint, breakSymbol } = b;
19125
+ this._breaks.forEach((b, index) => {
19126
+ const { startPoint, endPoint, breakSymbol, rawRange } = b;
19107
19127
  if ((breakSymbol === null || breakSymbol === void 0 ? void 0 : breakSymbol.visible) !== false) {
19128
+ const axisBreakGroup = graphicCreator.group({
19129
+ zIndex: 99
19130
+ });
19131
+ axisBreakGroup.name = AXIS_ELEMENT_NAME.axisBreak;
19132
+ axisBreakGroup.id = this._getNodeId(`${AXIS_ELEMENT_NAME.axisBreak}-${index}`);
19133
+ axisBreakGroup.data = rawRange;
19108
19134
  const symbolStyle = getAxisBreakSymbolAttrs(breakSymbol);
19109
19135
  const shape1 = graphicCreator.symbol(Object.assign({ x: startPoint.x, y: startPoint.y }, symbolStyle));
19110
19136
  shape1.name = AXIS_ELEMENT_NAME.axisBreakSymbol;
19111
19137
  const shape2 = graphicCreator.symbol(Object.assign({ x: endPoint.x, y: endPoint.y }, symbolStyle));
19112
19138
  shape2.name = AXIS_ELEMENT_NAME.axisBreakSymbol;
19113
- container.add(shape1);
19114
- container.add(shape2);
19139
+ axisBreakGroup.add(shape1);
19140
+ axisBreakGroup.add(shape2);
19141
+ container.add(axisBreakGroup);
19115
19142
  }
19116
19143
  });
19117
19144
  }
@@ -19187,9 +19214,20 @@ class LineAxis extends AxisBase {
19187
19214
  }
19188
19215
  else {
19189
19216
  if (axisVector[0] === 0) {
19190
- const boundsWidth = this.axisLabelsContainer ? this.axisLabelsContainer.AABBBounds.width() : 0;
19191
- if (isFinite(boundsWidth)) {
19192
- labelLength += boundsWidth + (layerCount - 1) * space;
19217
+ if (this.axisLabelsContainer &&
19218
+ this.axisLabelsContainer.AABBBounds &&
19219
+ !this.axisLabelsContainer.AABBBounds.empty()) {
19220
+ const baseX = this.axisLabelLayerSize[0].labelPos;
19221
+ const bounds = this.axisLabelsContainer.AABBBounds;
19222
+ labelLength +=
19223
+ (factor === 1
19224
+ ? bounds.x2 > baseX
19225
+ ? Math.min(bounds.x2 - baseX, bounds.width())
19226
+ : 0
19227
+ : bounds.x1 < baseX
19228
+ ? Math.min(baseX - bounds.x1, bounds.width())
19229
+ : 0) +
19230
+ (layerCount - 1) * space;
19193
19231
  }
19194
19232
  else {
19195
19233
  labelLength = 0;
@@ -19200,36 +19238,6 @@ class LineAxis extends AxisBase {
19200
19238
  labelLength += this.axisLabelLayerSize[layer].width + (index > 0 ? space : 0);
19201
19239
  });
19202
19240
  }
19203
- const textAlign = this.axisLabelLayerSize[0].textAlign;
19204
- const isTextAlignStart = textAlign === 'start' || textAlign === 'left';
19205
- const isTextCenter = textAlign === 'center';
19206
- const isReverse = axisVector[1] > 0;
19207
- if (factor === 1) {
19208
- labelLength = isReverse
19209
- ? isTextAlignStart
19210
- ? labelLength
19211
- : isTextCenter
19212
- ? labelLength / 2
19213
- : space
19214
- : isTextAlignStart
19215
- ? space
19216
- : isTextCenter
19217
- ? labelLength / 2
19218
- : labelLength;
19219
- }
19220
- else {
19221
- labelLength = isReverse
19222
- ? isTextAlignStart
19223
- ? space
19224
- : isTextCenter
19225
- ? labelLength / 2
19226
- : labelLength
19227
- : isTextAlignStart
19228
- ? labelLength
19229
- : isTextCenter
19230
- ? labelLength / 2
19231
- : space;
19232
- }
19233
19241
  }
19234
19242
  }
19235
19243
  let tickLength = 0;
@@ -19517,13 +19525,13 @@ class LineAxis extends AxisBase {
19517
19525
  if (isValid(this.attribute.label.containerAlign)) {
19518
19526
  let start;
19519
19527
  if (orient === 'left') {
19520
- start = axisLabelContainerBounds.x2;
19528
+ start = axisLabelContainerBounds.x2 - axisLabelContainerSize;
19521
19529
  }
19522
19530
  else if (orient === 'right') {
19523
19531
  start = axisLabelContainerBounds.x1;
19524
19532
  }
19525
19533
  else if (orient === 'top') {
19526
- start = axisLabelContainerBounds.y2;
19534
+ start = axisLabelContainerBounds.y2 - axisLabelContainerSize;
19527
19535
  }
19528
19536
  else if (orient === 'bottom') {
19529
19537
  start = axisLabelContainerBounds.y1;
@@ -19923,22 +19931,18 @@ function getScaleTicks(op, scale, count, getTicks) {
19923
19931
  let scaleTicks;
19924
19932
  const { breakData } = op;
19925
19933
  if (breakData) {
19926
- const { scope, range: breakRanges } = breakData();
19934
+ const { range: breakRanges } = breakData();
19927
19935
  const domain = scale.domain();
19928
19936
  scaleTicks = [];
19929
19937
  for (let i = 0; i < domain.length; i++) {
19930
19938
  if (i < domain.length - 1) {
19931
19939
  const range = [domain[i], domain[i + 1]];
19932
- const [start, end] = scope[i];
19933
- const subCount = (end - start) * count;
19934
- if (subCount > 0) {
19935
- const ticks = getTicks(subCount > 1 ? Math.floor(subCount) : 1, range);
19936
- ticks.forEach(tick => {
19937
- if (!breakRanges.some((breakRange) => tick >= breakRange[0] && tick <= breakRange[1])) {
19938
- scaleTicks.push(tick);
19939
- }
19940
- });
19941
- }
19940
+ const ticks = getTicks(count, range);
19941
+ ticks.forEach(tick => {
19942
+ if (!breakRanges.some((breakRange) => tick >= breakRange[0] && tick <= breakRange[1])) {
19943
+ scaleTicks.push(tick);
19944
+ }
19945
+ });
19942
19946
  }
19943
19947
  }
19944
19948
  scale.domain(domain);
@@ -19998,8 +20002,9 @@ const continuousTicks = (scale, op) => {
19998
20002
  AABBBounds: bounds,
19999
20003
  value: scaleTicks[i]
20000
20004
  }));
20005
+ const samplingMethod = breakData ? methods.greedy : methods.parity;
20001
20006
  while (items.length >= 3 && hasOverlap(items, labelGap)) {
20002
- items = methods.parity(items);
20007
+ items = samplingMethod(items, labelGap);
20003
20008
  }
20004
20009
  const ticks = items.map(item => item.value);
20005
20010
  if (ticks.length < 3 && labelFlush) {
@@ -26206,14 +26211,14 @@ class Indicator extends AbstractComponent {
26206
26211
  return undefined;
26207
26212
  }
26208
26213
  render() {
26209
- var _a;
26214
+ var _a, _b;
26210
26215
  this.removeAllChild(true);
26211
26216
  if (this.attribute.visible !== true) {
26212
26217
  return;
26213
26218
  }
26214
26219
  const { title = {}, content, size, limitRatio = Infinity } = this.attribute;
26215
26220
  const limit = Math.min(size.width, size.height) * limitRatio;
26216
- const group = this.createOrUpdateChild('indicator-container', { x: 0, y: 0, zIndex: 1 }, 'group');
26221
+ const group = this.createOrUpdateChild('indicator-container', { x: 0, y: 0, zIndex: 1, pickable: (_a = this.attribute.pickable) !== null && _a !== void 0 ? _a : true }, 'group');
26217
26222
  if (isValid(title)) {
26218
26223
  this._title = this._renderText(group, title, limit, limitRatio, 'title.style', 'indicator-title');
26219
26224
  }
@@ -26229,7 +26234,7 @@ class Indicator extends AbstractComponent {
26229
26234
  }
26230
26235
  this._setGlobalAutoFit(limit);
26231
26236
  this._setYPosition();
26232
- const totalHeight = (_a = group === null || group === void 0 ? void 0 : group.AABBBounds.height()) !== null && _a !== void 0 ? _a : 0;
26237
+ const totalHeight = (_b = group === null || group === void 0 ? void 0 : group.AABBBounds.height()) !== null && _b !== void 0 ? _b : 0;
26233
26238
  group.setAttribute('y', size.height / 2 - totalHeight / 2);
26234
26239
  group.setAttribute('x', size.width / 2);
26235
26240
  }
@@ -28618,6 +28623,6 @@ EmptyTip.defaultAttributes = {
28618
28623
  }
28619
28624
  };
28620
28625
 
28621
- const version = "0.20.1-alpha.4";
28626
+ const version = "0.20.1-alpha.6";
28622
28627
 
28623
28628
  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, getAxisBreakSymbolAttrs, 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/base.d.ts CHANGED
@@ -22,6 +22,7 @@ export declare abstract class AxisBase<T extends AxisBaseAttributes> extends Abs
22
22
  height: number;
23
23
  textAlign: string;
24
24
  textBaseline: string;
25
+ labelPos: number;
25
26
  }>;
26
27
  protected axisLabelsContainer: IGroup | null;
27
28
  protected axisContainer: IGroup;
package/es/axis/base.js CHANGED
@@ -82,17 +82,18 @@ export class AxisBase extends AbstractComponent {
82
82
  this.beforeLabelsOverlap(labels, axisItems, layerLabelGroup, layer, items.length),
83
83
  this.handleLabelsOverlap(labels, axisItems, layerLabelGroup, layer, items.length),
84
84
  this.afterLabelsOverlap(labels, axisItems, layerLabelGroup, layer, items.length);
85
- let maxTextWidth = 0, maxTextHeight = 0, textAlign = "center", textBaseline = "middle";
86
- labels.forEach((label => {
85
+ let maxTextWidth = 0, maxTextHeight = 0, textAlign = "center", textBaseline = "middle", labelPos = 0;
86
+ labels.forEach(((label, index) => {
87
87
  var _a;
88
88
  const labelStyle = label.attribute, angle = null !== (_a = labelStyle.angle) && void 0 !== _a ? _a : 0, textBounds = label.AABBBounds;
89
89
  let textWidth = textBounds.width(), textHeight = textBounds.height();
90
90
  angle && (textWidth = Math.abs(textWidth * Math.cos(angle)), textHeight = Math.abs(textHeight * Math.sin(angle))),
91
91
  maxTextWidth = Math.max(maxTextWidth, textWidth), maxTextHeight = Math.max(maxTextHeight, textHeight),
92
- textAlign = labelStyle.textAlign, textBaseline = labelStyle.textBaseline;
92
+ textAlign = labelStyle.textAlign, textBaseline = labelStyle.textBaseline, 0 === index && (labelPos = labelStyle.x);
93
93
  })), this.axisLabelLayerSize[layer] = {
94
94
  width: maxTextWidth,
95
95
  height: maxTextHeight,
96
+ labelPos: labelPos,
96
97
  textAlign: textAlign,
97
98
  textBaseline: textBaseline
98
99
  };