mdt-charts 1.29.0 → 1.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/lib/config/config.d.ts +167 -177
  2. package/lib/designer/designerConfig.d.ts +59 -62
  3. package/lib/engine/block/block.d.ts +16 -22
  4. package/lib/engine/block/block.js +51 -51
  5. package/lib/engine/block/blockHelper.d.ts +6 -6
  6. package/lib/engine/block/blockHelper.js +16 -16
  7. package/lib/engine/block/blockHtml.d.ts +8 -8
  8. package/lib/engine/block/blockHtml.js +15 -15
  9. package/lib/engine/block/blockSvg.d.ts +20 -20
  10. package/lib/engine/block/blockSvg.js +66 -65
  11. package/lib/engine/block/defs/LinearGradientDef.d.ts +2 -2
  12. package/lib/engine/block/defs/LinearGradientDef.js +27 -27
  13. package/lib/engine/block/defs/hatchPattern.d.ts +4 -4
  14. package/lib/engine/block/defs/hatchPattern.js +9 -9
  15. package/lib/engine/colorReader/colorReader.d.ts +5 -5
  16. package/lib/engine/colorReader/colorReader.js +18 -18
  17. package/lib/engine/contentManager/contentManager.d.ts +7 -6
  18. package/lib/engine/contentManager/contentManager.js +15 -15
  19. package/lib/engine/contentManager/contentManagerFactory.d.ts +7 -7
  20. package/lib/engine/contentManager/contentManagerFactory.js +12 -12
  21. package/lib/engine/elementHighlighter/elementHighlighter.d.ts +22 -70
  22. package/lib/engine/elementHighlighter/elementHighlighter.js +181 -230
  23. package/lib/engine/elementHighlighter/selectHighlighter.d.ts +4 -29
  24. package/lib/engine/elementHighlighter/selectHighlighter.js +87 -189
  25. package/lib/engine/engine.d.ts +17 -17
  26. package/lib/engine/engine.js +62 -87
  27. package/lib/engine/features/aggregator/aggregator.d.ts +17 -24
  28. package/lib/engine/features/aggregator/aggregator.js +102 -113
  29. package/lib/engine/features/axis/axis.d.ts +9 -22
  30. package/lib/engine/features/axis/axis.js +150 -159
  31. package/lib/engine/features/axis/axisDomHelper.d.ts +2 -7
  32. package/lib/engine/features/axis/axisDomHelper.js +20 -19
  33. package/lib/engine/features/axis/axisHelper.d.ts +5 -9
  34. package/lib/engine/features/axis/axisHelper.js +33 -28
  35. package/lib/engine/features/axis/axisLabelDomHelper.d.ts +11 -26
  36. package/lib/engine/features/axis/axisLabelDomHelper.js +152 -156
  37. package/lib/engine/features/axis/axisLabelsEventManager.d.ts +2 -2
  38. package/lib/engine/features/axis/axisLabelsEventManager.js +32 -32
  39. package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +16 -51
  40. package/lib/engine/features/embeddedLabels/embeddedLabels.js +134 -234
  41. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +2 -13
  42. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +23 -20
  43. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +15 -32
  44. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +63 -56
  45. package/lib/engine/features/gridLine/gidLineHelper.d.ts +7 -13
  46. package/lib/engine/features/gridLine/gidLineHelper.js +49 -42
  47. package/lib/engine/features/gridLine/gridLine.d.ts +5 -19
  48. package/lib/engine/features/gridLine/gridLine.js +36 -35
  49. package/lib/engine/features/legend/legend.d.ts +28 -38
  50. package/lib/engine/features/legend/legend.js +92 -118
  51. package/lib/engine/features/legend/legendDomHelper.d.ts +6 -13
  52. package/lib/engine/features/legend/legendDomHelper.js +62 -63
  53. package/lib/engine/features/legend/legendEventsManager.d.ts +8 -13
  54. package/lib/engine/features/legend/legendEventsManager.js +47 -48
  55. package/lib/engine/features/legend/legendHelper.d.ts +14 -39
  56. package/lib/engine/features/legend/legendHelper.js +92 -98
  57. package/lib/engine/features/legend/legendHelperService.d.ts +6 -13
  58. package/lib/engine/features/legend/legendHelperService.js +25 -24
  59. package/lib/engine/features/legend/legendMarkerCreator.d.ts +9 -18
  60. package/lib/engine/features/legend/legendMarkerCreator.js +76 -79
  61. package/lib/engine/features/legend/legendWidthCalculator.d.ts +7 -7
  62. package/lib/engine/features/legend/legendWidthCalculator.js +122 -126
  63. package/lib/engine/features/markDots/markDot.d.ts +15 -42
  64. package/lib/engine/features/markDots/markDot.js +70 -101
  65. package/lib/engine/features/markDots/markDotsHelper.d.ts +1 -8
  66. package/lib/engine/features/markDots/markDotsHelper.js +12 -13
  67. package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.d.ts +5 -23
  68. package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +34 -42
  69. package/lib/engine/features/scale/scale.d.ts +12 -17
  70. package/lib/engine/features/scale/scale.js +69 -76
  71. package/lib/engine/features/tipBox/tipBox.d.ts +5 -9
  72. package/lib/engine/features/tipBox/tipBox.js +24 -24
  73. package/lib/engine/features/tipBox/tipBoxHelper.d.ts +9 -16
  74. package/lib/engine/features/tipBox/tipBoxHelper.js +45 -60
  75. package/lib/engine/features/title/title.d.ts +6 -6
  76. package/lib/engine/features/title/title.js +35 -34
  77. package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +11 -15
  78. package/lib/engine/features/tolltip/newTooltip/newTooltip.js +21 -21
  79. package/lib/engine/features/tolltip/newTooltip/newTooltipService.d.ts +8 -13
  80. package/lib/engine/features/tolltip/newTooltip/newTooltipService.js +23 -26
  81. package/lib/engine/features/tolltip/tooltip.d.ts +11 -17
  82. package/lib/engine/features/tolltip/tooltip.js +142 -296
  83. package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +10 -21
  84. package/lib/engine/features/tolltip/tooltipComponentsManager.js +114 -113
  85. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +21 -43
  86. package/lib/engine/features/tolltip/tooltipDomHelper.js +120 -144
  87. package/lib/engine/features/tolltip/tooltipHelper.d.ts +9 -39
  88. package/lib/engine/features/tolltip/tooltipHelper.js +91 -114
  89. package/lib/engine/features/valueLabels/valueLabels.d.ts +38 -58
  90. package/lib/engine/features/valueLabels/valueLabels.js +169 -205
  91. package/lib/engine/features/valueLabels/valueLabelsHelper.d.ts +1 -7
  92. package/lib/engine/features/valueLabels/valueLabelsHelper.js +18 -23
  93. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.d.ts +15 -18
  94. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +47 -46
  95. package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.d.ts +3 -6
  96. package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.js +45 -49
  97. package/lib/engine/filterManager/filterEventManager.d.ts +30 -37
  98. package/lib/engine/filterManager/filterEventManager.js +131 -174
  99. package/lib/engine/helpers/domHelper.d.ts +20 -45
  100. package/lib/engine/helpers/domHelper.js +61 -62
  101. package/lib/engine/helpers/fontResizer/fontResizer.d.ts +10 -10
  102. package/lib/engine/helpers/fontResizer/fontResizer.js +16 -21
  103. package/lib/engine/helpers/fontResizer/fontResizerService.d.ts +1 -1
  104. package/lib/engine/helpers/fontResizer/fontResizerService.js +10 -9
  105. package/lib/engine/helpers/helper.d.ts +27 -27
  106. package/lib/engine/helpers/helper.js +92 -91
  107. package/lib/engine/helpers/namesHelper.d.ts +3 -3
  108. package/lib/engine/helpers/namesHelper.js +6 -6
  109. package/lib/engine/helpers/pipeline/Pipeline.d.ts +5 -5
  110. package/lib/engine/helpers/pipeline/Pipeline.js +33 -33
  111. package/lib/engine/polarNotation/donut/DonutHelper.d.ts +11 -25
  112. package/lib/engine/polarNotation/donut/DonutHelper.js +70 -71
  113. package/lib/engine/polarNotation/donut/donut.d.ts +23 -38
  114. package/lib/engine/polarNotation/donut/donut.js +99 -109
  115. package/lib/engine/polarNotation/polarManager.d.ts +6 -6
  116. package/lib/engine/polarNotation/polarManager.js +47 -67
  117. package/lib/engine/transitionManager.d.ts +14 -13
  118. package/lib/engine/transitionManager.js +49 -48
  119. package/lib/engine/twoDimensionalNotation/area/area.d.ts +28 -44
  120. package/lib/engine/twoDimensionalNotation/area/area.js +238 -272
  121. package/lib/engine/twoDimensionalNotation/area/areaGenerator.d.ts +5 -13
  122. package/lib/engine/twoDimensionalNotation/area/areaGenerator.js +13 -13
  123. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +4 -4
  124. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +41 -57
  125. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +29 -54
  126. package/lib/engine/twoDimensionalNotation/bar/bar.js +224 -362
  127. package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +32 -71
  128. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +126 -162
  129. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.d.ts +6 -6
  130. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.js +24 -24
  131. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStackerService.d.ts +2 -2
  132. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStackerService.js +17 -16
  133. package/lib/engine/twoDimensionalNotation/dot/dotChart.d.ts +23 -23
  134. package/lib/engine/twoDimensionalNotation/dot/dotChart.js +114 -135
  135. package/lib/engine/twoDimensionalNotation/line/line.d.ts +16 -37
  136. package/lib/engine/twoDimensionalNotation/line/line.js +132 -162
  137. package/lib/engine/twoDimensionalNotation/line/lineBuilder.d.ts +11 -14
  138. package/lib/engine/twoDimensionalNotation/line/lineBuilder.js +48 -47
  139. package/lib/engine/twoDimensionalNotation/line/lineGenerator.d.ts +4 -4
  140. package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +8 -8
  141. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +6 -12
  142. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +60 -76
  143. package/lib/engine/twoDimensionalNotation/lineLike/generatorFactory/lineLikeGeneratorFactory.d.ts +6 -6
  144. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorCurveMiddleware.d.ts +5 -5
  145. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorCurveMiddleware.js +17 -16
  146. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.d.ts +10 -11
  147. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.js +7 -9
  148. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorMiddleware.d.ts +1 -3
  149. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +10 -10
  150. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +138 -253
  151. package/lib/engine/valueFormatter.d.ts +3 -3
  152. package/lib/engine/valueFormatter.js +6 -6
  153. package/lib/main.d.ts +79 -82
  154. package/lib/main.js +84 -79
  155. package/lib/model/EventEmitter.d.ts +8 -8
  156. package/lib/model/EventEmitter.js +24 -24
  157. package/lib/model/chartStyleModel/chartStyleModel.d.ts +5 -5
  158. package/lib/model/chartStyleModel/chartStyleModel.js +25 -27
  159. package/lib/model/chartStyleModel/colorRange.d.ts +3 -3
  160. package/lib/model/chartStyleModel/colorRange.js +24 -19
  161. package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.d.ts +12 -22
  162. package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.js +60 -69
  163. package/lib/model/configsValidator/configValidator.d.ts +1 -1
  164. package/lib/model/configsValidator/configValidator.js +4 -4
  165. package/lib/model/dataManagerModel/dataManagerModel.d.ts +26 -36
  166. package/lib/model/dataManagerModel/dataManagerModel.js +128 -179
  167. package/lib/model/dataManagerModel/dataManagerModelService.d.ts +2 -2
  168. package/lib/model/dataManagerModel/dataManagerModelService.js +26 -25
  169. package/lib/model/featuresModel/axisModel.d.ts +18 -69
  170. package/lib/model/featuresModel/axisModel.js +169 -224
  171. package/lib/model/featuresModel/axisModelService.d.ts +6 -10
  172. package/lib/model/featuresModel/axisModelService.js +27 -27
  173. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +11 -16
  174. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +59 -55
  175. package/lib/model/featuresModel/legendModel/legendModel.d.ts +3 -7
  176. package/lib/model/featuresModel/legendModel/legendModel.js +41 -59
  177. package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +3 -8
  178. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +20 -18
  179. package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +4 -8
  180. package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +27 -40
  181. package/lib/model/featuresModel/otherComponents.d.ts +4 -7
  182. package/lib/model/featuresModel/otherComponents.js +9 -9
  183. package/lib/model/featuresModel/recordOverflowModel/recordOverflowModel.d.ts +4 -0
  184. package/lib/model/featuresModel/recordOverflowModel/recordOverflowModel.js +33 -0
  185. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +6 -6
  186. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +23 -27
  187. package/lib/model/featuresModel/scaleModel/scaleDomainService.d.ts +5 -19
  188. package/lib/model/featuresModel/scaleModel/scaleDomainService.js +55 -44
  189. package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +10 -10
  190. package/lib/model/featuresModel/scaleModel/scaleModel.js +50 -61
  191. package/lib/model/featuresModel/scaleModel/scaleModelServices.js +22 -15
  192. package/lib/model/featuresModel/titleModel.d.ts +1 -1
  193. package/lib/model/featuresModel/titleModel.js +14 -14
  194. package/lib/model/featuresModel/tooltipModel.d.ts +1 -1
  195. package/lib/model/featuresModel/tooltipModel.js +5 -5
  196. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +11 -23
  197. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +51 -53
  198. package/lib/model/helpers/modelHelper.d.ts +7 -7
  199. package/lib/model/helpers/modelHelper.js +42 -38
  200. package/lib/model/helpers/twoDimensionalModelHelper.d.ts +9 -37
  201. package/lib/model/helpers/twoDimensionalModelHelper.js +125 -147
  202. package/lib/model/helpers/unitsFromConfigReader.js +4 -4
  203. package/lib/model/helpers/unitsReader.d.ts +2 -2
  204. package/lib/model/helpers/unitsReader.js +13 -11
  205. package/lib/model/margin/marginModel.d.ts +7 -7
  206. package/lib/model/margin/marginModel.js +20 -23
  207. package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +13 -13
  208. package/lib/model/margin/twoDim/twoDimMarginModel.js +113 -184
  209. package/lib/model/model.d.ts +284 -315
  210. package/lib/model/model.js +4 -4
  211. package/lib/model/modelBuilder.d.ts +18 -27
  212. package/lib/model/modelBuilder.js +79 -85
  213. package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +17 -17
  214. package/lib/model/modelInstance/canvasModel/canvasModel.js +43 -42
  215. package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasMarginModel.d.ts +7 -7
  216. package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasSizeModel.d.ts +2 -2
  217. package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.d.ts +6 -6
  218. package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +24 -24
  219. package/lib/model/modelInstance/canvasModel/legendCanvasModel.d.ts +4 -4
  220. package/lib/model/modelInstance/canvasModel/legendCanvasModel.js +11 -11
  221. package/lib/model/modelInstance/canvasModel/titleCanvas.d.ts +4 -4
  222. package/lib/model/modelInstance/canvasModel/titleCanvas.js +9 -9
  223. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.d.ts +3 -3
  224. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.js +6 -6
  225. package/lib/model/modelInstance/configReader.d.ts +23 -32
  226. package/lib/model/modelInstance/configReader.js +94 -125
  227. package/lib/model/modelInstance/dataModel/dataModel.d.ts +10 -10
  228. package/lib/model/modelInstance/dataModel/dataModel.js +25 -25
  229. package/lib/model/modelInstance/dataModel/dataRepository.d.ts +14 -14
  230. package/lib/model/modelInstance/dataModel/dataRepository.js +42 -42
  231. package/lib/model/modelInstance/modelInstance.d.ts +6 -11
  232. package/lib/model/modelInstance/modelInstance.js +16 -16
  233. package/lib/model/modelInstance/titleConfigReader.d.ts +8 -8
  234. package/lib/model/modelInstance/titleConfigReader.js +30 -37
  235. package/lib/model/notations/polar/donut/donutAggregatorService.d.ts +6 -9
  236. package/lib/model/notations/polar/donut/donutAggregatorService.js +37 -40
  237. package/lib/model/notations/polar/donut/donutModel.d.ts +5 -9
  238. package/lib/model/notations/polar/donut/donutModel.js +28 -28
  239. package/lib/model/notations/polar/donut/donutThicknessService.d.ts +3 -3
  240. package/lib/model/notations/polar/donut/donutThicknessService.js +15 -13
  241. package/lib/model/notations/polar/polarModel.d.ts +7 -18
  242. package/lib/model/notations/polar/polarModel.js +72 -79
  243. package/lib/model/notations/twoDimensional/styles.d.ts +7 -44
  244. package/lib/model/notations/twoDimensional/styles.js +125 -234
  245. package/lib/model/notations/twoDimensionalModel.d.ts +13 -23
  246. package/lib/model/notations/twoDimensionalModel.js +170 -330
  247. package/lib/optionsServices/publicOptionsService.d.ts +1 -1
  248. package/lib/optionsServices/publicOptionsService.js +4 -4
  249. package/lib/optionsServices/validators/sizeValidator.d.ts +2 -2
  250. package/lib/optionsServices/validators/sizeValidator.js +11 -10
  251. package/lib/style/charts-main.css +151 -150
  252. package/lib/style/charts-main.less +151 -150
  253. package/package.json +1 -1
  254. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.d.ts +0 -15
  255. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +0 -40
  256. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.d.ts +0 -15
  257. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +0 -32
