@visactor/vrender-components 0.12.3 → 0.13.0

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 (147) hide show
  1. package/cjs/axis/base.d.ts +2 -1
  2. package/cjs/axis/base.js +8 -6
  3. package/cjs/axis/base.js.map +1 -1
  4. package/cjs/axis/circle.d.ts +3 -2
  5. package/cjs/axis/circle.js +1 -0
  6. package/cjs/axis/circle.js.map +1 -1
  7. package/cjs/axis/line.d.ts +3 -2
  8. package/cjs/axis/line.js +26 -4
  9. package/cjs/axis/line.js.map +1 -1
  10. package/cjs/axis/overlap/auto-hide.d.ts +9 -0
  11. package/cjs/axis/overlap/auto-hide.js +62 -0
  12. package/cjs/axis/overlap/auto-hide.js.map +1 -0
  13. package/cjs/axis/overlap/auto-limit.d.ts +8 -0
  14. package/cjs/axis/overlap/auto-limit.js +21 -0
  15. package/cjs/axis/overlap/auto-limit.js.map +1 -0
  16. package/cjs/axis/overlap/auto-rotate.d.ts +7 -0
  17. package/cjs/axis/overlap/auto-rotate.js +103 -0
  18. package/cjs/axis/overlap/auto-rotate.js.map +1 -0
  19. package/cjs/axis/type.d.ts +20 -11
  20. package/cjs/axis/type.js.map +1 -1
  21. package/cjs/index.d.ts +2 -1
  22. package/cjs/index.js +10 -9
  23. package/cjs/index.js.map +1 -1
  24. package/cjs/legend/discrete/discrete.js +1 -1
  25. package/cjs/legend/discrete/discrete.js.map +1 -1
  26. package/cjs/marker/area.d.ts +4 -3
  27. package/cjs/marker/area.js +12 -4
  28. package/cjs/marker/area.js.map +1 -1
  29. package/cjs/marker/base.d.ts +5 -4
  30. package/cjs/marker/base.js +5 -5
  31. package/cjs/marker/base.js.map +1 -1
  32. package/cjs/marker/line.d.ts +4 -3
  33. package/cjs/marker/line.js +17 -6
  34. package/cjs/marker/line.js.map +1 -1
  35. package/cjs/marker/point.d.ts +16 -8
  36. package/cjs/marker/point.js +54 -26
  37. package/cjs/marker/point.js.map +1 -1
  38. package/cjs/poptip/contribution.d.ts +6 -0
  39. package/cjs/poptip/contribution.js +34 -0
  40. package/cjs/poptip/contribution.js.map +1 -0
  41. package/cjs/poptip/index.d.ts +3 -0
  42. package/cjs/poptip/index.js +22 -0
  43. package/cjs/poptip/index.js.map +1 -0
  44. package/cjs/poptip/poptip-plugin.d.ts +14 -0
  45. package/cjs/poptip/poptip-plugin.js +43 -0
  46. package/cjs/poptip/poptip-plugin.js.map +1 -0
  47. package/cjs/poptip/poptip.d.ts +13 -0
  48. package/cjs/poptip/poptip.js +201 -0
  49. package/cjs/poptip/poptip.js.map +1 -0
  50. package/cjs/poptip/register.d.ts +3 -0
  51. package/cjs/poptip/register.js +17 -0
  52. package/cjs/poptip/register.js.map +1 -0
  53. package/cjs/poptip/type.d.ts +29 -0
  54. package/cjs/poptip/type.js +6 -0
  55. package/cjs/poptip/type.js.map +1 -0
  56. package/cjs/segment/segment.d.ts +2 -2
  57. package/cjs/segment/segment.js +3 -1
  58. package/cjs/segment/segment.js.map +1 -1
  59. package/cjs/segment/type.d.ts +3 -2
  60. package/cjs/segment/type.js.map +1 -1
  61. package/cjs/tag/tag.d.ts +1 -1
  62. package/cjs/tag/tag.js +1 -1
  63. package/cjs/tag/tag.js.map +1 -1
  64. package/cjs/tooltip/tooltip.js +29 -15
  65. package/cjs/tooltip/tooltip.js.map +1 -1
  66. package/cjs/tooltip/type.d.ts +5 -2
  67. package/cjs/tooltip/type.js.map +1 -1
  68. package/cjs/tooltip/util.d.ts +3 -1
  69. package/cjs/tooltip/util.js +18 -1
  70. package/cjs/tooltip/util.js.map +1 -1
  71. package/cjs/util/text.d.ts +3 -2
  72. package/cjs/util/text.js.map +1 -1
  73. package/dist/index.js +761 -74
  74. package/dist/index.min.js +1 -1
  75. package/es/axis/base.d.ts +2 -1
  76. package/es/axis/base.js +7 -6
  77. package/es/axis/base.js.map +1 -1
  78. package/es/axis/circle.d.ts +3 -2
  79. package/es/axis/circle.js +1 -0
  80. package/es/axis/circle.js.map +1 -1
  81. package/es/axis/line.d.ts +3 -2
  82. package/es/axis/line.js +32 -4
  83. package/es/axis/line.js.map +1 -1
  84. package/es/axis/overlap/auto-hide.d.ts +9 -0
  85. package/es/axis/overlap/auto-hide.js +53 -0
  86. package/es/axis/overlap/auto-hide.js.map +1 -0
  87. package/es/axis/overlap/auto-limit.d.ts +8 -0
  88. package/es/axis/overlap/auto-limit.js +13 -0
  89. package/es/axis/overlap/auto-limit.js.map +1 -0
  90. package/es/axis/overlap/auto-rotate.d.ts +7 -0
  91. package/es/axis/overlap/auto-rotate.js +95 -0
  92. package/es/axis/overlap/auto-rotate.js.map +1 -0
  93. package/es/axis/type.d.ts +20 -11
  94. package/es/axis/type.js.map +1 -1
  95. package/es/index.d.ts +2 -1
  96. package/es/index.js +3 -1
  97. package/es/index.js.map +1 -1
  98. package/es/legend/discrete/discrete.js +1 -1
  99. package/es/legend/discrete/discrete.js.map +1 -1
  100. package/es/marker/area.d.ts +4 -3
  101. package/es/marker/area.js +12 -4
  102. package/es/marker/area.js.map +1 -1
  103. package/es/marker/base.d.ts +5 -4
  104. package/es/marker/base.js +5 -5
  105. package/es/marker/base.js.map +1 -1
  106. package/es/marker/line.d.ts +4 -3
  107. package/es/marker/line.js +17 -6
  108. package/es/marker/line.js.map +1 -1
  109. package/es/marker/point.d.ts +16 -8
  110. package/es/marker/point.js +54 -26
  111. package/es/marker/point.js.map +1 -1
  112. package/es/poptip/contribution.d.ts +6 -0
  113. package/es/poptip/contribution.js +31 -0
  114. package/es/poptip/contribution.js.map +1 -0
  115. package/es/poptip/index.d.ts +3 -0
  116. package/es/poptip/index.js +6 -0
  117. package/es/poptip/index.js.map +1 -0
  118. package/es/poptip/poptip-plugin.d.ts +14 -0
  119. package/es/poptip/poptip-plugin.js +41 -0
  120. package/es/poptip/poptip-plugin.js.map +1 -0
  121. package/es/poptip/poptip.d.ts +13 -0
  122. package/es/poptip/poptip.js +194 -0
  123. package/es/poptip/poptip.js.map +1 -0
  124. package/es/poptip/register.d.ts +3 -0
  125. package/es/poptip/register.js +17 -0
  126. package/es/poptip/register.js.map +1 -0
  127. package/es/poptip/type.d.ts +29 -0
  128. package/es/poptip/type.js +2 -0
  129. package/es/poptip/type.js.map +1 -0
  130. package/es/segment/segment.d.ts +2 -2
  131. package/es/segment/segment.js +3 -1
  132. package/es/segment/segment.js.map +1 -1
  133. package/es/segment/type.d.ts +3 -2
  134. package/es/segment/type.js.map +1 -1
  135. package/es/tag/tag.d.ts +1 -1
  136. package/es/tag/tag.js +1 -1
  137. package/es/tag/tag.js.map +1 -1
  138. package/es/tooltip/tooltip.js +30 -15
  139. package/es/tooltip/tooltip.js.map +1 -1
  140. package/es/tooltip/type.d.ts +5 -2
  141. package/es/tooltip/type.js.map +1 -1
  142. package/es/tooltip/util.d.ts +3 -1
  143. package/es/tooltip/util.js +16 -1
  144. package/es/tooltip/util.js.map +1 -1
  145. package/es/util/text.d.ts +3 -2
  146. package/es/util/text.js.map +1 -1
  147. package/package.json +8 -7
