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
@@ -9,188 +9,117 @@ import { Scale } from "../../../engine/features/scale/scale";
9
9
  export const AXIS_HORIZONTAL_LABEL_PADDING = 12;
10
10
  export const AXIS_VERTICAL_LABEL_PADDING = 8;
11
11
  export class TwoDimMarginModel {
12
- constructor(designerConfig, configReader) {
13
- this.designerConfig = designerConfig;
14
- this.configReader = configReader;
15
- this.twoDimLegendModel = new TwoDimLegendModel(this.configReader);
16
- }
17
- recalcMargin(otherComponents, modelInstance) {
18
- const canvasModel = modelInstance.canvasModel;
19
- this.twoDimLegendModel.recalcMarginWith2DLegend(
20
- modelInstance,
21
- otherComponents.legendBlock,
22
- this.configReader.options.legend
23
- );
24
- this.recalcVerticalMarginByAxisLabelHeight(LABEL_ELEMENT_HEIGHT_PX, canvasModel);
25
- const labelSize = this.getMaxLabelSize(modelInstance);
26
- // Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
27
- // При этом все графики должны иметь: embeddedLabels = 'key'
28
- // И все графики должны быть типа bar.
29
- const showingFlag =
30
- this.configReader.options.type === "2d"
31
- ? !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(
32
- this.configReader.options.charts,
33
- this.configReader.options.orientation
34
- )
35
- : true;
36
- this.recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, showingFlag);
37
- if (this.configReader.containsSecondaryAxis()) {
38
- const secondaryLabelSize = this.getMaxLabelSizeSecondary(modelInstance);
39
- this.recalcMarginBySecondaryAxisLabelSize(secondaryLabelSize, canvasModel);
40
- }
41
- if (
42
- this.configReader.areValueLabelsOn() &&
43
- this.configReader.areValueLabelsNeedIncreaseMargin() &&
44
- this.configReader.options.orientation === "vertical"
45
- ) {
46
- this.recalcVerticalMarginWithValueLabelsOn(canvasModel);
47
- }
48
- }
49
- recalcMarginByVerticalAxisLabel(modelInstance) {
50
- if (this.configReader.options.orientation === "vertical") {
51
- const dataModel = modelInstance.dataModel;
52
- const axisLabelSize = AxisModel.getLabelSize(
53
- this.designerConfig.canvas.axisLabel.maxSize.main,
54
- dataModel.getAllowableKeys()
55
- );
56
- const axisConfig = AxisModel.getKeyAxisLabelPosition(
57
- modelInstance.canvasModel,
58
- dataModel.getAllowableKeys().length,
59
- this.configReader.options.axis.key
60
- );
61
- const marginOrient = this.configReader.options.axis.key.position === "end" ? "bottom" : "top";
62
- if (axisConfig === "rotated") {
63
- modelInstance.canvasModel.decreaseMarginSide(marginOrient, axisLabelSize.height);
64
- modelInstance.canvasModel.increaseMarginSide(
65
- marginOrient,
66
- axisLabelSize.width,
67
- keyAxisLabelVerticalLog
68
- );
69
- }
70
- }
71
- }
72
- getMaxLabelSize(modelInstance) {
73
- const keyAxisOrient = AxisModel.getAxisOrient(
74
- AxisType.Key,
75
- this.configReader.options.orientation,
76
- this.configReader.options.axis.key.position
77
- );
78
- let labelsTexts;
79
- if (keyAxisOrient === "left" || keyAxisOrient === "right") {
80
- labelsTexts = modelInstance.dataModel.repository.getValuesByKeyField();
81
- } else {
82
- const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel).getScaleLinear(
83
- modelInstance.dataModel.repository.getRawRows(),
84
- this.configReader
85
- );
86
- labelsTexts = this.getValueAxisLabels(scaleModel).map((v) =>
87
- this.configReader.getAxisLabelFormatter()(v).toString()
88
- );
89
- }
90
- return AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, labelsTexts);
91
- }
92
- getMaxLabelSizeSecondary(modelInstance) {
93
- const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel).getScaleSecondaryLinear(
94
- modelInstance.dataModel.repository.getRawRows(),
95
- this.configReader
96
- );
97
- const labelsTexts = this.getValueAxisLabels(scaleModel).map((v) =>
98
- this.configReader.getSecondaryAxisLabelFormatter()(v).toString()
99
- );
100
- return AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, labelsTexts);
101
- }
102
- recalcVerticalMarginByAxisLabelHeight(labelHeight, canvasModel) {
103
- const keyAxisOrient = AxisModel.getAxisOrient(
104
- AxisType.Key,
105
- this.configReader.options.orientation,
106
- this.configReader.options.axis.key.position
107
- );
108
- const valueAxisOrient = AxisModel.getAxisOrient(
109
- AxisType.Value,
110
- this.configReader.options.orientation,
111
- this.configReader.options.axis.value.position
112
- );
113
- if ((keyAxisOrient === "bottom" || keyAxisOrient === "top") && this.configReader.options.axis.key.visibility)
114
- canvasModel.increaseMarginSide(
115
- keyAxisOrient,
116
- labelHeight + AXIS_HORIZONTAL_LABEL_PADDING,
117
- keyAxisLabelVerticalLog
118
- );
119
- else if (this.configReader.options.axis.value.visibility)
120
- canvasModel.increaseMarginSide(valueAxisOrient, labelHeight + AXIS_HORIZONTAL_LABEL_PADDING);
121
- }
122
- recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, isShow) {
123
- const keyAxisOrient = AxisModel.getAxisOrient(
124
- AxisType.Key,
125
- this.configReader.options.orientation,
126
- this.configReader.options.axis.key.position
127
- );
128
- const valueAxisOrient = AxisModel.getAxisOrient(
129
- AxisType.Value,
130
- this.configReader.options.orientation,
131
- this.configReader.options.axis.value.position
132
- );
133
- if (
134
- (keyAxisOrient === "left" || keyAxisOrient === "right") &&
135
- isShow &&
136
- this.configReader.options.axis.key.visibility
137
- ) {
138
- canvasModel.increaseMarginSide(
139
- keyAxisOrient,
140
- labelSize.width + AXIS_VERTICAL_LABEL_PADDING,
141
- keyAxisLabelHorizontalLog
142
- );
143
- } else if (
144
- (valueAxisOrient === "left" || valueAxisOrient === "right") &&
145
- this.configReader.options.axis.value.visibility
146
- ) {
147
- canvasModel.increaseMarginSide(valueAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
148
- }
149
- }
150
- recalcMarginBySecondaryAxisLabelSize(labelSize, canvasModel) {
151
- const valueAxisOrient = AxisModel.getAxisOrient(
152
- AxisType.Value,
153
- this.configReader.options.orientation,
154
- this.configReader.options.axis.value.position
155
- );
156
- const secondaryOrientByMain = {
157
- bottom: "top",
158
- left: "right",
159
- right: "left",
160
- top: "bottom"
161
- };
162
- const secondaryOrient = secondaryOrientByMain[valueAxisOrient];
163
- const sizeMap = {
164
- vertical: labelSize.width + AXIS_VERTICAL_LABEL_PADDING,
165
- horizontal: labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING
166
- };
167
- if (this.configReader.options.axis.valueSecondary.visibility) {
168
- canvasModel.increaseMarginSide(secondaryOrient, sizeMap[this.configReader.options.orientation]);
169
- }
170
- }
171
- recalcVerticalMarginWithValueLabelsOn(canvasModel) {
172
- const keyAxisOrient = AxisModel.getAxisOrient(
173
- AxisType.Key,
174
- this.configReader.options.orientation,
175
- this.configReader.options.axis.key.position
176
- );
177
- const valueLabelFontSize = this.configReader.getValueLabelsStyleModel().fontSize;
178
- const axisMarginMapping = {
179
- top: "bottom",
180
- bottom: "top"
181
- };
182
- canvasModel.increaseMarginSide(axisMarginMapping[keyAxisOrient], valueLabelFontSize + OFFSET_SIZE_PX);
183
- }
184
- getValueAxisLabels(scaleModel) {
185
- const scale = Scale.getScaleValue(scaleModel);
186
- const ticksPolicy = AxisModel.getTickAmountPolicy(
187
- this.configReader.options.orientation,
188
- this.configReader.options.axis.value,
189
- scaleModel
190
- );
191
- let outputValues = [];
192
- if (ticksPolicy.type === "constant") outputValues = ticksPolicy.values;
193
- else if (ticksPolicy.type === "amount") outputValues = scale.ticks(ticksPolicy.amount);
194
- return outputValues;
195
- }
12
+ constructor(designerConfig, configReader) {
13
+ this.designerConfig = designerConfig;
14
+ this.configReader = configReader;
15
+ this.twoDimLegendModel = new TwoDimLegendModel(this.configReader);
16
+ }
17
+ recalcMargin(otherComponents, modelInstance) {
18
+ const canvasModel = modelInstance.canvasModel;
19
+ this.twoDimLegendModel.recalcMarginWith2DLegend(modelInstance, otherComponents.legendBlock, this.configReader.options.legend);
20
+ this.recalcVerticalMarginByAxisLabelHeight(LABEL_ELEMENT_HEIGHT_PX, canvasModel);
21
+ const labelSize = this.getMaxLabelSize(modelInstance);
22
+ // Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
23
+ // При этом все графики должны иметь: embeddedLabels = 'key'
24
+ // И все графики должны быть типа bar.
25
+ const showingFlag = this.configReader.options.type === "2d"
26
+ ? !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(this.configReader.options.charts, this.configReader.options.orientation)
27
+ : true;
28
+ this.recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, showingFlag);
29
+ if (this.configReader.containsSecondaryAxis()) {
30
+ const secondaryLabelSize = this.getMaxLabelSizeSecondary(modelInstance);
31
+ this.recalcMarginBySecondaryAxisLabelSize(secondaryLabelSize, canvasModel);
32
+ }
33
+ if (this.configReader.areValueLabelsOn() &&
34
+ this.configReader.areValueLabelsNeedIncreaseMargin() &&
35
+ this.configReader.options.orientation === "vertical") {
36
+ this.recalcVerticalMarginWithValueLabelsOn(canvasModel);
37
+ }
38
+ }
39
+ recalcMarginByVerticalAxisLabel(modelInstance) {
40
+ if (this.configReader.options.orientation === "vertical") {
41
+ const dataModel = modelInstance.dataModel;
42
+ const axisLabelSize = AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, dataModel.getAllowableKeys());
43
+ const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataModel.getAllowableKeys().length, this.configReader.options.axis.key);
44
+ const marginOrient = this.configReader.options.axis.key.position === "end" ? "bottom" : "top";
45
+ if (axisConfig === "rotated") {
46
+ modelInstance.canvasModel.decreaseMarginSide(marginOrient, axisLabelSize.height);
47
+ modelInstance.canvasModel.increaseMarginSide(marginOrient, axisLabelSize.width, keyAxisLabelVerticalLog);
48
+ }
49
+ }
50
+ }
51
+ getMaxLabelSize(modelInstance) {
52
+ const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, this.configReader.options.orientation, this.configReader.options.axis.key.position);
53
+ let labelsTexts;
54
+ if (keyAxisOrient === "left" || keyAxisOrient === "right") {
55
+ labelsTexts = modelInstance.dataModel.repository.getValuesByKeyField();
56
+ }
57
+ else {
58
+ const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel).getScaleLinear(modelInstance.dataModel.repository.getRawRows(), this.configReader);
59
+ labelsTexts = this.getValueAxisLabels(scaleModel).map((v) => this.configReader.getAxisLabelFormatter()(v).toString());
60
+ }
61
+ return AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, labelsTexts);
62
+ }
63
+ getMaxLabelSizeSecondary(modelInstance) {
64
+ const scaleModel = new ScaleModel(this.configReader.options, modelInstance.canvasModel).getScaleSecondaryLinear(modelInstance.dataModel.repository.getRawRows(), this.configReader);
65
+ const labelsTexts = this.getValueAxisLabels(scaleModel).map((v) => this.configReader.getSecondaryAxisLabelFormatter()(v).toString());
66
+ return AxisModel.getLabelSize(this.designerConfig.canvas.axisLabel.maxSize.main, labelsTexts);
67
+ }
68
+ recalcVerticalMarginByAxisLabelHeight(labelHeight, canvasModel) {
69
+ const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, this.configReader.options.orientation, this.configReader.options.axis.key.position);
70
+ const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, this.configReader.options.orientation, this.configReader.options.axis.value.position);
71
+ if ((keyAxisOrient === "bottom" || keyAxisOrient === "top") && this.configReader.options.axis.key.visibility)
72
+ canvasModel.increaseMarginSide(keyAxisOrient, labelHeight + AXIS_HORIZONTAL_LABEL_PADDING, keyAxisLabelVerticalLog);
73
+ else if (this.configReader.options.axis.value.visibility)
74
+ canvasModel.increaseMarginSide(valueAxisOrient, labelHeight + AXIS_HORIZONTAL_LABEL_PADDING);
75
+ }
76
+ recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, isShow) {
77
+ const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, this.configReader.options.orientation, this.configReader.options.axis.key.position);
78
+ const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, this.configReader.options.orientation, this.configReader.options.axis.value.position);
79
+ if ((keyAxisOrient === "left" || keyAxisOrient === "right") &&
80
+ isShow &&
81
+ this.configReader.options.axis.key.visibility) {
82
+ canvasModel.increaseMarginSide(keyAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING, keyAxisLabelHorizontalLog);
83
+ }
84
+ else if ((valueAxisOrient === "left" || valueAxisOrient === "right") &&
85
+ this.configReader.options.axis.value.visibility) {
86
+ canvasModel.increaseMarginSide(valueAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
87
+ }
88
+ }
89
+ recalcMarginBySecondaryAxisLabelSize(labelSize, canvasModel) {
90
+ const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, this.configReader.options.orientation, this.configReader.options.axis.value.position);
91
+ const secondaryOrientByMain = {
92
+ bottom: "top",
93
+ left: "right",
94
+ right: "left",
95
+ top: "bottom"
96
+ };
97
+ const secondaryOrient = secondaryOrientByMain[valueAxisOrient];
98
+ const sizeMap = {
99
+ vertical: labelSize.width + AXIS_VERTICAL_LABEL_PADDING,
100
+ horizontal: labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING
101
+ };
102
+ if (this.configReader.options.axis.valueSecondary.visibility) {
103
+ canvasModel.increaseMarginSide(secondaryOrient, sizeMap[this.configReader.options.orientation]);
104
+ }
105
+ }
106
+ recalcVerticalMarginWithValueLabelsOn(canvasModel) {
107
+ const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, this.configReader.options.orientation, this.configReader.options.axis.key.position);
108
+ const valueLabelFontSize = this.configReader.getValueLabelsStyleModel().fontSize;
109
+ const axisMarginMapping = {
110
+ top: "bottom",
111
+ bottom: "top"
112
+ };
113
+ canvasModel.increaseMarginSide(axisMarginMapping[keyAxisOrient], valueLabelFontSize + OFFSET_SIZE_PX);
114
+ }
115
+ getValueAxisLabels(scaleModel) {
116
+ const scale = Scale.getScaleValue(scaleModel);
117
+ const ticksPolicy = AxisModel.getTickAmountPolicy(this.configReader.options.orientation, this.configReader.options.axis.value, scaleModel);
118
+ let outputValues = [];
119
+ if (ticksPolicy.type === "constant")
120
+ outputValues = ticksPolicy.values;
121
+ else if (ticksPolicy.type === "amount")
122
+ outputValues = scale.ticks(ticksPolicy.amount);
123
+ return outputValues;
124
+ }
196
125
  }