@@ -8,212 +8,176 @@ import { ValueLabelsCollision } from "../../../engine/features/valueLabelsCollis
8
8
  import { Pipeline } from "../../helpers/pipeline/Pipeline";
9
9
  import { getStackedData } from "../../twoDimensionalNotation/line/lineHelper";
10
10
  export class ChartValueLabels {
11
- constructor(globalOptions, chart) {
12
- this.globalOptions = globalOptions;
13
- this.chart = chart;
14
- this.renderPipeline = new Pipeline();
15
- this.attrsProvider = new ValueLabelsAttrsProvider();
16
- this.options = chart.valueLabels;
17
- this.renderPipeline.push((valueLabels, { style }) => {
18
- valueLabels.attr("fill", "currentColor").style("font-size", style.fontSize).style("color", style.color);
19
- if (style.cssClassName) valueLabels.classed(style.cssClassName, true);
20
- return valueLabels;
21
- });
22
- }
23
- render(scales, data) {
24
- if (this.chart.isSegmented) {
25
- const preparedData = getStackedData(data, this.chart);
26
- preparedData.forEach((segment, segmentIndex) => {
27
- if (!segment[0]) return;
28
- this.renderByGroupIndex(scales, segmentIndex, segment, segment[0].fieldName, "1", (d) => d.data);
29
- });
30
- } else {
31
- this.chart.data.valueFields.forEach((valueField, vfIndex) => {
32
- this.renderByGroupIndex(scales, vfIndex, data, valueField.name, valueField.name, (d) => d);
33
- });
34
- }
35
- }
36
- update(scales, newData, updatedOptions) {
37
- const updatePromises = [];
38
- this.options = updatedOptions;
39
- if (this.chart.isSegmented) {
40
- const preparedData = getStackedData(newData, this.chart);
41
- preparedData.forEach((segment, segmentIndex) => {
42
- var _a;
43
- const promise = this.updateByGroupIndex(
44
- scales,
45
- segmentIndex,
46
- segment,
47
- "1",
48
- (d) => d.data,
49
- (_a = segment[0]) === null || _a === void 0 ? void 0 : _a.fieldName
50
- );
51
- updatePromises.push(promise);
52
- });
53
- } else {
54
- this.chart.data.valueFields.forEach((valueField, vfIndex) => {
55
- const promise = this.updateByGroupIndex(
56
- scales,
57
- vfIndex,
58
- newData,
59
- valueField.name,
60
- (d) => d,
61
- valueField.name
62
- );
63
- updatePromises.push(promise);
64
- });
65
- }
66
- return Promise.all(updatePromises);
67
- }
68
- renderByGroupIndex(scales, groupIndex, data, valueFieldName, datumField, dataRowAccessor) {
69
- let valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data).enter().append("text");
70
- valueLabels = this.renderPipeline.execute(valueLabels, {
71
- style: this.globalOptions.canvas.style
72
- });
73
- const attrs = this.attrsProvider.getAttrs(
74
- this.globalOptions,
75
- this.options,
76
- scales,
77
- datumField,
78
- dataRowAccessor
79
- );
80
- this.setAttrs(valueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor);
81
- this.setClasses(valueLabels, this.chart.cssClasses, groupIndex);
82
- }
83
- updateByGroupIndex(scales, groupIndex, data, datumField, dataRowAccessor, valueFieldName) {
84
- return new Promise((resolve) => {
85
- const valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data);
86
- valueLabels.exit().remove();
87
- const attrs = this.attrsProvider.getAttrs(
88
- this.globalOptions,
89
- this.options,
90
- scales,
91
- datumField,
92
- dataRowAccessor
93
- );
94
- if (!valueFieldName) {
95
- resolve();
96
- return;
97
- }
98
- let newValueLabels = valueLabels.enter().append("text");
99
- newValueLabels = this.renderPipeline.execute(newValueLabels, {
100
- style: this.globalOptions.canvas.style
101
- });
102
- const mergedValueLabels = newValueLabels.merge(valueLabels);
103
- this.setAttrs(newValueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor);
104
- this.setClasses(mergedValueLabels, this.chart.cssClasses, groupIndex);
105
- this.setAttrs(valueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor, true, resolve);
106
- });
107
- }
108
- getAllValueLabelsOfChart(vfIndex) {
109
- const block = this.globalOptions.elementAccessors.getBlock().svg.getChartBlock();
110
- return block.selectAll(
111
- `.${ChartValueLabels.valueLabelClass}.${CLASSES.dataLabel}${Helper.getCssClassesLine(
112
- this.chart.cssClasses
113
- )}.chart-element-${vfIndex}`
114
- );
115
- }
116
- setAttrs(valueLabels, attrs, valueFieldName, formatter, dataRowAccessor, animate = false, onEndAnimation) {
117
- const animationName = "labels-updating";
118
- let selection = valueLabels
119
- .text((d) => formatter(dataRowAccessor(d)[valueFieldName]))
120
- .attr("dominant-baseline", attrs.dominantBaseline)
121
- .attr("text-anchor", attrs.textAnchor);
122
- if (animate) {
123
- selection = selection
124
- .interrupt(animationName)
125
- .transition(animationName)
126
- .duration(this.globalOptions.elementAccessors.getBlock().transitionManager.durations.chartUpdate);
127
- }
128
- selection
129
- .attr("x", (d) => attrs.x(d))
130
- .attr("y", (d) => attrs.y(d))
131
- .attr("transform", (d) => {
132
- var _a;
133
- return ((_a = this.chart.valueLabels.rotation) === null || _a === void 0 ? void 0 : _a.angle)
134
- ? `rotate(${this.chart.valueLabels.rotation.angle}, ${attrs.x(d)}, ${attrs.y(d)})`
135
- : null;
136
- });
137
- const handleElements = () => {
138
- if (this.chart.valueLabels.handleElement) {
139
- const thisClass = this;
140
- selection.each(function (d) {
141
- thisClass.chart.valueLabels.handleElement({
142
- element: this,
143
- value: dataRowAccessor(d)[valueFieldName]
144
- });
145
- });
146
- }
147
- };
148
- if (animate)
149
- selection.on("end", () => {
150
- onEndAnimation();
151
- handleElements();
152
- });
153
- else handleElements();
154
- }
155
- setClasses(textLabels, cssClasses, vfIndex) {
156
- textLabels.classed(ChartValueLabels.valueLabelClass, true);
157
- textLabels.classed(CLASSES.dataLabel, true);
158
- DomHelper.setCssClasses(textLabels, Helper.getCssClassesWithElementIndex(cssClasses, vfIndex));
159
- }
11
+ constructor(globalOptions, chart) {
12
+ this.globalOptions = globalOptions;
13
+ this.chart = chart;
14
+ this.renderPipeline = new Pipeline();
15
+ this.attrsProvider = new ValueLabelsAttrsProvider();
16
+ this.options = chart.valueLabels;
17
+ this.renderPipeline.push((valueLabels, { style }) => {
18
+ valueLabels.attr("fill", "currentColor").style("font-size", style.fontSize).style("color", style.color);
19
+ if (style.cssClassName)
20
+ valueLabels.classed(style.cssClassName, true);
21
+ return valueLabels;
22
+ });
23
+ }
24
+ render(scales, data) {
25
+ if (this.chart.isSegmented) {
26
+ const preparedData = getStackedData(data, this.chart);
27
+ preparedData.forEach((segment, segmentIndex) => {
28
+ if (!segment[0])
29
+ return;
30
+ this.renderByGroupIndex(scales, segmentIndex, segment, segment[0].fieldName, "1", (d) => d.data);
31
+ });
32
+ }
33
+ else {
34
+ this.chart.data.valueFields.forEach((valueField, vfIndex) => {
35
+ this.renderByGroupIndex(scales, vfIndex, data, valueField.name, valueField.name, (d) => d);
36
+ });
37
+ }
38
+ }
39
+ update(scales, newData, updatedOptions) {
40
+ const updatePromises = [];
41
+ this.options = updatedOptions;
42
+ if (this.chart.isSegmented) {
43
+ const preparedData = getStackedData(newData, this.chart);
44
+ preparedData.forEach((segment, segmentIndex) => {
45
+ var _a;
46
+ const promise = this.updateByGroupIndex(scales, segmentIndex, segment, "1", (d) => d.data, (_a = segment[0]) === null || _a === void 0 ? void 0 : _a.fieldName);
47
+ updatePromises.push(promise);
48
+ });
49
+ }
50
+ else {
51
+ this.chart.data.valueFields.forEach((valueField, vfIndex) => {
52
+ const promise = this.updateByGroupIndex(scales, vfIndex, newData, valueField.name, (d) => d, valueField.name);
53
+ updatePromises.push(promise);
54
+ });
55
+ }
56
+ return Promise.all(updatePromises);
57
+ }
58
+ renderByGroupIndex(scales, groupIndex, data, valueFieldName, datumField, dataRowAccessor) {
59
+ let valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data).enter().append("text");
60
+ valueLabels = this.renderPipeline.execute(valueLabels, { style: this.globalOptions.canvas.style });
61
+ const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.options, scales, datumField, dataRowAccessor);
62
+ this.setAttrs(valueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor);
63
+ this.setClasses(valueLabels, this.chart.cssClasses, groupIndex);
64
+ }
65
+ updateByGroupIndex(scales, groupIndex, data, datumField, dataRowAccessor, valueFieldName) {
66
+ return new Promise((resolve) => {
67
+ const valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data);
68
+ valueLabels.exit().remove();
69
+ const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.options, scales, datumField, dataRowAccessor);
70
+ if (!valueFieldName) {
71
+ resolve();
72
+ return;
73
+ }
74
+ let newValueLabels = valueLabels.enter().append("text");
75
+ newValueLabels = this.renderPipeline.execute(newValueLabels, { style: this.globalOptions.canvas.style });
76
+ const mergedValueLabels = newValueLabels.merge(valueLabels);
77
+ this.setAttrs(newValueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor);
78
+ this.setClasses(mergedValueLabels, this.chart.cssClasses, groupIndex);
79
+ this.setAttrs(valueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor, true, resolve);
80
+ });
81
+ }
82
+ getAllValueLabelsOfChart(vfIndex) {
83
+ const block = this.globalOptions.elementAccessors.getBlock().svg.getChartBlock();
84
+ return block.selectAll(`.${ChartValueLabels.valueLabelClass}.${CLASSES.dataLabel}${Helper.getCssClassesLine(this.chart.cssClasses)}.chart-element-${vfIndex}`);
85
+ }
86
+ setAttrs(valueLabels, attrs, valueFieldName, formatter, dataRowAccessor, animate = false, onEndAnimation) {
87
+ const animationName = "labels-updating";
88
+ let selection = valueLabels
89
+ .text((d) => formatter(dataRowAccessor(d)[valueFieldName]))
90
+ .attr("dominant-baseline", attrs.dominantBaseline)
91
+ .attr("text-anchor", attrs.textAnchor);
92
+ if (animate) {
93
+ selection = selection
94
+ .interrupt(animationName)
95
+ .transition(animationName)
96
+ .duration(this.globalOptions.elementAccessors.getBlock().transitionManager.durations.chartUpdate);
97
+ }
98
+ selection
99
+ .attr("x", (d) => attrs.x(d))
100
+ .attr("y", (d) => attrs.y(d))
101
+ .attr("transform", (d) => {
102
+ var _a;
103
+ return ((_a = this.chart.valueLabels.rotation) === null || _a === void 0 ? void 0 : _a.angle) ? `rotate(${this.chart.valueLabels.rotation.angle}, ${attrs.x(d)}, ${attrs.y(d)})`
104
+ : null;
105
+ });
106
+ const handleElements = () => {
107
+ if (this.chart.valueLabels.handleElement) {
108
+ const thisClass = this;
109
+ selection.each(function (d) {
110
+ thisClass.chart.valueLabels.handleElement({
111
+ element: this,
112
+ value: dataRowAccessor(d)[valueFieldName]
113
+ });
114
+ });
115
+ }
116
+ };
117
+ if (animate)
118
+ selection.on("end", () => {
119
+ onEndAnimation();
120
+ handleElements();
121
+ });
122
+ else
123
+ handleElements();
124
+ }
125
+ setClasses(textLabels, cssClasses, vfIndex) {
126
+ textLabels.classed(ChartValueLabels.valueLabelClass, true);
127
+ textLabels.classed(CLASSES.dataLabel, true);
128
+ DomHelper.setCssClasses(textLabels, Helper.getCssClassesWithElementIndex(cssClasses, vfIndex));
129
+ }
160
130
  }
