mdt-charts 1.29.0 → 1.30.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 (257) hide show
  1. package/lib/config/config.d.ts +170 -178
  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 +170 -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 +281 -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 +5 -5
  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
@@ -2,119 +2,108 @@ import { interpolateNumber } from "d3-interpolate";
2
2
  import { Helper } from "../../helpers/helper";
3
3
  import { ValueFormatter } from "../../valueFormatter";
4
4
  export class Aggregator {
5
- static render(block, valueField, innerRadius, translate, fontSize, settings) {
6
- const aggregator = this.buildConfig(valueField, settings);
7
- this.renderText(block, innerRadius, aggregator, fontSize, translate);
8
- }
9
- static update(block, valueField, settings) {
10
- const aggregator = this.buildConfig(valueField, settings);
11
- this.updateText(block, aggregator, typeof aggregator.value === "string");
12
- }
13
- static buildConfig(valueField, settings) {
14
- return {
15
- name: settings.content.title,
16
- value: settings.content.value,
17
- format: valueField.format,
18
- marginInPercent: settings.margin
19
- };
20
- }
21
- static renderText(block, innerRadius, aggregatorInfo, fontSize, translate) {
22
- if (innerRadius > 30) {
23
- const aggregatorObject = this.renderAggregatorObject(block, innerRadius, translate);
24
- const wrapper = this.renderWrapper(aggregatorObject);
25
- wrapper
26
- .append("div")
27
- .attr("class", this.aggregatorValueClass)
28
- .attr("title", this.formatValue(aggregatorInfo.format, aggregatorInfo.value))
29
- .style("text-align", "center")
30
- .style("font-size", `${fontSize}px`)
31
- .text(this.formatValue(aggregatorInfo.format, aggregatorInfo.value));
32
- const titleBlock = wrapper
33
- .append("div")
34
- .attr("class", this.aggregatorTitleClass)
35
- .attr("title", aggregatorInfo.name)
36
- .style("text-align", "center")
37
- .text(aggregatorInfo.name);
38
- this.setTitleFontSize(titleBlock, innerRadius);
39
- this.reCalculateAggregatorFontSize(
40
- aggregatorObject.node().getBoundingClientRect().width,
41
- block,
42
- aggregatorInfo.marginInPercent
43
- );
44
- }
45
- }
46
- static formatValue(format, value) {
47
- if (typeof value === "string") return value;
48
- return ValueFormatter.formatField(format, value);
49
- }
50
- static updateText(block, newAggregator, withoutAnimation) {
51
- const aggregatorObject = block.getSvg().select(`.${this.aggregatorObjectClass}`);
52
- const thisClass = this;
53
- const valueBlock = block.getSvg().select(`.${this.aggregatorValueClass}`);
54
- if (withoutAnimation) {
55
- valueBlock.text(this.formatValue(newAggregator.format, newAggregator.value));
56
- return;
57
- }
58
- valueBlock
59
- .interrupt()
60
- .transition()
61
- .duration(block.transitionManager.durations.chartUpdate)
62
- .tween("text", function () {
63
- const newValue =
64
- typeof newAggregator.value === "string" ? parseFloat(newAggregator.value) : newAggregator.value;
65
- const oldValue = Helper.parseFormattedToNumber(this.textContent, ",");
66
- const precision = Helper.calcDigitsAfterDot(newValue);
67
- const interpolateFunc = interpolateNumber(oldValue, newValue);
68
- return (t) => {
69
- this.textContent = thisClass.formatValue(
70
- newAggregator.format,
71
- parseFloat(interpolateFunc(t).toFixed(precision))
72
- );
73
- thisClass.reCalculateAggregatorFontSize(
74
- aggregatorObject.node().getBoundingClientRect().width,
75
- block,
76
- newAggregator.marginInPercent
77
- );
78
- };
79
- });
80
- }
81
- static reCalculateAggregatorFontSize(wrapperSize, block, pad) {
82
- const aggregatorValue = block.getSvg().select(`.${this.aggregatorValueClass}`);
83
- const sizeCoefficient = 0.25;
84
- let fontSize = wrapperSize * sizeCoefficient;
85
- aggregatorValue.style("font-size", `${fontSize}px`);
86
- const margin = (pad / 100) * wrapperSize;
87
- while (aggregatorValue.node().getBoundingClientRect().width > wrapperSize - margin * 2 && fontSize > 12) {
88
- aggregatorValue.style("font-size", `${(fontSize -= 2)}px`);
89
- }
90
- }
91
- static setTitleFontSize(aggregatorTitle, innerRadius) {
92
- const sizeCoefficient = 0.15;
93
- aggregatorTitle.style("font-size", `${Math.round(innerRadius * sizeCoefficient)}px`);
94
- aggregatorTitle.style("max-height", `${sizeCoefficient * 100}%`);
95
- }
96
- static renderAggregatorObject(block, innerRadius, translate) {
97
- return block
98
- .getSvg()
99
- .append("foreignObject")
100
- .attr("class", this.aggregatorObjectClass)
101
- .attr("transform-origin", "center")
102
- .attr("width", innerRadius * 2)
103
- .attr("height", innerRadius * 2)
104
- .attr("transform", `translate(${translate.x - innerRadius}, ${translate.y - innerRadius})`)
105
- .style("pointer-events", `none`);
106
- }
107
- static renderWrapper(aggregatorObject) {
108
- return aggregatorObject
109
- .append("xhtml:div")
110
- .style("width", "100%")
111
- .style("height", "100%")
112
- .style("border-radius", "50%")
113
- .style("display", "flex")
114
- .style("flex-direction", "column")
115
- .style("justify-content", "center")
116
- .style("align-items", "center");
117
- }
5
+ static render(block, valueField, innerRadius, translate, fontSize, settings) {
6
+ const aggregator = this.buildConfig(valueField, settings);
7
+ this.renderText(block, innerRadius, aggregator, fontSize, translate);
8
+ }
9
+ static update(block, valueField, settings) {
10
+ const aggregator = this.buildConfig(valueField, settings);
11
+ this.updateText(block, aggregator, typeof aggregator.value === "string");
12
+ }
13
+ static buildConfig(valueField, settings) {
14
+ return {
15
+ name: settings.content.title,
16
+ value: settings.content.value,
17
+ format: valueField.format,
18
+ marginInPercent: settings.margin
19
+ };
20
+ }
21
+ static renderText(block, innerRadius, aggregatorInfo, fontSize, translate) {
22
+ if (innerRadius > 30) {
23
+ const aggregatorObject = this.renderAggregatorObject(block, innerRadius, translate);
24
+ const wrapper = this.renderWrapper(aggregatorObject);
25
+ wrapper
26
+ .append("div")
27
+ .attr("class", this.aggregatorValueClass)
28
+ .attr("title", this.formatValue(aggregatorInfo.format, aggregatorInfo.value))
29
+ .style("text-align", "center")
30
+ .style("font-size", `${fontSize}px`)
31
+ .text(this.formatValue(aggregatorInfo.format, aggregatorInfo.value));
32
+ const titleBlock = wrapper
33
+ .append("div")
34
+ .attr("class", this.aggregatorTitleClass)
35
+ .attr("title", aggregatorInfo.name)
36
+ .style("text-align", "center")
37
+ .text(aggregatorInfo.name);
38
+ this.setTitleFontSize(titleBlock, innerRadius);
39
+ this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, aggregatorInfo.marginInPercent);
40
+ }
41
+ }
42
+ static formatValue(format, value) {
43
+ if (typeof value === "string")
44
+ return value;
45
+ return ValueFormatter.formatField(format, value);
46
+ }
47
+ static updateText(block, newAggregator, withoutAnimation) {
48
+ const aggregatorObject = block.getSvg().select(`.${this.aggregatorObjectClass}`);
49
+ const thisClass = this;
50
+ const valueBlock = block.getSvg().select(`.${this.aggregatorValueClass}`);
51
+ if (withoutAnimation) {
52
+ valueBlock.text(this.formatValue(newAggregator.format, newAggregator.value));
53
+ return;
54
+ }
55
+ valueBlock
56
+ .interrupt()
57
+ .transition()
58
+ .duration(block.transitionManager.durations.chartUpdate)
59
+ .tween("text", function () {
60
+ const newValue = typeof newAggregator.value === "string" ? parseFloat(newAggregator.value) : newAggregator.value;
61
+ const oldValue = Helper.parseFormattedToNumber(this.textContent, ",");
62
+ const precision = Helper.calcDigitsAfterDot(newValue);
63
+ const interpolateFunc = interpolateNumber(oldValue, newValue);
64
+ return (t) => {
65
+ this.textContent = thisClass.formatValue(newAggregator.format, parseFloat(interpolateFunc(t).toFixed(precision)));
66
+ thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, newAggregator.marginInPercent);
67
+ };
68
+ });
69
+ }
70
+ static reCalculateAggregatorFontSize(wrapperSize, block, pad) {
71
+ const aggregatorValue = block.getSvg().select(`.${this.aggregatorValueClass}`);
72
+ const sizeCoefficient = 0.25;
73
+ let fontSize = wrapperSize * sizeCoefficient;
74
+ aggregatorValue.style("font-size", `${fontSize}px`);
75
+ const margin = (pad / 100) * wrapperSize;
76
+ while (aggregatorValue.node().getBoundingClientRect().width > wrapperSize - margin * 2 && fontSize > 12) {
77
+ aggregatorValue.style("font-size", `${(fontSize -= 2)}px`);
78
+ }
79
+ }
80
+ static setTitleFontSize(aggregatorTitle, innerRadius) {
81
+ const sizeCoefficient = 0.15;
82
+ aggregatorTitle.style("font-size", `${Math.round(innerRadius * sizeCoefficient)}px`);
83
+ aggregatorTitle.style("max-height", `${sizeCoefficient * 100}%`);
84
+ }
85
+ static renderAggregatorObject(block, innerRadius, translate) {
86
+ return block
87
+ .getSvg()
88
+ .append("foreignObject")
89
+ .attr("class", this.aggregatorObjectClass)
90
+ .attr("transform-origin", "center")
91
+ .attr("width", innerRadius * 2)
92
+ .attr("height", innerRadius * 2)
93
+ .attr("transform", `translate(${translate.x - innerRadius}, ${translate.y - innerRadius})`)
94
+ .style("pointer-events", `none`);
95
+ }
96
+ static renderWrapper(aggregatorObject) {
97
+ return aggregatorObject
98
+ .append("xhtml:div")
99
+ .style("width", "100%")
100
+ .style("height", "100%")
101
+ .style("border-radius", "50%")
102
+ .style("display", "flex")
103
+ .style("flex-direction", "column")
104
+ .style("justify-content", "center")
105
+ .style("align-items", "center");
106
+ }
118
107
  }