package/dist/index.js CHANGED
@@ -644,7 +644,7 @@
644
644
  }
645
645
  }
646
646
  const { visible: bgVisible, ...backgroundStyle } = panel;
647
- if (vutils.isBoolean(bgVisible)) {
647
+ if (visible && vutils.isBoolean(bgVisible)) {
648
648
  const bgRect = this.createOrUpdateChild('tag-panel', {
649
649
  ...backgroundStyle,
650
650
  visible: bgVisible && !!text,
@@ -660,6 +660,305 @@
660
660
  }
661
661
  }
662
662
 
663
+ class PopTip extends AbstractComponent {
664
+ name = 'poptip';
665
+ static defaultAttributes = {
666
+ position: 'rt',
667
+ visible: true,
668
+ title: null,
669
+ content: null,
670
+ titleStyle: {
671
+ fontSize: 12,
672
+ fill: '#000',
673
+ textAlign: 'left',
674
+ textBaseline: 'top'
675
+ },
676
+ contentStyle: {
677
+ fontSize: 12,
678
+ fill: '#000',
679
+ textAlign: 'left',
680
+ textBaseline: 'top'
681
+ },
682
+ space: 8,
683
+ padding: 10
684
+ };
685
+ constructor(attributes) {
686
+ super(vutils.merge({}, PopTip.defaultAttributes, attributes));
687
+ }
688
+ render() {
689
+ const { title = '', titleStyle = {}, position, content = '', contentStyle = {}, panel = {}, space = 4, minWidth = 0, maxWidth = Infinity, padding = 4, visible, state, dx = 0, dy = 0 } = this.attribute;
690
+ const parsedPadding = vutils.normalizePadding(padding);
691
+ const group = this.createOrUpdateChild('poptip-content', { x: 0, y: 0, zIndex: 1 }, 'group');
692
+ const maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3];
693
+ const titleVisible = vutils.isValid(title) && visible !== false;
694
+ const titleAttrs = {
695
+ text: title,
696
+ visible: titleVisible,
697
+ ...titleStyle,
698
+ x: parsedPadding[3],
699
+ y: parsedPadding[0],
700
+ maxLineWidth,
701
+ textAlign: 'left',
702
+ textBaseline: 'top'
703
+ };
704
+ const titleShape = group.createOrUpdateChild('poptip-title', titleAttrs, 'text');
705
+ if (!vutils.isEmpty(state?.title)) {
706
+ titleShape.states = state.title;
707
+ }
708
+ const titleBounds = titleShape.AABBBounds;
709
+ const titleHeight = titleBounds.height();
710
+ const titleWidth = titleBounds.width();
711
+ let height = titleHeight + space;
712
+ if (!titleVisible) {
713
+ height = 0;
714
+ }
715
+ const contentVisible = vutils.isValid(content) && visible !== false;
716
+ const contentAttrs = {
717
+ text: content,
718
+ visible: contentVisible,
719
+ ...contentStyle,
720
+ x: parsedPadding[3],
721
+ y: parsedPadding[0] + height,
722
+ maxLineWidth,
723
+ textAlign: 'left',
724
+ textBaseline: 'top'
725
+ };
726
+ const contentShape = group.createOrUpdateChild('poptip-content', contentAttrs, 'text');
727
+ if (!vutils.isEmpty(state?.content)) {
728
+ contentShape.states = state.content;
729
+ }
730
+ const contentBounds = contentShape.AABBBounds;
731
+ const contentHeight = contentBounds.height();
732
+ const contentWidth = contentBounds.width();
733
+ if (contentVisible) {
734
+ height += contentHeight;
735
+ }
736
+ let popTipWidth = vutils.max(titleWidth + parsedPadding[1] + parsedPadding[3], contentWidth + parsedPadding[1] + parsedPadding[3]);
737
+ if (popTipWidth > maxWidth) {
738
+ popTipWidth = maxWidth;
739
+ }
740
+ else if (popTipWidth < minWidth) {
741
+ popTipWidth = minWidth;
742
+ }
743
+ const poptipHeight = parsedPadding[0] + parsedPadding[2] + height;
744
+ const { visible: bgVisible, ...backgroundStyle } = panel;
745
+ const symbolSize = backgroundStyle.size ?? 12;
746
+ const lineWidth = backgroundStyle.lineWidth ?? 1;
747
+ const { angle, offset, rectOffset } = this.getAngleAndOffset(position, popTipWidth, poptipHeight, vutils.isArray(symbolSize) ? symbolSize : [symbolSize, symbolSize - lineWidth]);
748
+ if (vutils.isBoolean(bgVisible)) {
749
+ const offsetX = (vutils.isArray(symbolSize) ? symbolSize[0] : symbolSize) / 4;
750
+ const bgSymbol = group.createOrUpdateChild('poptip-symbol-panel', {
751
+ ...backgroundStyle,
752
+ visible: bgVisible && (contentVisible || titleVisible),
753
+ x: offsetX,
754
+ y: 0,
755
+ anchor: [0, 0],
756
+ symbolType: 'arrow2Left',
757
+ angle: angle,
758
+ dx: offset[0],
759
+ dy: offset[1],
760
+ size: symbolSize,
761
+ zIndex: -9
762
+ }, 'symbol');
763
+ if (!vutils.isEmpty(state?.panel)) {
764
+ bgSymbol.states = state.panel;
765
+ }
766
+ const bgRect = group.createOrUpdateChild('poptip-rect-panel', {
767
+ ...backgroundStyle,
768
+ visible: bgVisible && (contentVisible || titleVisible),
769
+ x: 0,
770
+ y: 0,
771
+ width: popTipWidth,
772
+ height: poptipHeight,
773
+ zIndex: -10
774
+ }, 'rect');
775
+ if (!vutils.isEmpty(state?.panel)) {
776
+ bgRect.states = state.panel;
777
+ }
778
+ }
779
+ group.setAttributes({
780
+ x: -offset[0] + dx,
781
+ y: -offset[1] + dy
782
+ });
783
+ }
784
+ getAngleAndOffset(position, width, height, size) {
785
+ const sizeH = size[1] / 2;
786
+ switch (position) {
787
+ case 'tl':
788
+ return {
789
+ angle: (vutils.pi / 2) * 3,
790
+ offset: [width / 4, height + sizeH],
791
+ rectOffset: [-width / 4, -height - size[1]]
792
+ };
793
+ case 'top':
794
+ return { angle: (vutils.pi / 2) * 3, offset: [width / 2, height + sizeH], rectOffset: [0, -height - size[1]] };
795
+ case 'tr':
796
+ return {
797
+ angle: (vutils.pi / 2) * 3,
798
+ offset: [(width / 4) * 3, height + sizeH],
799
+ rectOffset: [(width / 4) * 3, -height - size[1]]
800
+ };
801
+ case 'rt':
802
+ return { angle: 0, offset: [-sizeH, height / 5], rectOffset: [(width / 4) * 3, -height - size[1]] };
803
+ case 'right':
804
+ return { angle: 0, offset: [-sizeH, height / 2], rectOffset: [(width / 4) * 3, -height - size[1]] };
805
+ case 'rb':
806
+ return { angle: 0, offset: [-sizeH, (height / 5) * 4], rectOffset: [(width / 4) * 3, -height - size[1]] };
807
+ case 'bl':
808
+ return { angle: vutils.pi / 2, offset: [width / 4, -sizeH], rectOffset: [-width / 4, -height - size[1]] };
809
+ case 'bottom':
810
+ return { angle: vutils.pi / 2, offset: [width / 2, -sizeH], rectOffset: [0, -height - size[1]] };
811
+ case 'br':
812
+ return { angle: vutils.pi / 2, offset: [(width / 4) * 3, -sizeH], rectOffset: [(width / 4) * 3, -height - size[1]] };
813
+ case 'lt':
814
+ return { angle: vutils.pi, offset: [width + sizeH, height / 5], rectOffset: [-width / 4, -height - size[1]] };
815
+ case 'left':
816
+ return { angle: vutils.pi, offset: [width + sizeH, height / 2], rectOffset: [0, -height - size[1]] };
817
+ case 'lb':
818
+ return {
819
+ angle: vutils.pi,
820
+ offset: [width + sizeH, (height / 5) * 4],
821
+ rectOffset: [(width / 4) * 3, -height - size[1]]
822
+ };
823
+ }
824
+ }
825
+ }
826
+
827
+ var PARAM_TYPES = "inversify:paramtypes";
828
+ var DESIGN_PARAM_TYPES = "design:paramtypes";
829
+
830
+ function _typeof(obj) {
831
+ "@babel/helpers - typeof";
832
+
833
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
834
+ return typeof obj;
835
+ } : function (obj) {
836
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
837
+ }, _typeof(obj);
838
+ }
839
+
840
+ var idCounter = 0;
841
+ function id() {
842
+ return idCounter++;
843
+ }
844
+
845
+ var DUPLICATED_INJECTABLE_DECORATOR = "Cannot apply @injectable decorator multiple times.";
846
+
847
+ var ContainerModule = function () {
848
+ function ContainerModule(registry) {
849
+ this.id = id();
850
+ this.registry = registry;
851
+ }
852
+ return ContainerModule;
853
+ }();
854
+
855
+ function injectable() {
856
+ return function (target) {
857
+ if (Reflect.hasOwnMetadata(PARAM_TYPES, target)) {
858
+ throw new Error(DUPLICATED_INJECTABLE_DECORATOR);
859
+ }
860
+ var types = Reflect.getMetadata(DESIGN_PARAM_TYPES, target) || [];
861
+ Reflect.defineMetadata(PARAM_TYPES, types, target);
862
+ return target;
863
+ };
864
+ }
865
+
866
+ function __decorate(decorators, target, key, desc) {
867
+ var c = arguments.length,
868
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
869
+ d;
870
+ if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
871
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
872
+ }
873
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
874
+ var e = new Error(message);
875
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
876
+ };
877
+
878
+ let PopTipRenderContribution = class PopTipRenderContribution {
879
+ render(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
880
+ if (graphic._showPoptip) {
881
+ const { visible, visibleCb } = graphic.attribute.poptip;
882
+ if (visible === false || (visibleCb && visibleCb(graphic) === false)) {
883
+ return;
884
+ }
885
+ if (!this.poptipComponent) {
886
+ this.poptipComponent = new PopTip(graphic.attribute.poptip);
887
+ }
888
+ this.poptipComponent.setAttributes({
889
+ ...graphic.attribute.poptip,
890
+ x: 0,
891
+ y: 0,
892
+ postMatrix: graphic.globalTransMatrix
893
+ });
894
+ const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');
895
+ if (interactiveLayer) {
896
+ interactiveLayer.add(this.poptipComponent);
897
+ }
898
+ }
899
+ }
900
+ };
901
+ PopTipRenderContribution = __decorate([
902
+ injectable()
903
+ ], PopTipRenderContribution);
904
+
905
+ let PopTipPlugin = class PopTipPlugin {
906
+ name = 'poptip';
907
+ activeEvent = 'onRegister';
908
+ pluginService;
909
+ _uid = vrender.Generator.GenAutoIncrementId();
910
+ key = this.name + this._uid;
911
+ activeGraphic;
912
+ activate(context) {
913
+ this.pluginService = context;
914
+ const { stage } = this.pluginService;
915
+ stage.addEventListener('pointerover', this.poptip);
916
+ }
917
+ poptip = (e) => {
918
+ const graphic = e.target;
919
+ if (graphic.isContainer || !graphic.attribute || graphic === this.activeGraphic) {
920
+ this.unpoptip(e);
921
+ return;
922
+ }
923
+ const { poptip } = graphic.attribute;
924
+ if (poptip) {
925
+ graphic._showPoptip = true;
926
+ }
927
+ if (this.activeGraphic) {
928
+ this.activeGraphic._showPoptip = false;
929
+ }
930
+ this.setActiveGraphic(graphic, true);
931
+ };
932
+ unpoptip = (e) => {
933
+ if (!this.activeGraphic) {
934
+ return;
935
+ }
936
+ this.activeGraphic._showPoptip = false;
937
+ this.setActiveGraphic(null, true);
938
+ };
939
+ setActiveGraphic(graphic, rerender) {
940
+ this.activeGraphic = graphic;
941
+ this.pluginService.stage.renderNextFrame();
942
+ }
943
+ deactivate(context) {
944
+ const { stage } = this.pluginService;
945
+ stage.removeEventListener('pointerover', this.poptip);
946
+ }
947
+ };
948
+ PopTipPlugin = __decorate([
949
+ injectable()
950
+ ], PopTipPlugin);
951
+
952
+ const module = new ContainerModule(bind => {
953
+ bind(PopTipRenderContribution).toSelf().inSingletonScope();
954
+ bind(vrender.InteractiveSubRenderContribution).toService(PopTipRenderContribution);
955
+ bind(PopTipPlugin).toSelf().inSingletonScope();
956
+ bind(vrender.AutoEnablePlugins).toService(PopTipPlugin);
957
+ });
958
+ function enablePoptip() {
959
+ vrender.container.load(module);
960
+ }
961
+
663
962
  class CrosshairBase extends AbstractComponent {
664
963
  name = 'crosshair';
665
964
  render() {
@@ -1938,6 +2237,7 @@
1938
2237
  _startAngle;
1939
2238
  _endAngle;
1940
2239
  static defaultAttributes = {
2240
+ visible: true,
1941
2241
  lineStyle: {
1942
2242
  lineWidth: 1,
1943
2243
  stroke: '#000'
@@ -1985,7 +2285,10 @@
1985
2285
  }
1986
2286
  render() {
1987
2287
  this.removeAllChild();
1988
- const { points, startSymbol, endSymbol, lineStyle, state } = this.attribute;
2288
+ const { points, startSymbol, endSymbol, lineStyle, state, visible = true } = this.attribute;
2289
+ if (!visible) {
2290
+ return;
2291
+ }
1989
2292
  if (points.length > 1) {
1990
2293
  this.computeLineAngle();
1991
2294
  }
@@ -2292,7 +2595,9 @@
2292
2595
  this.axisLabelsContainer = labelGroup;
2293
2596
  axisContainer.add(labelGroup);
2294
2597
  items.forEach((axisItems, layer) => {
2295
- this.renderLabels(labelGroup, axisItems, layer);
2598
+ const layerLabelGroup = this.renderLabels(labelGroup, axisItems, layer);
2599
+ const labels = layerLabelGroup.getChildren();
2600
+ this.handleLabelsOverlap(labels, axisItems, layer, items.length);
2296
2601
  });
2297
2602
  }
2298
2603
  if (grid?.visible) {
@@ -2357,13 +2662,11 @@
2357
2662
  }
2358
2663
  }
2359
2664
  renderLabels(container, items, layer) {
2360
- let data;
2361
- if (layer === 0) {
2362
- data = this.data;
2363
- }
2364
- else {
2365
- data = this._transformItems(items);
2665
+ const { dataFilter } = this.attribute.label;
2666
+ if (dataFilter && vutils.isFunction(dataFilter)) {
2667
+ items = dataFilter(items, layer);
2366
2668
  }
2669
+ const data = this._transformItems(items);
2367
2670
  const labelGroup = vrender.createGroup({ x: 0, y: 0, pickable: false });
2368
2671
  labelGroup.name = `${exports.AXIS_ELEMENT_NAME.labelContainer}-layer-${layer}`;
2369
2672
  labelGroup.id = this._getNodeId(`label-container-layer-${layer}`);
@@ -2440,13 +2743,13 @@
2440
2743
  const { tick } = this.attribute;
2441
2744
  const data = this.data;
2442
2745
  const tickLineItems = [];
2443
- const { alignWithLabel, inside = false, length } = tick;
2746
+ const { alignWithLabel, inside = false, length, dataFilter } = tick;
2444
2747
  let tickSegment = 1;
2445
2748
  const count = data.length;
2446
2749
  if (count >= 2) {
2447
2750
  tickSegment = data[1].value - data[0].value;
2448
2751
  }
2449
- data.forEach((item) => {
2752
+ (dataFilter && vutils.isFunction(dataFilter) ? dataFilter(data) : data).forEach((item) => {
2450
2753
  let point = item.point;
2451
2754
  let tickValue = item.value;
2452
2755
  if (!alignWithLabel) {
@@ -2602,6 +2905,231 @@
2602
2905
  }
2603
2906
  }
2604
2907
 
2908
+ const methods = {
2909
+ parity: function (items) {
2910
+ return items.filter((item, i) => (i % 2 ? item.setAttribute('opacity', 0) : 1));
2911
+ },
2912
+ greedy: function (items, sep) {
2913
+ let a;
2914
+ return items.filter((b, i) => {
2915
+ if (!i || !intersect(a.AABBBounds, b.AABBBounds, sep)) {
2916
+ a = b;
2917
+ return 1;
2918
+ }
2919
+ return b.setAttribute('opacity', 0);
2920
+ });
2921
+ }
2922
+ };
2923
+ function intersect(a, b, sep) {
2924
+ return sep > Math.max(b.x1 - a.x2, a.x1 - b.x2, b.y1 - a.y2, a.y1 - b.y2);
2925
+ }
2926
+ function hasOverlap(items, pad) {
2927
+ for (let i = 1, n = items.length, a = items[0].AABBBounds, b; i < n; a = b, ++i) {
2928
+ if (intersect(a, (b = items[i].AABBBounds), pad)) {
2929
+ return true;
2930
+ }
2931
+ }
2932
+ }
2933
+ function hasBounds(item) {
2934
+ const b = item.AABBBounds;
2935
+ return b.width() > 1 && b.height() > 1;
2936
+ }
2937
+ function reset(items) {
2938
+ items.forEach(item => item.setAttribute('opacity', 1));
2939
+ return items;
2940
+ }
2941
+ function autoHide(labels, config) {
2942
+ if (vutils.isEmpty(labels)) {
2943
+ return;
2944
+ }
2945
+ const source = labels.filter(hasBounds);
2946
+ if (vutils.isEmpty(source)) {
2947
+ return;
2948
+ }
2949
+ let items;
2950
+ items = reset(source);
2951
+ const { method = 'parity', separation: sep = 0 } = config;
2952
+ const reduce = vutils.isFunction(method) ? method : methods[method] || methods.parity;
2953
+ if (items.length >= 3 && hasOverlap(items, sep)) {
2954
+ do {
2955
+ items = reduce(items, sep);
2956
+ } while (items.length >= 3 && hasOverlap(items, sep));
2957
+ if (items.length < 3 && !vutils.last(source).attribute.opacity) {
2958
+ if (items.length > 1) {
2959
+ vutils.last(items).setAttribute('opacity', 0);
2960
+ }
2961
+ vutils.last(source).setAttribute('opacity', 1);
2962
+ }
2963
+ }
2964
+ source.forEach(item => {
2965
+ item.setAttribute('visible', !!item.attribute.opacity);
2966
+ });
2967
+ }
2968
+
2969
+ function autoRotate(items, rotateConfig) {
2970
+ if (vutils.isEmpty(items)) {
2971
+ return;
2972
+ }
2973
+ const { orient, labelRotateAngle = [0, 45, 90] } = rotateConfig;
2974
+ if (labelRotateAngle.length === 0 || items.some(item => !!item.attribute.angle)) {
2975
+ return;
2976
+ }
2977
+ let i = 0;
2978
+ let n = 0;
2979
+ if (labelRotateAngle && labelRotateAngle.length > 0) {
2980
+ n = labelRotateAngle.length;
2981
+ }
2982
+ while (i < n) {
2983
+ const angle = labelRotateAngle[i++];
2984
+ items.forEach(item => {
2985
+ item.attribute.angle = vutils.degreeToRadian(angle);
2986
+ });
2987
+ tryRotate(orient, items);
2988
+ if (!hasIntersect(items)) {
2989
+ break;
2990
+ }
2991
+ }
2992
+ }
2993
+ function hasIntersect(items) {
2994
+ for (let i = 1; i < items.length; i++) {
2995
+ if (itemIntersect(items[i - 1], items[i])) {
2996
+ return true;
2997
+ }
2998
+ }
2999
+ return false;
3000
+ }
3001
+ function itemIntersect(item1, item2) {
3002
+ return vutils.isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true);
3003
+ }
3004
+ function tryRotate(orient, items) {
3005
+ if (orient === 'bottom' || orient === 'top') {
3006
+ rotateXAxis(orient, items);
3007
+ }
3008
+ if (orient === 'left' || orient === 'right') {
3009
+ rotateYAxis(orient, items);
3010
+ }
3011
+ genRotateBounds(items);
3012
+ }
3013
+ function rotate(x, y, deg, originX, originY) {
3014
+ return {
3015
+ x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,
3016
+ y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY
3017
+ };
3018
+ }
3019
+ function genNormalBounds(item) {
3020
+ const bounds = item.AABBBounds;
3021
+ return {
3022
+ x1: bounds.x1,
3023
+ x2: bounds.x2,
3024
+ y1: bounds.y1,
3025
+ y2: bounds.y2,
3026
+ centerX: item.attribute.x,
3027
+ centerY: item.attribute.y,
3028
+ angle: item.attribute.angle
3029
+ };
3030
+ }
3031
+ function genRotateBounds(items) {
3032
+ items.forEach(item => {
3033
+ const bounds = genNormalBounds(item);
3034
+ const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);
3035
+ const deltaX = rotatedCenter.x - bounds.centerX;
3036
+ const deltaY = rotatedCenter.y - bounds.centerY;
3037
+ bounds.x1 += deltaX;
3038
+ bounds.x2 += deltaX;
3039
+ bounds.y1 += deltaY;
3040
+ bounds.y2 += deltaY;
3041
+ bounds.centerX += deltaX;
3042
+ bounds.centerY += deltaY;
3043
+ item.rotatedBounds = bounds;
3044
+ });
3045
+ }
3046
+ function rotateYAxis(orient, items) {
3047
+ let align = ['right', 'right', 'center', 'left', 'center', 'left', 'center', 'right', 'right'];
3048
+ let baseline = ['middle', 'middle', 'top', 'top', 'middle', 'middle', 'bottom', 'bottom', 'middle'];
3049
+ if (orient === 'right') {
3050
+ align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];
3051
+ baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
3052
+ }
3053
+ items.forEach((item, i) => {
3054
+ let angle = item.attribute.angle || 0;
3055
+ if (angle < 0) {
3056
+ while (angle < 0) {
3057
+ angle += Math.PI * 2;
3058
+ }
3059
+ }
3060
+ if (angle > 0) {
3061
+ while (angle >= Math.PI * 2) {
3062
+ angle -= Math.PI * 2;
3063
+ }
3064
+ }
3065
+ const step = angle / (Math.PI * 0.5);
3066
+ let index;
3067
+ if (step === Math.floor(step)) {
3068
+ index = Math.floor(step) * 2;
3069
+ }
3070
+ else {
3071
+ index = Math.floor(step) * 2 + 1;
3072
+ }
3073
+ item.setAttributes({
3074
+ textAlign: align[index],
3075
+ textBaseline: baseline[index],
3076
+ angle: angle
3077
+ });
3078
+ });
3079
+ }
3080
+ function rotateXAxis(orient, items) {
3081
+ let align = ['center', 'left', 'left', 'left', 'center', 'right', 'right', 'right', 'left'];
3082
+ let baseline = ['top', 'top', 'middle', 'bottom', 'bottom', 'bottom', 'middle', 'top', 'top'];
3083
+ if (orient === 'top') {
3084
+ align = ['center', 'right', 'right', 'right', 'center', 'left', 'left', 'left', 'right'];
3085
+ baseline = ['bottom', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
3086
+ }
3087
+ items.forEach(item => {
3088
+ let angle = item.attribute.angle || 0;
3089
+ if (angle < 0) {
3090
+ while (angle < 0) {
3091
+ angle += Math.PI * 2;
3092
+ }
3093
+ }
3094
+ if (angle > 0) {
3095
+ while (angle >= Math.PI * 2) {
3096
+ angle -= Math.PI * 2;
3097
+ }
3098
+ }
3099
+ const step = angle / (Math.PI * 0.5);
3100
+ let index;
3101
+ if (step === Math.floor(step)) {
3102
+ index = Math.floor(step) * 2;
3103
+ }
3104
+ else {
3105
+ index = Math.floor(step) * 2 + 1;
3106
+ }
3107
+ item.setAttributes({
3108
+ textAlign: align[index],
3109
+ textBaseline: baseline[index],
3110
+ angle
3111
+ });
3112
+ });
3113
+ }
3114
+
3115
+ function autoLimit(labels, config) {
3116
+ const { limitLength, ellipsis = '...', orient } = config;
3117
+ if (vutils.isEmpty(labels) || !vutils.isValidNumber(limitLength)) {
3118
+ return;
3119
+ }
3120
+ labels.forEach(label => {
3121
+ const limitLabelLength = label.attribute.angle === 0 || vutils.isNil(label.attribute.angle)
3122
+ ? orient === 'top' || orient === 'bottom'
3123
+ ? null
3124
+ : limitLength
3125
+ : limitLength / Math.sin(label.attribute.angle);
3126
+ label.setAttributes({
3127
+ maxLineWidth: limitLabelLength,
3128
+ ellipsis
3129
+ });
3130
+ });
3131
+ }
3132
+
2605
3133
  function getCirclePoints(center, count, radius, startAngle, endAngle) {
2606
3134
  const points = [];
2607
3135
  const range = endAngle - startAngle;
@@ -2680,9 +3208,10 @@
2680
3208
  const space = +vutils.get(this.attribute, 'label.space', 4);
2681
3209
  labelLength += space;
2682
3210
  if (axisVector[1] === 0) {
2683
- Object.keys(this.axisLabelLayerSize).forEach((layer, index) => {
2684
- labelLength += this.axisLabelLayerSize[layer].height + (index > 0 ? space : 0);
2685
- });
3211
+ labelLength = this.axisLabelsContainer.AABBBounds.height();
3212
+ }
3213
+ else if (axisVector[0] === 0) {
3214
+ labelLength = this.axisLabelsContainer.AABBBounds.width();
2686
3215
  }
2687
3216
  else {
2688
3217
  Object.keys(this.axisLabelLayerSize).forEach((layer, index) => {
@@ -2910,6 +3439,51 @@
2910
3439
  }
2911
3440
  return base;
2912
3441
  }
3442
+ handleLabelsOverlap(labelShapes, labelData, layer, layerCount) {
3443
+ if (vutils.isEmpty(labelShapes)) {
3444
+ return;
3445
+ }
3446
+ const { verticalLimitSize, label, title, line, tick, orient } = this.attribute;
3447
+ const labelSpace = label.space ?? 4;
3448
+ let limitLength = verticalLimitSize;
3449
+ let titleHeight = 0;
3450
+ let titleSpacing = 0;
3451
+ const axisLineWidth = line?.visible ? line.style.lineWidth ?? 1 : 0;
3452
+ const tickLength = tick?.visible ? tick.length ?? 4 : 0;
3453
+ if (title?.visible) {
3454
+ titleHeight = measureTextSize(title.text, title.textStyle).height;
3455
+ titleSpacing = title.space;
3456
+ }
3457
+ if (limitLength) {
3458
+ limitLength = (limitLength - labelSpace - titleSpacing - titleHeight - axisLineWidth - tickLength) / layerCount;
3459
+ }
3460
+ const { layoutFunc, autoRotate: autoRotate$1, autoRotateAngle, autoLimit: autoLimit$1, limitEllipsis, autoHide: autoHide$1, autoHideMethod, autoHideSeparation } = label;
3461
+ if (vutils.isFunction(layoutFunc)) {
3462
+ layoutFunc(labelShapes, labelData, layer, this);
3463
+ }
3464
+ else {
3465
+ if (autoRotate$1) {
3466
+ autoRotate(labelShapes, {
3467
+ labelRotateAngle: autoRotateAngle,
3468
+ orient
3469
+ });
3470
+ }
3471
+ if (autoLimit$1 && vutils.isValidNumber(limitLength) && limitLength > 0) {
3472
+ autoLimit(labelShapes, {
3473
+ limitLength,
3474
+ ellipsis: limitEllipsis,
3475
+ orient
3476
+ });
3477
+ }
3478
+ if (autoHide$1) {
3479
+ autoHide(labelShapes, {
3480
+ orient,
3481
+ method: autoHideMethod,
3482
+ separation: autoHideSeparation
3483
+ });
3484
+ }
3485
+ }
3486
+ }
2913
3487
  }
2914
3488
 
2915
3489
  class CircleAxis extends AxisBase {
@@ -3164,6 +3738,9 @@
3164
3738
  }
3165
3739
  return base;
3166
3740
  }
3741
+ handleLabelsOverlap(labelShapes, labelData, layer, layerCount) {
3742
+ return;
3743
+ }
3167
3744
  }
3168
3745
 
3169
3746
  function getElMap(g) {
@@ -4184,17 +4761,24 @@
4184
4761
  _container;
4185
4762
  _label;
4186
4763
  render() {
4187
- this.removeAllChild();
4188
4764
  const markerVisible = this.attribute.visible ?? true;
4189
4765
  const markerInteractive = this.attribute.interactive ?? false;
4190
4766
  if (!markerInteractive) {
4191
4767
  this.setAttribute('pickable', false);
4192
4768
  this.setAttribute('childrenPickable', false);
4193
4769
  }
4194
- const group = vrender.createGroup({});
4195
- group.name = 'marker-container';
4196
- this.add(group);
4197
- markerVisible && this.renderMarker(group);
4770
+ if (markerVisible) {
4771
+ if (!this._container) {
4772
+ const group = vrender.createGroup({});
4773
+ group.name = 'marker-container';
4774
+ this.add(group);
4775
+ this._container = group;
4776
+ this.initMarker(group);
4777
+ }
4778
+ else {
4779
+ this.updateMarker();
4780
+ }
4781
+ }
4198
4782
  }
4199
4783
  }
4200
4784
 
@@ -4436,19 +5020,19 @@
4436
5020
  const labelOffsetX = label?.refX * Math.cos(labelAngle) + label.refY * Math.cos(labelAngle - Math.PI / 2);
4437
5021
  const labelOffsetY = label?.refX * Math.sin(labelAngle) + label.refY * Math.sin(labelAngle - Math.PI / 2);
4438
5022
  if (labelPosition.includes('start') || labelPosition.includes('Start')) {
4439
- this._label.setAttributes({
5023
+ this._label?.setAttributes({
4440
5024
  x: points[0].x + labelOffsetX,
4441
5025
  y: points[0].y + labelOffsetY
4442
5026
  });
4443
5027
  }
4444
5028
  else if (labelPosition.includes('middle') || labelPosition.includes('Middle')) {
4445
- this._label.setAttributes({
5029
+ this._label?.setAttributes({
4446
5030
  x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
4447
5031
  y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
4448
5032
  });
4449
5033
  }
4450
5034
  else {
4451
- this._label.setAttributes({
5035
+ this._label?.setAttributes({
4452
5036
  x: points[points.length - 1].x + labelOffsetX,
4453
5037
  y: points[points.length - 1].y + labelOffsetY
4454
5038
  });
@@ -4461,7 +5045,7 @@
4461
5045
  }
4462
5046
  });
4463
5047
  }
4464
- renderMarker(container) {
5048
+ initMarker(container) {
4465
5049
  const { points, startSymbol, endSymbol, label, lineStyle } = this.attribute;
4466
5050
  const line = new Segment({
4467
5051
  points,
@@ -4480,6 +5064,19 @@
4480
5064
  container.add(markLabel);
4481
5065
  this.setLabelPos();
4482
5066
  }
5067
+ updateMarker() {
5068
+ const { points, startSymbol, endSymbol, label, lineStyle } = this.attribute;
5069
+ this._line?.setAttributes({
5070
+ points,
5071
+ startSymbol,
5072
+ endSymbol,
5073
+ lineStyle
5074
+ });
5075
+ this._label?.setAttributes({
5076
+ ...label
5077
+ });
5078
+ this.setLabelPos();
5079
+ }
4483
5080
  }
4484
5081
 
4485
5082
  class MarkArea extends Marker {
@@ -4522,38 +5119,38 @@
4522
5119
  const { label } = this.attribute;
4523
5120
  const labelPosition = label?.position ?? 'middle';
4524
5121
  if (labelPosition.includes('left') || labelPosition.includes('Left')) {
4525
- this._label.setAttributes({
5122
+ this._label?.setAttributes({
4526
5123
  ...this.getLeftPos()
4527
5124
  });
4528
5125
  }
4529
5126
  else if (labelPosition.includes('right') || labelPosition.includes('Right')) {
4530
- this._label.setAttributes({
5127
+ this._label?.setAttributes({
4531
5128
  ...this.getRightPos()
4532
5129
  });
4533
5130
  }
4534
5131
  else if (labelPosition.includes('top') || labelPosition.includes('Top')) {
4535
- this._label.setAttributes({
5132
+ this._label?.setAttributes({
4536
5133
  ...this.getTopPos()
4537
5134
  });
4538
5135
  }
4539
5136
  else if (labelPosition.includes('bottom') || labelPosition.includes('Bottom')) {
4540
- this._label.setAttributes({
5137
+ this._label?.setAttributes({
4541
5138
  ...this.getBottomPos()
4542
5139
  });
4543
5140
  }
4544
5141
  else {
4545
- this._label.setAttributes({
5142
+ this._label?.setAttributes({
4546
5143
  ...this.getMiddlePos()
4547
5144
  });
4548
5145
  }
4549
- this._label.setAttributes({
5146
+ this._label?.setAttributes({
4550
5147
  textStyle: {
4551
5148
  ...DEFAULT_MARK_AREA_TEXT_STYLE_MAP[labelPosition],
4552
5149
  ...label.textStyle
4553
5150
  }
4554
5151
  });
4555
5152
  }
4556
- renderMarker(container) {
5153
+ initMarker(container) {
4557
5154
  const { points, label, areaStyle } = this.attribute;
4558
5155
  const area = vrender.createPolygon({
4559
5156
  points: points,
@@ -4570,6 +5167,17 @@
4570
5167
  container.add(markLabel);
4571
5168
  this.setLabelPos();
4572
5169
  }
5170
+ updateMarker() {
5171
+ const { points, label, areaStyle } = this.attribute;
5172
+ this._area?.setAttributes({
5173
+ points: points,
5174
+ ...areaStyle
5175
+ });
5176
+ this._label?.setAttributes({
5177
+ ...label
5178
+ });
5179
+ this.setLabelPos();
5180
+ }
4573
5181
  }
4574
5182
 
4575
5183
  class MarkPoint extends Marker {
@@ -4588,7 +5196,7 @@
4588
5196
  const itemOffsetX = refX * Math.cos(itemAngle) + refY * Math.cos(itemAngle - Math.PI / 2);
4589
5197
  const itemOffsetY = refX * Math.sin(itemAngle) + refY * Math.sin(itemAngle - Math.PI / 2);
4590
5198
  if (itemType === 'text') {
4591
- item.setAttributes({
5199
+ item?.setAttributes({
4592
5200
  ...textStyle,
4593
5201
  textStyle: {
4594
5202
  ...DEFAULT_MARK_POINT_TEXT_STYLE_MAP[itemContent?.position || 'end'],
@@ -4597,18 +5205,18 @@
4597
5205
  });
4598
5206
  }
4599
5207
  else if (itemType === 'richText') {
4600
- item.setAttributes({
5208
+ item?.setAttributes({
4601
5209
  dx: this.getItemDx(item, position, richTextStyle) + (richTextStyle?.dx || 0),
4602
5210
  dy: this.getItemDy(item, position, richTextStyle) + (richTextStyle?.dy || 0)
4603
5211
  });
4604
5212
  }
4605
5213
  else if (itemType === 'image') {
4606
- item.setAttributes({
5214
+ item?.setAttributes({
4607
5215
  dx: this.getItemDx(item, position, imageStyle) + (imageStyle?.dx || 0),
4608
5216
  dy: this.getItemDy(item, position, imageStyle) + (imageStyle?.dy || 0)
4609
5217
  });
4610
5218
  }
4611
- item.setAttributes({
5219
+ item?.setAttributes({
4612
5220
  x: itemPosition.x + (itemOffsetX || 0),
4613
5221
  y: itemPosition.y + (itemOffsetY || 0),
4614
5222
  angle: autoRotate && itemAngle + refAngle
@@ -4634,7 +5242,7 @@
4634
5242
  }
4635
5243
  return 0;
4636
5244
  }
4637
- renderItem(itemContent, itemPosition) {
5245
+ initItem(itemContent, itemPosition) {
4638
5246
  const { type = 'text', symbolStyle, richTextStyle, imageStyle, renderCustomCallback } = itemContent;
4639
5247
  let item;
4640
5248
  if (type === 'symbol') {
@@ -4666,9 +5274,9 @@
4666
5274
  this.setItemAttributes(item, itemContent, itemPosition, type);
4667
5275
  return item;
4668
5276
  }
4669
- renderItemLine(itemLine, position, itemPosition) {
4670
- const { startSymbol, endSymbol, lineStyle, type = 'type-s' } = itemLine;
5277
+ getItemLineAttr(itemLine, position, itemPosition) {
4671
5278
  let points = [];
5279
+ const { type = 'type-s' } = itemLine;
4672
5280
  if (type === 'type-do') {
4673
5281
  points = [
4674
5282
  position,
@@ -4702,23 +5310,37 @@
4702
5310
  else {
4703
5311
  points = [position, itemPosition];
4704
5312
  }
4705
- const line = new Segment({
5313
+ return points;
5314
+ }
5315
+ setItemLineAttr(itemLine, position, itemPosition, visible) {
5316
+ const { startSymbol, endSymbol, lineStyle } = itemLine;
5317
+ const points = this.getItemLineAttr(itemLine, position, itemPosition);
5318
+ this._line?.setAttributes({
4706
5319
  points,
4707
5320
  startSymbol,
4708
5321
  endSymbol,
4709
- lineStyle
5322
+ lineStyle,
5323
+ visible
4710
5324
  });
4711
- return line;
4712
5325
  }
4713
- renderDecorativeLine(itemLine, itemPosition) {
4714
- const { lineStyle } = itemLine;
5326
+ getDecorativeLineAttr(itemLine, itemPosition) {
4715
5327
  const decorativeLength = itemLine?.decorativeLine?.length || 10;
4716
5328
  const itemAngle = this._line.getEndAngle() || 0;
4717
5329
  const startPointOffsetX = (decorativeLength / 2) * Math.cos(itemAngle - Math.PI / 2);
4718
5330
  const startPointOffsetY = (decorativeLength / 2) * Math.sin(itemAngle - Math.PI / 2);
4719
5331
  const endPointOffsetX = (-decorativeLength / 2) * Math.cos(itemAngle - Math.PI / 2);
4720
5332
  const endPointOffsetY = (-decorativeLength / 2) * Math.sin(itemAngle - Math.PI / 2);
4721
- return vrender.createLine({
5333
+ return {
5334
+ startPointOffsetX,
5335
+ startPointOffsetY,
5336
+ endPointOffsetX,
5337
+ endPointOffsetY
5338
+ };
5339
+ }
5340
+ setDecorativeLineAttr(itemLine, itemPosition, visible) {
5341
+ const { lineStyle } = itemLine;
5342
+ const { startPointOffsetX, startPointOffsetY, endPointOffsetX, endPointOffsetY } = this.getDecorativeLineAttr(itemLine, itemPosition);
5343
+ this._decorativeLine?.setAttributes({
4722
5344
  points: [
4723
5345
  {
4724
5346
  x: itemPosition.x + startPointOffsetX,
@@ -4729,31 +5351,45 @@
4729
5351
  y: itemPosition.y + endPointOffsetY
4730
5352
  }
4731
5353
  ],
4732
- ...lineStyle
5354
+ ...lineStyle,
5355
+ visible
4733
5356
  });
4734
5357
  }
4735
- renderMarker(container) {
5358
+ initMarker(container) {
4736
5359
  const { position, itemLine, itemContent } = this.attribute;
4737
5360
  const itemPosition = {
4738
5361
  x: position.x + (itemContent?.offsetX || 0),
4739
5362
  y: position.y + (itemContent?.offsetY || 0)
4740
5363
  };
4741
- if (itemLine?.visible) {
4742
- const line = this.renderItemLine(itemLine, position, itemPosition);
4743
- line.name = 'mark-point-line';
4744
- this._line = line;
4745
- container.add(line);
4746
- if (itemLine?.decorativeLine?.visible) {
4747
- const decorativeLine = this.renderDecorativeLine(itemLine, itemPosition);
4748
- decorativeLine.name = 'mark-point-decorativeLine';
4749
- this._decorativeLine = decorativeLine;
4750
- container.add(decorativeLine);
4751
- }
4752
- }
4753
- const item = this.renderItem(itemContent, itemPosition);
5364
+ const line = new Segment({
5365
+ points: []
5366
+ });
5367
+ line.name = 'mark-point-line';
5368
+ this._line = line;
5369
+ container.add(line);
5370
+ const decorativeLine = vrender.createLine({
5371
+ points: []
5372
+ });
5373
+ decorativeLine.name = 'mark-point-decorativeLine';
5374
+ this._decorativeLine = decorativeLine;
5375
+ container.add(decorativeLine);
5376
+ this.setItemLineAttr(itemLine, position, itemPosition, itemLine?.visible);
5377
+ this.setDecorativeLineAttr(itemLine, itemPosition, itemLine?.decorativeLine?.visible);
5378
+ const item = this.initItem(itemContent, itemPosition);
4754
5379
  this._item = item;
4755
5380
  container.add(item);
4756
5381
  }
5382
+ updateMarker() {
5383
+ const { position, itemLine, itemContent } = this.attribute;
5384
+ const { type = 'text' } = itemContent;
5385
+ const itemPosition = {
5386
+ x: position.x + (itemContent?.offsetX || 0),
5387
+ y: position.y + (itemContent?.offsetY || 0)
5388
+ };
5389
+ this.setItemLineAttr(itemLine, position, itemPosition, itemLine?.visible);
5390
+ this.setDecorativeLineAttr(itemLine, itemPosition, itemLine?.decorativeLine?.visible);
5391
+ this.setItemAttributes(this._item, itemContent, itemPosition, type);
5392
+ }
4757
5393
  }
4758
5394
 
4759
5395
  const DEFAULT_HANDLER_STYLE = {
@@ -5333,7 +5969,7 @@
5333
5969
  ...shape,
5334
5970
  ...shapeAttr.style
5335
5971
  });
5336
- Object.keys(shapeAttr.state).forEach(key => {
5972
+ Object.keys(shapeAttr.state || {}).forEach(key => {
5337
5973
  const color = shapeAttr.state[key].fill || shapeAttr.state[key].stroke;
5338
5974
  if (shape.fill && vutils.isNil(shapeAttr.state[key].fill) && color) {
5339
5975
  shapeAttr.state[key].fill = color;
@@ -8263,6 +8899,21 @@
8263
8899
  value: valueList.every(vutils.isNil) ? undefined : vutils.merge({}, ...valueList)
8264
8900
  });
8265
8901
  };
8902
+ const getRichTextAttribute = (attr) => {
8903
+ const { width, height, wordBreak = 'break-word', textAlign, textBaseline, text } = attr;
8904
+ return {
8905
+ width,
8906
+ height,
8907
+ wordBreak: wordBreak,
8908
+ textAlign: textAlign,
8909
+ textBaseline: textBaseline,
8910
+ singleLine: false,
8911
+ textConfig: vutils.array(text).map(text => ({
8912
+ ...attr,
8913
+ text
8914
+ }))
8915
+ };
8916
+ };
8266
8917
 
8267
8918
  const defaultAttributes = {
8268
8919
  panel: {
@@ -8376,10 +9027,20 @@
8376
9027
  this._tooltipTitleSymbol = this._tooltipTitleContainer.createOrUpdateChild(`${TOOLTIP_TITLE_NAME}-${TOOLTIP_SHAPE_NAME_SUFFIX}`, vutils.merge({ symbolType: 'circle' }, titleAttr.shape, {
8377
9028
  visible: isVisible(titleAttr) && isVisible(titleAttr.shape)
8378
9029
  }), 'symbol');
9030
+ if (titleAttr.value.multiLine) {
9031
+ this._tooltipTitle = this._tooltipTitleContainer.createOrUpdateChild(`${TOOLTIP_TITLE_NAME}-${TOOLTIP_VALUE_NAME_SUFFIX}`, {
9032
+ visible: isVisible(titleAttr) && isVisible(titleAttr.value),
9033
+ ...getRichTextAttribute(titleAttr.value)
9034
+ }, 'richtext');
9035
+ }
9036
+ else {
9037
+ this._tooltipTitle = this._tooltipTitleContainer.createOrUpdateChild(`${TOOLTIP_TITLE_NAME}-${TOOLTIP_VALUE_NAME_SUFFIX}`, {
9038
+ text: '',
9039
+ visible: isVisible(titleAttr) && isVisible(titleAttr.value),
9040
+ ...titleAttr.value
9041
+ }, 'text');
9042
+ }
8379
9043
  const titlePaddingLeft = isVisible(titleAttr.shape) ? titleAttr.shape.size + titleAttr.shape.spacing : 0;
8380
- this._tooltipTitle = this._tooltipTitleContainer.createOrUpdateChild(`${TOOLTIP_TITLE_NAME}-${TOOLTIP_VALUE_NAME_SUFFIX}`, vutils.merge({ text: '' }, titleAttr.value, {
8381
- visible: isVisible(titleAttr) && isVisible(titleAttr.value)
8382
- }), 'text');
8383
9044
  const { textAlign, textBaseline } = titleAttr.value;
8384
9045
  const contentWidth = panel.width - padding[3] - padding[0] - titlePaddingLeft;
8385
9046
  if (textAlign === 'center') {
@@ -8419,7 +9080,8 @@
8419
9080
  itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_SHAPE_NAME_SUFFIX}`, {
8420
9081
  visible: true,
8421
9082
  x: itemAttr.shape.size / 2,
8422
- y: itemAttr.height / 2,
9083
+ y: itemAttr.shape.size / 2 +
9084
+ ((itemAttr.key.lineHeight ?? itemAttr.key.fontSize) - itemAttr.shape.size) / 2,
8423
9085
  ...itemAttr.shape
8424
9086
  }, 'symbol');
8425
9087
  }
@@ -8427,10 +9089,21 @@
8427
9089
  x += itemAttr.shape.size + itemAttr.shape.spacing;
8428
9090
  }
8429
9091
  if (isVisible(itemAttr.key)) {
8430
- const element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_KEY_NAME_SUFFIX}`, {
8431
- visible: true,
8432
- ...itemAttr.key
8433
- }, 'text');
9092
+ let element;
9093
+ if (itemAttr.key.multiLine) {
9094
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_KEY_NAME_SUFFIX}`, {
9095
+ visible: true,
9096
+ ...getRichTextAttribute(itemAttr.key),
9097
+ textBaseline: 'top'
9098
+ }, 'richtext');
9099
+ }
9100
+ else {
9101
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_KEY_NAME_SUFFIX}`, {
9102
+ visible: true,
9103
+ ...itemAttr.key,
9104
+ textBaseline: 'top'
9105
+ }, 'text');
9106
+ }
8434
9107
  const { textAlign } = itemAttr.key;
8435
9108
  if (textAlign === 'center') {
8436
9109
  element.setAttribute('x', x + keyWidth / 2);
@@ -8441,14 +9114,25 @@
8441
9114
  else {
8442
9115
  element.setAttribute('x', x);
8443
9116
  }
8444
- element.setAttribute('y', itemAttr.height / 2);
9117
+ element.setAttribute('y', 0);
8445
9118
  x += keyWidth + itemAttr.key.spacing;
8446
9119
  }
8447
9120
  if (isVisible(itemAttr.value)) {
8448
- const element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, {
8449
- visible: true,
8450
- ...itemAttr.value
8451
- }, 'text');
9121
+ let element;
9122
+ if (itemAttr.value.multiLine) {
9123
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, {
9124
+ visible: true,
9125
+ ...getRichTextAttribute(itemAttr.value),
9126
+ textBaseline: 'top'
9127
+ }, 'richtext');
9128
+ }
9129
+ else {
9130
+ element = itemGroup.createOrUpdateChild(`${itemGroupName}-${TOOLTIP_VALUE_NAME_SUFFIX}`, {
9131
+ visible: true,
9132
+ ...itemAttr.value,
9133
+ textBaseline: 'top'
9134
+ }, 'text');
9135
+ }
8452
9136
  let textAlign = 'right';
8453
9137
  if (vutils.isValid(itemAttr.value.textAlign)) {
8454
9138
  textAlign = itemAttr.value.textAlign;
@@ -8467,7 +9151,7 @@
8467
9151
  element.setAttribute('x', x);
8468
9152
  }
8469
9153
  x += valueWidth;
8470
- element.setAttribute('y', itemAttr.height / 2);
9154
+ element.setAttribute('y', 0);
8471
9155
  itemGroup.add(element);
8472
9156
  }
8473
9157
  lastYPos += itemAttr.height + itemAttr.spaceRow;
@@ -8624,7 +9308,7 @@
8624
9308
  }
8625
9309
  }
8626
9310
 
8627
- const version = "0.12.3";
9311
+ const version = "0.13.0";
8628
9312
 
8629
9313
  exports.AbstractComponent = AbstractComponent;
8630
9314
  exports.BasePlayer = BasePlayer;
@@ -8661,6 +9345,7 @@
8661
9345
  exports.MarkPoint = MarkPoint;
8662
9346
  exports.Pager = Pager;
8663
9347
  exports.PolygonCrosshair = PolygonCrosshair;
9348
+ exports.PopTip = PopTip;
8664
9349
  exports.RectCrosshair = RectCrosshair;
8665
9350
  exports.RectLabel = RectLabel;
8666
9351
  exports.ScrollBar = ScrollBar;
@@ -8672,9 +9357,11 @@
8672
9357
  exports.Tag = Tag;
8673
9358
  exports.Title = Title;
8674
9359
  exports.Tooltip = Tooltip;
9360
+ exports.enablePoptip = enablePoptip;
8675
9361
  exports.getHorizontalPath = getHorizontalPath;
8676
9362
  exports.getSizeHandlerPath = getSizeHandlerPath;
8677
9363
  exports.getVerticalPath = getVerticalPath;
9364
+ exports.module = module;
8678
9365
  exports.version = version;
8679
9366
 
8680
9367
  }));