161
131
  ChartValueLabels.valueLabelClass = NamesHelper.getClassName("value-label");
162
132
  export class CanvasValueLabels {
163
- constructor(options) {
164
- this.options = options;
165
- this.chartsValueLabels = [];
166
- }
167
- render(scales, charts, data, dataOptions) {
168
- const valueLabelsSettings = this.options.canvas.valueLabels;
169
- const chartsWithLabels = charts.filter((chart) => {
170
- var _a;
171
- return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show;
172
- });
173
- if (chartsWithLabels.length === 0) return;
174
- chartsWithLabels.forEach((chart) => {
175
- const chartScales = this.getChartScales(scales, chart);
176
- const chartValueLabels = new ChartValueLabels(this.options, chart);
177
- this.chartsValueLabels.push(chartValueLabels);
178
- chartValueLabels.render(chartScales, data[dataOptions.dataSource]);
179
- });
180
- const valueLabels = this.getAllValueLabels();
181
- ValueLabelsCollision.resolveValueLabelsCollisions(valueLabels, valueLabelsSettings);
182
- }
183
- update(scales, charts, data, dataOptions, newCanvasOptions) {
184
- this.options.canvas.valueLabels = newCanvasOptions;
185
- const chartsWithLabels = charts.filter((chart) => {
186
- var _a;
187
- return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show;
188
- });
189
- if (chartsWithLabels.length === 0) return;
190
- if (this.options.canvas.valueLabels.collision.otherValueLables.mode === "hide")
191
- this.toggleOldValueLabelsVisibility();
192
- const chartsUpdatePromises = chartsWithLabels.map((chart, index) => {
193
- const chartScales = this.getChartScales(scales, chart);
194
- return this.chartsValueLabels[index].update(chartScales, data[dataOptions.dataSource], chart.valueLabels);
195
- });
196
- Promise.all(chartsUpdatePromises).then(() => {
197
- ValueLabelsCollision.resolveValueLabelsCollisions(
198
- this.getAllValueLabels(),
199
- this.options.canvas.valueLabels
200
- );
201
- });
202
- }
203
- toggleOldValueLabelsVisibility() {
204
- const oldValueLabels = this.getAllValueLabels();
205
- oldValueLabels.each(function () {
206
- if (this.style.display === "none") select(this).style("display", "block");
207
- });
208
- }
209
- getAllValueLabels() {
210
- const block = this.options.elementAccessors.getBlock().svg.getChartBlock();
211
- return block.selectAll(`.${ChartValueLabels.valueLabelClass}`);
212
- }
213
- getChartScales(scales, chart) {
214
- return {
215
- key: scales.key,
216
- value: chart.data.valueGroup === "secondary" ? scales.valueSecondary : scales.value
217
- };
218
- }
133
+ constructor(options) {
134
+ this.options = options;
135
+ this.chartsValueLabels = [];
136
+ }
137
+ render(scales, charts, data, dataOptions) {
138
+ const valueLabelsSettings = this.options.canvas.valueLabels;
139
+ const chartsWithLabels = charts.filter((chart) => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show; });
140
+ if (chartsWithLabels.length === 0)
141
+ return;
142
+ chartsWithLabels.forEach((chart) => {
143
+ const chartScales = this.getChartScales(scales, chart);
144
+ const chartValueLabels = new ChartValueLabels(this.options, chart);
145
+ this.chartsValueLabels.push(chartValueLabels);
146
+ chartValueLabels.render(chartScales, data[dataOptions.dataSource]);
147
+ });
148
+ const valueLabels = this.getAllValueLabels();
149
+ ValueLabelsCollision.resolveValueLabelsCollisions(valueLabels, valueLabelsSettings);
150
+ }
151
+ update(scales, charts, data, dataOptions, newCanvasOptions) {
152
+ this.options.canvas.valueLabels = newCanvasOptions;
153
+ const chartsWithLabels = charts.filter((chart) => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show; });
154
+ if (chartsWithLabels.length === 0)
155
+ return;
156
+ if (this.options.canvas.valueLabels.collision.otherValueLables.mode === "hide")
157
+ this.toggleOldValueLabelsVisibility();
158
+ const chartsUpdatePromises = chartsWithLabels.map((chart, index) => {
159
+ const chartScales = this.getChartScales(scales, chart);
160
+ return this.chartsValueLabels[index].update(chartScales, data[dataOptions.dataSource], chart.valueLabels);
161
+ });
162
+ Promise.all(chartsUpdatePromises).then(() => {
163
+ ValueLabelsCollision.resolveValueLabelsCollisions(this.getAllValueLabels(), this.options.canvas.valueLabels);
164
+ });
165
+ }
166
+ toggleOldValueLabelsVisibility() {
167
+ const oldValueLabels = this.getAllValueLabels();
168
+ oldValueLabels.each(function () {
169
+ if (this.style.display === "none")
170
+ select(this).style("display", "block");
171
+ });
172
+ }
173
+ getAllValueLabels() {
174
+ const block = this.options.elementAccessors.getBlock().svg.getChartBlock();
175
+ return block.selectAll(`.${ChartValueLabels.valueLabelClass}`);
176
+ }
177
+ getChartScales(scales, chart) {
178
+ return {
179
+ key: scales.key,
180
+ value: chart.data.valueGroup === "secondary" ? scales.valueSecondary : scales.value
181
+ };
182
+ }
219
183
  }