119
108
  Aggregator.aggregatorValueClass = "aggregator-value";
120
109
  Aggregator.aggregatorTitleClass = "aggregator-name";
@@ -3,26 +3,13 @@ import { Block } from "../../block/block";
3
3
  import { ScalesWithSecondary } from "../scale/scale";
4
4
  import { Size } from "../../../config/config";
5
5
  export declare class Axis {
6
- static axesClass: string;
7
- static render(
8
- block: Block,
9
- scales: ScalesWithSecondary,
10
- scaleModel: IScaleModel,
11
- axisModel: IAxisModel,
12
- blockSize: Size
13
- ): void;
14
- static update(
15
- block: Block,
16
- scales: ScalesWithSecondary,
17
- scalesOptions: IScaleModel,
18
- axisModel: IAxisModel,
19
- blockSize: Size,
20
- keyDomainsEquality: boolean
21
- ): void;
22
- static raiseKeyAxis(block: Block, axisOptions: AxisModelOptions): void;
23
- private static findAxis;
24
- private static renderAxis;
25
- private static updateValueAxis;
26
- private static updateKeyAxis;
27
- private static handleLabelsHighlight;
6
+ static axesClass: string;
7
+ static render(block: Block, scales: ScalesWithSecondary, scaleModel: IScaleModel, axisModel: IAxisModel, blockSize: Size): void;
8
+ static update(block: Block, scales: ScalesWithSecondary, scalesOptions: IScaleModel, axisModel: IAxisModel, blockSize: Size, keyDomainsEquality: boolean): void;
9
+ static raiseKeyAxis(block: Block, axisOptions: AxisModelOptions): void;
10
+ private static findAxis;
11
+ private static renderAxis;
12
+ private static updateValueAxis;
13
+ private static updateKeyAxis;
14
+ private static handleLabelsHighlight;
28
15
  }