@@ -4,11 +4,5 @@ import { Scales } from "../../../engine/features/scale/scale";
4
4
  import { Segment } from "../../twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware";
5
5
  import { MdtChartsDataRow } from "../../../config/config";
6
6
  export declare class ValueLabelsAttrsProvider {
7
- getAttrs(
8
- globalOptions: ValueLabelsOptions,
9
- valueLabels: TwoDimChartValueLabelsOptions,
10
- scales: Scales,
11
- datumField: string,
12
- dataRowAccessor: (d: MdtChartsDataRow | Segment) => MdtChartsDataRow
13
- ): ValueLabelAttrs;
7
+ getAttrs(globalOptions: ValueLabelsOptions, valueLabels: TwoDimChartValueLabelsOptions, scales: Scales, datumField: string, dataRowAccessor: (d: MdtChartsDataRow | Segment) => MdtChartsDataRow): ValueLabelAttrs;
14
8
  }
@@ -1,26 +1,21 @@
1
1
  import { Scale } from "../../../engine/features/scale/scale";
2
2
  export class ValueLabelsAttrsProvider {
3
- getAttrs(globalOptions, valueLabels, scales, datumField, dataRowAccessor) {
4
- let attrs = {
5
- x: null,
6
- y: null,
7
- dominantBaseline: valueLabels.dominantBaseline,
8
- textAnchor: valueLabels.textAnchor
9
- };
10
- const orient = globalOptions.canvas.keyAxisOrient;
11
- if (orient === "left" || orient === "right") {
12
- attrs.x = (d) => valueLabels.handleX(scales.value(valueLabels.handleScaledValue(d, datumField)));
13
- attrs.y = (d) =>
14
- valueLabels.handleY(
15
- Scale.getScaledValue(scales.key, dataRowAccessor(d)[globalOptions.data.keyFieldName])
16
- );
17
- } else if (orient === "bottom" || orient === "top") {
18
- attrs.x = (d) =>
19
- valueLabels.handleX(
20
- Scale.getScaledValue(scales.key, dataRowAccessor(d)[globalOptions.data.keyFieldName])
21
- );
22
- attrs.y = (d) => valueLabels.handleY(scales.value(valueLabels.handleScaledValue(d, datumField)));
23
- }
24
- return attrs;
25
- }
3
+ getAttrs(globalOptions, valueLabels, scales, datumField, dataRowAccessor) {
4
+ let attrs = {
5
+ x: null,
6
+ y: null,
7
+ dominantBaseline: valueLabels.dominantBaseline,
8
+ textAnchor: valueLabels.textAnchor
9
+ };
10
+ const orient = globalOptions.canvas.keyAxisOrient;
11
+ if (orient === "left" || orient === "right") {
12
+ attrs.x = (d) => valueLabels.handleX(scales.value(valueLabels.handleScaledValue(d, datumField)));
13
+ attrs.y = (d) => valueLabels.handleY(Scale.getScaledValue(scales.key, dataRowAccessor(d)[globalOptions.data.keyFieldName]));
14
+ }
15
+ else if (orient === "bottom" || orient === "top") {
16
+ attrs.x = (d) => valueLabels.handleX(Scale.getScaledValue(scales.key, dataRowAccessor(d)[globalOptions.data.keyFieldName]));
17
+ attrs.y = (d) => valueLabels.handleY(scales.value(valueLabels.handleScaledValue(d, datumField)));
18
+ }
19
+ return attrs;
20
+ }
26
21
  }
@@ -3,30 +3,27 @@ import { TwoDimensionalValueLabels } from "../../../model/model";
3
3
  import { MdtChartsDataRow } from "../../../config/config";
4
4
  export declare type ValueLabelOnCanvasIndex = number;
5
5
  export interface BoundingRect {
6
- x: number;
7
- y: number;
8
- width: number;
9
- height: number;
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
10
  }
11
11
  export interface ValueLabelElementRectInfo {
12
- index: ValueLabelOnCanvasIndex;
13
- boundingClientRect: BoundingRect;
12
+ index: ValueLabelOnCanvasIndex;
13
+ boundingClientRect: BoundingRect;
14
14
  }
15
15
  export interface ValueLabelElement extends ValueLabelElementRectInfo {
16
- svgElement: SVGTextElement;
16
+ svgElement: SVGTextElement;
17
17
  }
18
18
  export interface LabelVisibility {
19
- index: ValueLabelOnCanvasIndex;
20
- isVisible: boolean;
19
+ index: ValueLabelOnCanvasIndex;
20
+ isVisible: boolean;
21
21
  }
22
22
  export declare class ValueLabelsCollision {
23
- static resolveValueLabelsCollisions(
24
- newValueLabels: Selection<SVGTextElement, MdtChartsDataRow, SVGGElement, unknown>,
25
- valueLabelsSettings: TwoDimensionalValueLabels
26
- ): void;
27
- private static getValueLabelElementsRectInfo;
28
- private static shiftValueLabelsCollision;
29
- private static handleCollisionShift;
30
- private static toggleValueLabelElementsVisibility;
31
- private static changeLabelElementCoordinateByAxis;
23
+ static resolveValueLabelsCollisions(newValueLabels: Selection<SVGTextElement, MdtChartsDataRow, SVGGElement, unknown>, valueLabelsSettings: TwoDimensionalValueLabels): void;
24
+ private static getValueLabelElementsRectInfo;
25
+ private static shiftValueLabelsCollision;
26
+ private static handleCollisionShift;
27
+ private static toggleValueLabelElementsVisibility;
28
+ private static changeLabelElementCoordinateByAxis;
32
29
  }