@@ -8,164 +8,155 @@ import { AxisLabelsEventManager } from "./axisLabelsEventManager";
8
8
  import { AXIS_VERTICAL_LABEL_PADDING } from "../../../model/margin/twoDim/twoDimMarginModel";
9
9
  const MINIMAL_STEP_SIZE_FOR_WRAPPING = 38;
10
10
  export class Axis {
11
- static render(block, scales, scaleModel, axisModel, blockSize) {
12
- var _a;
13
- if (axisModel.value.visibility)
14
- this.renderAxis(block, scales.value, scaleModel.value, axisModel.value, blockSize);
15
- if ((_a = axisModel.valueSecondary) === null || _a === void 0 ? void 0 : _a.visibility)
16
- this.renderAxis(
17
- block,
18
- scales.valueSecondary,
19
- scaleModel.valueSecondary,
20
- axisModel.valueSecondary,
21
- blockSize
22
- );
23
- if (axisModel.key.visibility) this.renderAxis(block, scales.key, scaleModel.key, axisModel.key, blockSize);
24
- }
25
- static update(block, scales, scalesOptions, axisModel, blockSize, keyDomainsEquality) {
26
- var _a;
27
- if (axisModel.value.visibility)
28
- this.updateValueAxis(block, scales.value, scalesOptions.value, axisModel.value, blockSize);
29
- if ((_a = axisModel.valueSecondary) === null || _a === void 0 ? void 0 : _a.visibility)
30
- this.updateValueAxis(
31
- block,
32
- scales.valueSecondary,
33
- scalesOptions.valueSecondary,
34
- axisModel.valueSecondary,
35
- blockSize
36
- );
37
- if (axisModel.key.visibility)
38
- this.updateKeyAxis(block, scales.key, scalesOptions.key, axisModel.key, blockSize, keyDomainsEquality);
39
- }
40
- static raiseKeyAxis(block, axisOptions) {
41
- const axisElement = this.findAxis(block, axisOptions.cssClass);
42
- axisElement.raise();
43
- }
44
- static findAxis(block, axisCssClass) {
45
- return block.getSvg().select(`g.${axisCssClass}`);
46
- }
47
- static renderAxis(block, scale, scaleOptions, axisOptions, blockSize) {
48
- const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scale);
49
- if (axisOptions.type === "value" && scaleOptions.type === "linear")
50
- AxisHelper.setValueAxisLabelsSettings(axisGenerator, scaleOptions, axisOptions.labels);
51
- else axisGenerator.tickFormat(axisOptions.labels.showTick);
52
- const axisElement = block
53
- .getSvg()
54
- .append("g")
55
- .attr("class", `${this.axesClass} ${axisOptions.cssClass} data-label`);
56
- AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate);
57
- if (!axisOptions.line.visible) axisElement.select(".domain").style("display", "none");
58
- if (!axisOptions.labels.visible) {
59
- AxisLabelHelper.hideLabels(axisElement);
60
- return;
61
- }
62
- if (axisOptions.type === "key") {
63
- if (
64
- axisOptions.labels.position === "rotated" &&
65
- (axisOptions.orient === "top" || axisOptions.orient === "bottom")
66
- )
67
- AxisLabelHelper.rotateLabels(axisElement, axisOptions.orient);
68
- if (
69
- (axisOptions.orient === "left" || axisOptions.orient === "right") &&
70
- Scale.getScaleStep(scale) >= MINIMAL_STEP_SIZE_FOR_WRAPPING
71
- )
72
- axisElement.selectAll(".tick text").call(AxisLabelHelper.wrapHandler, axisOptions.labels.maxSize);
73
- else AxisLabelHelper.cropLabels(block, scale, scaleOptions, axisOptions, blockSize);
74
- AxisLabelHelper.alignLabelsInKeyAxis(axisOptions, axisElement);
75
- AxisLabelsEventManager.setHoverEvents(block, axisElement);
76
- block.filterEventManager.eventEmitter.subscribe("change", (selectedKeys) => {
77
- this.handleLabelsHighlight(axisElement, selectedKeys);
78
- });
79
- }
80
- if (axisOptions.type === "value") {
81
- AxisLabelHelper.cropLabels(block, scale, scaleOptions, axisOptions, blockSize);
82
- }
83
- if (axisOptions.labels.defaultTooltip) AxisLabelHelper.setTitles(axisElement, axisOptions);
84
- }
85
- static updateValueAxis(block, scaleValue, scaleOptions, axisOptions, blockSize) {
86
- const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleValue);
87
- AxisHelper.setValueAxisLabelsSettings(axisGenerator, scaleOptions, axisOptions.labels);
88
- const axisElement = block.getSvg().select(`g.${axisOptions.cssClass}`);
89
- AxisDomHelper.updateAxisElement(
90
- axisGenerator,
91
- axisElement,
92
- axisOptions.translate,
93
- block.transitionManager.durations.chartUpdate
94
- ).then(() => {
95
- if (axisOptions.labels.defaultTooltip) AxisLabelHelper.setTitles(axisElement, axisOptions);
96
- if (axisOptions.orient === "bottom" || axisOptions.orient === "top") {
97
- AxisLabelHelper.cropLabels(block, scaleValue, scaleOptions, axisOptions, blockSize);
98
- }
99
- });
100
- }
101
- static updateKeyAxis(block, scaleKey, scaleOptions, axisOptions, blockSize, domainNotUpdated) {
102
- const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleKey);
103
- if (axisOptions.labels.position === "rotated") {
104
- // Задание координат для перевернутых лейблов (если до этого они не были перевернуты)
105
- if (axisOptions.orient === "bottom") axisGenerator.tickPadding(-4);
106
- else if (axisOptions.orient === "top") axisGenerator.tickPadding(-6);
107
- }
108
- axisGenerator.tickFormat(axisOptions.labels.showTick);
109
- const axisElement = block.getSvg().select(`g.${axisOptions.cssClass}`);
110
- AxisLabelsEventManager.removeEvents(axisElement);
111
- if (axisOptions.orient === "left" || axisOptions.orient === "right") {
112
- axisElement.selectAll(".tick text").attr("y", null);
113
- if (axisOptions.orient === "left")
114
- axisGenerator.tickPadding(axisOptions.labels.maxSize + AXIS_VERTICAL_LABEL_PADDING);
115
- }
116
- // Если ключи оси не меняются, то обновление происходит без анимации
117
- AxisDomHelper.updateAxisElement(
118
- axisGenerator,
119
- axisElement,
120
- axisOptions.translate,
121
- domainNotUpdated ? 0 : block.transitionManager.durations.chartUpdate
122
- ).then(() => {
123
- if (axisOptions.orient === "bottom" || axisOptions.orient === "top") {
124
- AxisLabelHelper.cropLabels(block, scaleKey, scaleOptions, axisOptions, blockSize);
125
- }
126
- AxisLabelsEventManager.setHoverEvents(block, axisElement);
127
- if (axisOptions.labels.defaultTooltip) AxisLabelHelper.setTitles(axisElement, axisOptions);
128
- this.handleLabelsHighlight(axisElement, block.filterEventManager.getSelectedKeys());
129
- });
130
- // Ведется отсчет нескольких кадров, чтобы получить уже 100%-отрендеренные лейблы оси.
131
- let frame = 0;
132
- const labelHandler = () => {
133
- frame++;
134
- if (frame < 10) requestAnimationFrame(labelHandler);
135
- if (frame === 2) {
136
- axisElement.selectAll(".tick").each(function (d) {
137
- if (scaleKey.domain().findIndex((key) => key === d) === -1) {
138
- select(this).style("opacity", 0);
139
- } else {
140
- select(this).style("opacity", 1);
141
- }
142
- });
143
- }
144
- if (axisOptions.orient === "left" || axisOptions.orient === "right") {
145
- if (Scale.getScaleStep(scaleKey) >= MINIMAL_STEP_SIZE_FOR_WRAPPING)
146
- axisElement.selectAll(".tick text").call(AxisLabelHelper.wrapHandler, axisOptions.labels.maxSize);
147
- else AxisLabelHelper.cropLabels(block, scaleKey, scaleOptions, axisOptions, blockSize);
148
- AxisLabelHelper.alignLabelsInKeyAxis(axisOptions, axisElement);
149
- }
150
- if (axisOptions.orient === "bottom" || axisOptions.orient === "top") {
151
- if (axisOptions.labels.position === "rotated")
152
- AxisLabelHelper.rotateLabels(axisElement, axisOptions.orient);
153
- if (axisOptions.labels.position === "straight")
154
- // Обратное выравнивание лейблов, если они были перевернуты, но теперь могут отображаться прямо
155
- AxisDomHelper.rotateElementsBack(axisElement);
156
- AxisLabelHelper.cropLabels(block, scaleKey, scaleOptions, axisOptions, blockSize);
157
- }
158
- };
159
- requestAnimationFrame(labelHandler);
160
- }
161
- static handleLabelsHighlight(axisElement, selectedKeys) {
162
- const labels = axisElement.selectAll(".tick text");
163
- if (selectedKeys.length === 0) labels.classed("mdt-charts-opacity-inactive", false);
164
- else
165
- labels.each(function (data) {
166
- const isActive = selectedKeys.includes(data);
167
- select(this).classed("mdt-charts-opacity-inactive", !isActive);
168
- });
169
- }
11
+ static render(block, scales, scaleModel, axisModel, blockSize) {
12
+ var _a;
13
+ if (axisModel.value.visibility)
14
+ this.renderAxis(block, scales.value, scaleModel.value, axisModel.value, blockSize);
15
+ if ((_a = axisModel.valueSecondary) === null || _a === void 0 ? void 0 : _a.visibility)
16
+ this.renderAxis(block, scales.valueSecondary, scaleModel.valueSecondary, axisModel.valueSecondary, blockSize);
17
+ if (axisModel.key.visibility)
18
+ this.renderAxis(block, scales.key, scaleModel.key, axisModel.key, blockSize);
19
+ }
20
+ static update(block, scales, scalesOptions, axisModel, blockSize, keyDomainsEquality) {
21
+ var _a;
22
+ if (axisModel.value.visibility)
23
+ this.updateValueAxis(block, scales.value, scalesOptions.value, axisModel.value, blockSize);
24
+ if ((_a = axisModel.valueSecondary) === null || _a === void 0 ? void 0 : _a.visibility)
25
+ this.updateValueAxis(block, scales.valueSecondary, scalesOptions.valueSecondary, axisModel.valueSecondary, blockSize);
26
+ if (axisModel.key.visibility)
27
+ this.updateKeyAxis(block, scales.key, scalesOptions.key, axisModel.key, blockSize, keyDomainsEquality);
28
+ }
29
+ static raiseKeyAxis(block, axisOptions) {
30
+ const axisElement = this.findAxis(block, axisOptions.cssClass);
31
+ axisElement.raise();
32
+ }
33
+ static findAxis(block, axisCssClass) {
34
+ return block.getSvg().select(`g.${axisCssClass}`);
35
+ }
36
+ static renderAxis(block, scale, scaleOptions, axisOptions, blockSize) {
37
+ const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scale);
38
+ if (axisOptions.type === "value" && scaleOptions.type === "linear")
39
+ AxisHelper.setValueAxisLabelsSettings(axisGenerator, scaleOptions, axisOptions.labels);
40
+ else
41
+ axisGenerator.tickFormat(axisOptions.labels.showTick);
42
+ const axisElement = block
43
+ .getSvg()
44
+ .append("g")
45
+ .attr("class", `${this.axesClass} ${axisOptions.cssClass} data-label`);
46
+ AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate);
47
+ if (!axisOptions.line.visible)
48
+ axisElement.select(".domain").style("display", "none");
49
+ if (!axisOptions.labels.visible) {
50
+ AxisLabelHelper.hideLabels(axisElement);
51
+ return;
52
+ }
53
+ if (axisOptions.type === "key") {
54
+ if (axisOptions.labels.position === "rotated" &&
55
+ (axisOptions.orient === "top" || axisOptions.orient === "bottom"))
56
+ AxisLabelHelper.rotateLabels(axisElement, axisOptions.orient);
57
+ if ((axisOptions.orient === "left" || axisOptions.orient === "right") &&
58
+ Scale.getScaleStep(scale) >= MINIMAL_STEP_SIZE_FOR_WRAPPING)
59
+ axisElement
60
+ .selectAll(".tick text")
61
+ .call(AxisLabelHelper.wrapHandler, axisOptions.labels.maxSize);
62
+ else
63
+ AxisLabelHelper.cropLabels(block, scale, scaleOptions, axisOptions, blockSize);
64
+ AxisLabelHelper.alignLabelsInKeyAxis(axisOptions, axisElement);
65
+ AxisLabelsEventManager.setHoverEvents(block, axisElement);
66
+ block.filterEventManager.eventEmitter.subscribe("change", (selectedKeys) => {
67
+ this.handleLabelsHighlight(axisElement, selectedKeys);
68
+ });
69
+ }
70
+ if (axisOptions.type === "value") {
71
+ AxisLabelHelper.cropLabels(block, scale, scaleOptions, axisOptions, blockSize);
72
+ }
73
+ if (axisOptions.labels.defaultTooltip)
74
+ AxisLabelHelper.setTitles(axisElement, axisOptions);
75
+ }
76
+ static updateValueAxis(block, scaleValue, scaleOptions, axisOptions, blockSize) {
77
+ const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleValue);
78
+ AxisHelper.setValueAxisLabelsSettings(axisGenerator, scaleOptions, axisOptions.labels);
79
+ const axisElement = block.getSvg().select(`g.${axisOptions.cssClass}`);
80
+ AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate, block.transitionManager.durations.chartUpdate).then(() => {
81
+ if (axisOptions.labels.defaultTooltip)
82
+ AxisLabelHelper.setTitles(axisElement, axisOptions);
83
+ if (axisOptions.orient === "bottom" || axisOptions.orient === "top") {
84
+ AxisLabelHelper.cropLabels(block, scaleValue, scaleOptions, axisOptions, blockSize);
85
+ }
86
+ });
87
+ }
88
+ static updateKeyAxis(block, scaleKey, scaleOptions, axisOptions, blockSize, domainNotUpdated) {
89
+ const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleKey);
90
+ if (axisOptions.labels.position === "rotated") {
91
+ // Задание координат для перевернутых лейблов (если до этого они не были перевернуты)
92
+ if (axisOptions.orient === "bottom")
93
+ axisGenerator.tickPadding(-4);
94
+ else if (axisOptions.orient === "top")
95
+ axisGenerator.tickPadding(-6);
96
+ }
97
+ axisGenerator.tickFormat(axisOptions.labels.showTick);
98
+ const axisElement = block.getSvg().select(`g.${axisOptions.cssClass}`);
99
+ AxisLabelsEventManager.removeEvents(axisElement);
100
+ if (axisOptions.orient === "left" || axisOptions.orient === "right") {
101
+ axisElement.selectAll(".tick text").attr("y", null);
102
+ if (axisOptions.orient === "left")
103
+ axisGenerator.tickPadding(axisOptions.labels.maxSize + AXIS_VERTICAL_LABEL_PADDING);
104
+ }
105
+ // Если ключи оси не меняются, то обновление происходит без анимации
106
+ AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate, domainNotUpdated ? 0 : block.transitionManager.durations.chartUpdate).then(() => {
107
+ if (axisOptions.orient === "bottom" || axisOptions.orient === "top") {
108
+ AxisLabelHelper.cropLabels(block, scaleKey, scaleOptions, axisOptions, blockSize);
109
+ }
110
+ AxisLabelsEventManager.setHoverEvents(block, axisElement);
111
+ if (axisOptions.labels.defaultTooltip)
112
+ AxisLabelHelper.setTitles(axisElement, axisOptions);
113
+ this.handleLabelsHighlight(axisElement, block.filterEventManager.getSelectedKeys());
114
+ });
115
+ // Ведется отсчет нескольких кадров, чтобы получить уже 100%-отрендеренные лейблы оси.
116
+ let frame = 0;
117
+ const labelHandler = () => {
118
+ frame++;
119
+ if (frame < 10)
120
+ requestAnimationFrame(labelHandler);
121
+ if (frame === 2) {
122
+ axisElement.selectAll(".tick").each(function (d) {
123
+ if (scaleKey.domain().findIndex((key) => key === d) === -1) {
124
+ select(this).style("opacity", 0);
125
+ }
126
+ else {
127
+ select(this).style("opacity", 1);
128
+ }
129
+ });
130
+ }
131
+ if (axisOptions.orient === "left" || axisOptions.orient === "right") {
132
+ if (Scale.getScaleStep(scaleKey) >= MINIMAL_STEP_SIZE_FOR_WRAPPING)
133
+ axisElement
134
+ .selectAll(".tick text")
135
+ .call(AxisLabelHelper.wrapHandler, axisOptions.labels.maxSize);
136
+ else
137
+ AxisLabelHelper.cropLabels(block, scaleKey, scaleOptions, axisOptions, blockSize);
138
+ AxisLabelHelper.alignLabelsInKeyAxis(axisOptions, axisElement);
139
+ }
140
+ if (axisOptions.orient === "bottom" || axisOptions.orient === "top") {
141
+ if (axisOptions.labels.position === "rotated")
142
+ AxisLabelHelper.rotateLabels(axisElement, axisOptions.orient);
143
+ if (axisOptions.labels.position === "straight")
144
+ // Обратное выравнивание лейблов, если они были перевернуты, но теперь могут отображаться прямо
145
+ AxisDomHelper.rotateElementsBack(axisElement);
146
+ AxisLabelHelper.cropLabels(block, scaleKey, scaleOptions, axisOptions, blockSize);
147
+ }
148
+ };
149
+ requestAnimationFrame(labelHandler);
150
+ }
151
+ static handleLabelsHighlight(axisElement, selectedKeys) {
152
+ const labels = axisElement.selectAll(".tick text");
153
+ if (selectedKeys.length === 0)
154
+ labels.classed("mdt-charts-opacity-inactive", false);
155
+ else
156
+ labels.each(function (data) {
157
+ const isActive = selectedKeys.includes(data);
158
+ select(this).classed("mdt-charts-opacity-inactive", !isActive);
159
+ });
160
+ }
170
161
  }
171
162
  Axis.axesClass = NamesHelper.getClassName("axis");
@@ -2,11 +2,6 @@ import { Selection, BaseType } from "d3-selection";
2
2
  import { Axis as IAxis } from "d3-axis";
3
3
  import { TranslateModel } from "../../../model/model";
4
4
  export declare class AxisDomHelper {
5
- static updateAxisElement(
6
- axisGenerator: IAxis<any>,
7
- axisElement: Selection<SVGGElement, any, BaseType, any>,
8
- translate: TranslateModel,
9
- transitionDuration?: number
10
- ): Promise<string>;
11
- static rotateElementsBack(axisElement: Selection<SVGGElement, unknown, HTMLElement, any>): void;
5
+ static updateAxisElement(axisGenerator: IAxis<any>, axisElement: Selection<SVGGElement, any, BaseType, any>, translate: TranslateModel, transitionDuration?: number): Promise<string>;
6
+ static rotateElementsBack(axisElement: Selection<SVGGElement, unknown, HTMLElement, any>): void;
12
7
  }