@@ -1,50 +1,51 @@
1
1
  import { select } from "d3-selection";
2
2
  import { ValueLabelsCollisionHelper } from "../../../engine/features/valueLabelsCollision/valueLabelsCollisionHelper";
3
3
  export class ValueLabelsCollision {
4
- static resolveValueLabelsCollisions(newValueLabels, valueLabelsSettings) {
5
- const valueLabelElementsRectInfo = this.getValueLabelElementsRectInfo(newValueLabels);
6
- this.shiftValueLabelsCollision(valueLabelElementsRectInfo, valueLabelsSettings.collision.chartBlock);
7
- if (valueLabelsSettings.collision.otherValueLables.mode === "hide")
8
- this.toggleValueLabelElementsVisibility(valueLabelElementsRectInfo);
9
- }
10
- static getValueLabelElementsRectInfo(valueLabels) {
11
- let ValueLabelElementsReactInfo = [];
12
- valueLabels.each(function (_, index) {
13
- const { height, width } = this.getBoundingClientRect();
14
- const x = +this.getAttribute("x");
15
- const y = +this.getAttribute("y");
16
- ValueLabelElementsReactInfo.push({
17
- index,
18
- svgElement: this,
19
- boundingClientRect: { x, y, width, height }
20
- });
21
- });
22
- return ValueLabelElementsReactInfo;
23
- }
24
- static shiftValueLabelsCollision(valueLabelElementsRectInfo, chartBlock) {
25
- valueLabelElementsRectInfo.forEach((element) => {
26
- this.handleCollisionShift(chartBlock, element);
27
- });
28
- }
29
- static handleCollisionShift(chartBlock, element) {
30
- const sides = Object.keys(chartBlock);
31
- sides.forEach((side) => {
32
- const blockSide = chartBlock[side];
33
- const axisCoordinate = side === "left" || side === "right" ? "x" : "y";
34
- if (blockSide.mode === "shift" && blockSide.hasCollision(element.boundingClientRect)) {
35
- blockSide.shiftCoordinate(element.boundingClientRect);
36
- this.changeLabelElementCoordinateByAxis(element, axisCoordinate);
37
- }
38
- });
39
- }
40
- static toggleValueLabelElementsVisibility(elements) {
41
- const labelsVisibility = ValueLabelsCollisionHelper.calculateValueLabelsVisibility(elements);
42
- labelsVisibility.forEach((label) => {
43
- const labelInfo = elements.find((element) => element.index === label.index);
44
- if (labelInfo && !label.isVisible) select(labelInfo.svgElement).style("display", "none");
45
- });
46
- }
47
- static changeLabelElementCoordinateByAxis(element, axis) {
48
- select(element.svgElement).attr(axis, element.boundingClientRect[axis]);
49
- }
4
+ static resolveValueLabelsCollisions(newValueLabels, valueLabelsSettings) {
5
+ const valueLabelElementsRectInfo = this.getValueLabelElementsRectInfo(newValueLabels);
6
+ this.shiftValueLabelsCollision(valueLabelElementsRectInfo, valueLabelsSettings.collision.chartBlock);
7
+ if (valueLabelsSettings.collision.otherValueLables.mode === "hide")
8
+ this.toggleValueLabelElementsVisibility(valueLabelElementsRectInfo);
9
+ }
10
+ static getValueLabelElementsRectInfo(valueLabels) {
11
+ let ValueLabelElementsReactInfo = [];
12
+ valueLabels.each(function (_, index) {
13
+ const { height, width } = this.getBoundingClientRect();
14
+ const x = +this.getAttribute("x");
15
+ const y = +this.getAttribute("y");
16
+ ValueLabelElementsReactInfo.push({
17
+ index,
18
+ svgElement: this,
19
+ boundingClientRect: { x, y, width, height }
20
+ });
21
+ });
22
+ return ValueLabelElementsReactInfo;
23
+ }
24
+ static shiftValueLabelsCollision(valueLabelElementsRectInfo, chartBlock) {
25
+ valueLabelElementsRectInfo.forEach((element) => {
26
+ this.handleCollisionShift(chartBlock, element);
27
+ });
28
+ }
29
+ static handleCollisionShift(chartBlock, element) {
30
+ const sides = Object.keys(chartBlock);
31
+ sides.forEach((side) => {
32
+ const blockSide = chartBlock[side];
33
+ const axisCoordinate = side === "left" || side === "right" ? "x" : "y";
34
+ if (blockSide.mode === "shift" && blockSide.hasCollision(element.boundingClientRect)) {
35
+ blockSide.shiftCoordinate(element.boundingClientRect);
36
+ this.changeLabelElementCoordinateByAxis(element, axisCoordinate);
37
+ }
38
+ });
39
+ }
40
+ static toggleValueLabelElementsVisibility(elements) {
41
+ const labelsVisibility = ValueLabelsCollisionHelper.calculateValueLabelsVisibility(elements);
42
+ labelsVisibility.forEach((label) => {
43
+ const labelInfo = elements.find((element) => element.index === label.index);
44
+ if (labelInfo && !label.isVisible)
45
+ select(labelInfo.svgElement).style("display", "none");
46
+ });
47
+ }
48
+ static changeLabelElementCoordinateByAxis(element, axis) {
49
+ select(element.svgElement).attr(axis, element.boundingClientRect[axis]);
50
+ }
50
51
  }
@@ -1,8 +1,5 @@
1
- import {
2
- LabelVisibility,
3
- ValueLabelElementRectInfo
4
- } from "../../../engine/features/valueLabelsCollision/valueLabelsCollision";
1
+ import { LabelVisibility, ValueLabelElementRectInfo } from "../../../engine/features/valueLabelsCollision/valueLabelsCollision";
5
2
  export declare class ValueLabelsCollisionHelper {
6
- static calculateValueLabelsVisibility(elements: ValueLabelElementRectInfo[]): Map<number, LabelVisibility>;
7
- private static isOverlapping;
3
+ static calculateValueLabelsVisibility(elements: ValueLabelElementRectInfo[]): Map<number, LabelVisibility>;
4
+ private static isOverlapping;
8
5
  }