mdt-charts 1.28.2 → 1.29.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 (255) hide show
  1. package/lib/config/config.d.ts +164 -165
  2. package/lib/designer/designerConfig.d.ts +62 -59
  3. package/lib/engine/block/block.d.ts +22 -16
  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 +65 -66
  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 +6 -6
  18. package/lib/engine/contentManager/contentManager.js +15 -15
  19. package/lib/engine/contentManager/contentManagerFactory.d.ts +6 -6
  20. package/lib/engine/contentManager/contentManagerFactory.js +12 -12
  21. package/lib/engine/elementHighlighter/elementHighlighter.d.ts +70 -22
  22. package/lib/engine/elementHighlighter/elementHighlighter.js +230 -181
  23. package/lib/engine/elementHighlighter/selectHighlighter.d.ts +29 -4
  24. package/lib/engine/elementHighlighter/selectHighlighter.js +189 -87
  25. package/lib/engine/engine.d.ts +16 -16
  26. package/lib/engine/engine.js +87 -62
  27. package/lib/engine/features/aggregator/aggregator.d.ts +24 -17
  28. package/lib/engine/features/aggregator/aggregator.js +113 -102
  29. package/lib/engine/features/axis/axis.d.ts +22 -9
  30. package/lib/engine/features/axis/axis.js +159 -150
  31. package/lib/engine/features/axis/axisDomHelper.d.ts +7 -2
  32. package/lib/engine/features/axis/axisDomHelper.js +19 -20
  33. package/lib/engine/features/axis/axisHelper.d.ts +9 -5
  34. package/lib/engine/features/axis/axisHelper.js +28 -33
  35. package/lib/engine/features/axis/axisLabelDomHelper.d.ts +26 -11
  36. package/lib/engine/features/axis/axisLabelDomHelper.js +156 -152
  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 +51 -16
  40. package/lib/engine/features/embeddedLabels/embeddedLabels.js +234 -134
  41. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +13 -2
  42. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +20 -23
  43. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +32 -15
  44. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +56 -63
  45. package/lib/engine/features/gridLine/gidLineHelper.d.ts +13 -7
  46. package/lib/engine/features/gridLine/gidLineHelper.js +42 -49
  47. package/lib/engine/features/gridLine/gridLine.d.ts +19 -5
  48. package/lib/engine/features/gridLine/gridLine.js +35 -36
  49. package/lib/engine/features/legend/legend.d.ts +38 -29
  50. package/lib/engine/features/legend/legend.js +117 -92
  51. package/lib/engine/features/legend/legendDomHelper.d.ts +13 -6
  52. package/lib/engine/features/legend/legendDomHelper.js +63 -62
  53. package/lib/engine/features/legend/legendEventsManager.d.ts +13 -8
  54. package/lib/engine/features/legend/legendEventsManager.js +48 -47
  55. package/lib/engine/features/legend/legendHelper.d.ts +39 -14
  56. package/lib/engine/features/legend/legendHelper.js +98 -93
  57. package/lib/engine/features/legend/legendHelperService.d.ts +13 -6
  58. package/lib/engine/features/legend/legendHelperService.js +24 -25
  59. package/lib/engine/features/legend/legendMarkerCreator.d.ts +18 -9
  60. package/lib/engine/features/legend/legendMarkerCreator.js +79 -76
  61. package/lib/engine/features/legend/legendWidthCalculator.d.ts +7 -7
  62. package/lib/engine/features/legend/legendWidthCalculator.js +126 -122
  63. package/lib/engine/features/markDots/markDot.d.ts +42 -15
  64. package/lib/engine/features/markDots/markDot.js +101 -70
  65. package/lib/engine/features/markDots/markDotsHelper.d.ts +8 -1
  66. package/lib/engine/features/markDots/markDotsHelper.js +13 -12
  67. package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.d.ts +17 -17
  68. package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +42 -47
  69. package/lib/engine/features/scale/scale.d.ts +17 -12
  70. package/lib/engine/features/scale/scale.js +76 -69
  71. package/lib/engine/features/tipBox/tipBox.d.ts +9 -5
  72. package/lib/engine/features/tipBox/tipBox.js +24 -24
  73. package/lib/engine/features/tipBox/tipBoxHelper.d.ts +16 -9
  74. package/lib/engine/features/tipBox/tipBoxHelper.js +60 -45
  75. package/lib/engine/features/title/title.d.ts +6 -6
  76. package/lib/engine/features/title/title.js +34 -35
  77. package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +15 -11
  78. package/lib/engine/features/tolltip/newTooltip/newTooltip.js +21 -21
  79. package/lib/engine/features/tolltip/newTooltip/newTooltipService.d.ts +13 -8
  80. package/lib/engine/features/tolltip/newTooltip/newTooltipService.js +26 -23
  81. package/lib/engine/features/tolltip/tooltip.d.ts +17 -11
  82. package/lib/engine/features/tolltip/tooltip.js +296 -142
  83. package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +21 -10
  84. package/lib/engine/features/tolltip/tooltipComponentsManager.js +113 -114
  85. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +43 -21
  86. package/lib/engine/features/tolltip/tooltipDomHelper.js +144 -120
  87. package/lib/engine/features/tolltip/tooltipHelper.d.ts +39 -9
  88. package/lib/engine/features/tolltip/tooltipHelper.js +114 -91
  89. package/lib/engine/features/valueLabels/valueLabels.d.ts +58 -38
  90. package/lib/engine/features/valueLabels/valueLabels.js +205 -169
  91. package/lib/engine/features/valueLabels/valueLabelsHelper.d.ts +7 -1
  92. package/lib/engine/features/valueLabels/valueLabelsHelper.js +23 -18
  93. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.d.ts +18 -15
  94. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +46 -47
  95. package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.d.ts +6 -3
  96. package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.js +49 -45
  97. package/lib/engine/filterManager/filterEventManager.d.ts +37 -26
  98. package/lib/engine/filterManager/filterEventManager.js +174 -129
  99. package/lib/engine/helpers/domHelper.d.ts +45 -20
  100. package/lib/engine/helpers/domHelper.js +62 -61
  101. package/lib/engine/helpers/fontResizer/fontResizer.d.ts +10 -10
  102. package/lib/engine/helpers/fontResizer/fontResizer.js +21 -16
  103. package/lib/engine/helpers/fontResizer/fontResizerService.d.ts +1 -1
  104. package/lib/engine/helpers/fontResizer/fontResizerService.js +9 -10
  105. package/lib/engine/helpers/helper.d.ts +27 -27
  106. package/lib/engine/helpers/helper.js +91 -92
  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 +25 -11
  112. package/lib/engine/polarNotation/donut/DonutHelper.js +71 -70
  113. package/lib/engine/polarNotation/donut/donut.d.ts +38 -23
  114. package/lib/engine/polarNotation/donut/donut.js +109 -99
  115. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.d.ts +7 -7
  116. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +36 -36
  117. package/lib/engine/polarNotation/polarManager.d.ts +5 -5
  118. package/lib/engine/polarNotation/polarManager.js +66 -52
  119. package/lib/engine/transitionManager.d.ts +13 -14
  120. package/lib/engine/transitionManager.js +48 -49
  121. package/lib/engine/twoDimensionalNotation/area/area.d.ts +44 -28
  122. package/lib/engine/twoDimensionalNotation/area/area.js +272 -238
  123. package/lib/engine/twoDimensionalNotation/area/areaGenerator.d.ts +13 -5
  124. package/lib/engine/twoDimensionalNotation/area/areaGenerator.js +13 -13
  125. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +4 -4
  126. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +57 -41
  127. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +54 -29
  128. package/lib/engine/twoDimensionalNotation/bar/bar.js +362 -224
  129. package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +71 -32
  130. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +162 -126
  131. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.d.ts +6 -6
  132. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.js +24 -24
  133. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStackerService.d.ts +2 -2
  134. package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStackerService.js +16 -17
  135. package/lib/engine/twoDimensionalNotation/dot/dotChart.d.ts +23 -23
  136. package/lib/engine/twoDimensionalNotation/dot/dotChart.js +135 -114
  137. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.d.ts +7 -7
  138. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +28 -28
  139. package/lib/engine/twoDimensionalNotation/line/line.d.ts +37 -16
  140. package/lib/engine/twoDimensionalNotation/line/line.js +162 -132
  141. package/lib/engine/twoDimensionalNotation/line/lineBuilder.d.ts +14 -11
  142. package/lib/engine/twoDimensionalNotation/line/lineBuilder.js +47 -48
  143. package/lib/engine/twoDimensionalNotation/line/lineGenerator.d.ts +4 -4
  144. package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +8 -8
  145. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +12 -6
  146. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +76 -60
  147. package/lib/engine/twoDimensionalNotation/lineLike/generatorFactory/lineLikeGeneratorFactory.d.ts +6 -6
  148. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorCurveMiddleware.d.ts +5 -5
  149. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorCurveMiddleware.js +16 -17
  150. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.d.ts +11 -10
  151. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.js +9 -7
  152. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorMiddleware.d.ts +3 -1
  153. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +9 -9
  154. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +252 -143
  155. package/lib/engine/valueFormatter.d.ts +3 -3
  156. package/lib/engine/valueFormatter.js +6 -6
  157. package/lib/main.d.ts +82 -75
  158. package/lib/main.js +79 -84
  159. package/lib/model/EventEmitter.d.ts +8 -8
  160. package/lib/model/EventEmitter.js +24 -24
  161. package/lib/model/chartStyleModel/chartStyleModel.d.ts +5 -5
  162. package/lib/model/chartStyleModel/chartStyleModel.js +27 -25
  163. package/lib/model/chartStyleModel/colorRange.d.ts +3 -3
  164. package/lib/model/chartStyleModel/colorRange.js +19 -24
  165. package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.d.ts +22 -12
  166. package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.js +69 -60
  167. package/lib/model/configsValidator/configValidator.d.ts +1 -1
  168. package/lib/model/configsValidator/configValidator.js +4 -4
  169. package/lib/model/dataManagerModel/dataManagerModel.d.ts +36 -26
  170. package/lib/model/dataManagerModel/dataManagerModel.js +179 -128
  171. package/lib/model/dataManagerModel/dataManagerModelService.d.ts +2 -2
  172. package/lib/model/dataManagerModel/dataManagerModelService.js +25 -26
  173. package/lib/model/featuresModel/axisModel.d.ts +69 -18
  174. package/lib/model/featuresModel/axisModel.js +224 -169
  175. package/lib/model/featuresModel/axisModelService.d.ts +10 -6
  176. package/lib/model/featuresModel/axisModelService.js +27 -27
  177. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +16 -11
  178. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +55 -59
  179. package/lib/model/featuresModel/legendModel/legendModel.d.ts +7 -3
  180. package/lib/model/featuresModel/legendModel/legendModel.js +59 -41
  181. package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +8 -3
  182. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +18 -20
  183. package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +8 -4
  184. package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +40 -27
  185. package/lib/model/featuresModel/otherComponents.d.ts +7 -4
  186. package/lib/model/featuresModel/otherComponents.js +9 -9
  187. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +6 -6
  188. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +27 -23
  189. package/lib/model/featuresModel/scaleModel/scaleDomainService.d.ts +19 -5
  190. package/lib/model/featuresModel/scaleModel/scaleDomainService.js +44 -55
  191. package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +10 -10
  192. package/lib/model/featuresModel/scaleModel/scaleModel.js +61 -50
  193. package/lib/model/featuresModel/scaleModel/scaleModelServices.js +15 -22
  194. package/lib/model/featuresModel/titleModel.d.ts +1 -1
  195. package/lib/model/featuresModel/titleModel.js +14 -14
  196. package/lib/model/featuresModel/tooltipModel.d.ts +1 -1
  197. package/lib/model/featuresModel/tooltipModel.js +5 -5
  198. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +23 -11
  199. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +53 -51
  200. package/lib/model/helpers/modelHelper.d.ts +7 -7
  201. package/lib/model/helpers/modelHelper.js +38 -42
  202. package/lib/model/helpers/twoDimensionalModelHelper.d.ts +37 -9
  203. package/lib/model/helpers/twoDimensionalModelHelper.js +147 -125
  204. package/lib/model/helpers/unitsFromConfigReader.js +4 -4
  205. package/lib/model/helpers/unitsReader.d.ts +2 -2
  206. package/lib/model/helpers/unitsReader.js +11 -13
  207. package/lib/model/margin/marginModel.d.ts +7 -7
  208. package/lib/model/margin/marginModel.js +23 -20
  209. package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +13 -13
  210. package/lib/model/margin/twoDim/twoDimMarginModel.js +184 -113
  211. package/lib/model/model.d.ts +308 -280
  212. package/lib/model/model.js +4 -4
  213. package/lib/model/modelBuilder.d.ts +27 -18
  214. package/lib/model/modelBuilder.js +85 -79
  215. package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +17 -17
  216. package/lib/model/modelInstance/canvasModel/canvasModel.js +42 -43
  217. package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasMarginModel.d.ts +7 -7
  218. package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasSizeModel.d.ts +2 -2
  219. package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.d.ts +6 -6
  220. package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +24 -24
  221. package/lib/model/modelInstance/canvasModel/legendCanvasModel.d.ts +4 -4
  222. package/lib/model/modelInstance/canvasModel/legendCanvasModel.js +11 -11
  223. package/lib/model/modelInstance/canvasModel/titleCanvas.d.ts +4 -4
  224. package/lib/model/modelInstance/canvasModel/titleCanvas.js +9 -9
  225. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.d.ts +3 -3
  226. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.js +6 -6
  227. package/lib/model/modelInstance/configReader.d.ts +32 -23
  228. package/lib/model/modelInstance/configReader.js +125 -94
  229. package/lib/model/modelInstance/dataModel/dataModel.d.ts +9 -9
  230. package/lib/model/modelInstance/dataModel/dataModel.js +24 -24
  231. package/lib/model/modelInstance/dataModel/dataRepository.d.ts +14 -14
  232. package/lib/model/modelInstance/dataModel/dataRepository.js +42 -42
  233. package/lib/model/modelInstance/modelInstance.d.ts +11 -6
  234. package/lib/model/modelInstance/modelInstance.js +16 -16
  235. package/lib/model/modelInstance/titleConfigReader.d.ts +8 -8
  236. package/lib/model/modelInstance/titleConfigReader.js +37 -30
  237. package/lib/model/notations/polar/donut/donutAggregatorService.d.ts +9 -6
  238. package/lib/model/notations/polar/donut/donutAggregatorService.js +40 -37
  239. package/lib/model/notations/polar/donut/donutModel.d.ts +9 -5
  240. package/lib/model/notations/polar/donut/donutModel.js +28 -28
  241. package/lib/model/notations/polar/donut/donutThicknessService.d.ts +3 -3
  242. package/lib/model/notations/polar/donut/donutThicknessService.js +13 -15
  243. package/lib/model/notations/polar/polarModel.d.ts +18 -7
  244. package/lib/model/notations/polar/polarModel.js +79 -65
  245. package/lib/model/notations/twoDimensional/styles.d.ts +44 -7
  246. package/lib/model/notations/twoDimensional/styles.js +234 -125
  247. package/lib/model/notations/twoDimensionalModel.d.ts +23 -13
  248. package/lib/model/notations/twoDimensionalModel.js +330 -162
  249. package/lib/optionsServices/publicOptionsService.d.ts +1 -1
  250. package/lib/optionsServices/publicOptionsService.js +4 -4
  251. package/lib/optionsServices/validators/sizeValidator.d.ts +2 -2
  252. package/lib/optionsServices/validators/sizeValidator.js +10 -11
  253. package/lib/style/charts-main.css +150 -151
  254. package/lib/style/charts-main.less +150 -151
  255. package/package.json +1 -1
@@ -2,98 +2,103 @@ import { Helper } from "../../helpers/helper";
2
2
  import { Legend } from "./legend";
3
3
  import { LegendHelperService } from "./legendHelperService";
4
4
  export class LegendHelper {
5
- static getLegendItemsContent(options, data) {
6
- if (options.type === "2d") {
7
- let texts = [];
8
- options.charts.forEach((chart) => {
9
- texts = texts.concat(chart.data.valueFields.map((field) => (Object.assign(Object.assign({}, chart.legend), { textContent: field.title }))));
10
- });
11
- return texts;
12
- }
13
- if (options.type === "polar") {
14
- return data[options.data.dataSource].map((record) => (Object.assign(Object.assign({}, options.charts[0].legend), { textContent: record[options.data.keyField.name] })));
15
- }
16
- }
17
- static getMarksColor(options, dataRows) {
18
- if (options.type === "2d") {
19
- let colors = [];
20
- options.charts.forEach((chart) => {
21
- colors = colors.concat(chart.style.elementColors);
22
- });
23
- return colors;
24
- }
25
- else if (options.type === "polar") {
26
- if (!options.charts[0].data.colorField)
27
- return options.charts.map((chart) => chart.style.elementColors)[0];
28
- return dataRows.map((row) => row[options.charts[0].data.colorField]);
29
- }
30
- }
31
- static getMaxItemWidth(legendBlockWidth, marginsLeft, itemsDirection) {
32
- if (itemsDirection === "row") {
33
- const sumOfMargins = Helper.getSumOfNumeric(marginsLeft);
34
- return (parseFloat(legendBlockWidth) - sumOfMargins) / marginsLeft.length;
35
- }
36
- return parseFloat(legendBlockWidth);
37
- }
38
- static getSumOfItemsWidths(itemsWidth, marginsLeft) {
39
- let sumOfItemsWidth = Helper.getSumOfNumeric(itemsWidth);
40
- sumOfItemsWidth += Helper.getSumOfNumeric(marginsLeft);
41
- return sumOfItemsWidth;
42
- }
43
- static getLegendCoordinateByPosition(legendPosition, legendBlockModel, blockSize) {
44
- const legendModel = legendBlockModel.coordinate[legendPosition];
45
- const coordinate = {
46
- x: 0,
47
- y: 0,
48
- width: 0,
49
- height: 0
50
- };
51
- if (legendPosition === "left" || legendPosition === "right") {
52
- coordinate.y = legendModel.margin.top + legendModel.pad;
53
- coordinate.width = legendModel.size;
54
- coordinate.height = blockSize.height - legendModel.margin.top - legendModel.margin.bottom;
55
- }
56
- else if (legendPosition === "bottom" || legendPosition === "top") {
57
- coordinate.x = legendModel.margin.left;
58
- coordinate.width = blockSize.width - legendModel.margin.left - legendModel.margin.right;
59
- coordinate.height = legendModel.size;
60
- }
61
- if (legendPosition === "left")
62
- coordinate.x = legendModel.margin.left;
63
- else if (legendPosition === "right")
64
- coordinate.x = blockSize.width - legendModel.size - legendModel.margin.right;
65
- else if (legendPosition === "top")
66
- coordinate.y = legendModel.margin.top + legendModel.pad;
67
- else if (legendPosition === "bottom")
68
- coordinate.y = blockSize.height - legendModel.size - legendModel.margin.bottom;
69
- return coordinate;
70
- }
71
- static getContentRenderingOptions(chartNotation, legendPosition, legendBlockModel) {
72
- const itemsDirection = this.service.getLegendItemsDirection(legendPosition);
73
- const legendLabelClass = this.getLegendClassByChartNotation(chartNotation);
74
- return {
75
- wrapperClasses: [
76
- Legend.legendBlockClass,
77
- chartNotation === "2d" ? "legend-block-centered" : "",
78
- this.service.getWrapperClassByItemsDirection(itemsDirection),
79
- this.service.getWrapperClassByWrappingItems(legendPosition, chartNotation)
80
- ],
81
- shouldCropLabels: chartNotation === "2d",
82
- blockModel: legendBlockModel,
83
- itemsOptions: {
84
- markerClass: Legend.markerClass,
85
- labelClass: this.service.getLegendLabelClassByPosition(legendPosition, chartNotation, legendLabelClass),
86
- wrapperClasses: [Legend.itemClass, this.service.getItemClasses(itemsDirection)]
87
- }
88
- };
89
- }
90
- static getLegendClassByChartNotation(chartNotation) {
91
- const legendClasses = {
92
- "2d": Legend.label2DClass,
93
- polar: Legend.labelPolarClass,
94
- interval: Legend.labelIntervalClass
95
- };
96
- return `${Legend.labelClass} ${legendClasses[chartNotation]}`;
97
- }
5
+ static getLegendItemsContent(options, data) {
6
+ if (options.type === "2d") {
7
+ let texts = [];
8
+ options.charts.forEach((chart) => {
9
+ texts = texts.concat(
10
+ chart.data.valueFields.map((field) =>
11
+ Object.assign(Object.assign({}, chart.legend), {
12
+ textContent: field.title
13
+ })
14
+ )
15
+ );
16
+ });
17
+ return texts;
18
+ }
19
+ if (options.type === "polar") {
20
+ return data[options.data.dataSource].map((record) =>
21
+ Object.assign(Object.assign({}, options.charts[0].legend), {
22
+ textContent: record[options.data.keyField.name]
23
+ })
24
+ );
25
+ }
26
+ }
27
+ static getMarksColor(options, dataRows) {
28
+ if (options.type === "2d") {
29
+ let colors = [];
30
+ options.charts.forEach((chart) => {
31
+ colors = colors.concat(chart.style.elementColors);
32
+ });
33
+ return colors;
34
+ } else if (options.type === "polar") {
35
+ if (!options.charts[0].data.colorField) return options.charts.map((chart) => chart.style.elementColors)[0];
36
+ return dataRows.map((row) => row[options.charts[0].data.colorField]);
37
+ }
38
+ }
39
+ static getMaxItemWidth(legendBlockWidth, marginsLeft, itemsDirection) {
40
+ if (itemsDirection === "row") {
41
+ const sumOfMargins = Helper.getSumOfNumeric(marginsLeft);
42
+ return (parseFloat(legendBlockWidth) - sumOfMargins) / marginsLeft.length;
43
+ }
44
+ return parseFloat(legendBlockWidth);
45
+ }
46
+ static getSumOfItemsWidths(itemsWidth, marginsLeft) {
47
+ let sumOfItemsWidth = Helper.getSumOfNumeric(itemsWidth);
48
+ sumOfItemsWidth += Helper.getSumOfNumeric(marginsLeft);
49
+ return sumOfItemsWidth;
50
+ }
51
+ static getLegendCoordinateByPosition(legendPosition, legendBlockModel, blockSize) {
52
+ const legendModel = legendBlockModel.coordinate[legendPosition];
53
+ const coordinate = {
54
+ x: 0,
55
+ y: 0,
56
+ width: 0,
57
+ height: 0
58
+ };
59
+ if (legendPosition === "left" || legendPosition === "right") {
60
+ coordinate.y = legendModel.margin.top + legendModel.pad;
61
+ coordinate.width = legendModel.size;
62
+ coordinate.height = blockSize.height - legendModel.margin.top - legendModel.margin.bottom;
63
+ } else if (legendPosition === "bottom" || legendPosition === "top") {
64
+ coordinate.x = legendModel.margin.left;
65
+ coordinate.width = blockSize.width - legendModel.margin.left - legendModel.margin.right;
66
+ coordinate.height = legendModel.size;
67
+ }
68
+ if (legendPosition === "left") coordinate.x = legendModel.margin.left;
69
+ else if (legendPosition === "right")
70
+ coordinate.x = blockSize.width - legendModel.size - legendModel.margin.right;
71
+ else if (legendPosition === "top") coordinate.y = legendModel.margin.top + legendModel.pad;
72
+ else if (legendPosition === "bottom")
73
+ coordinate.y = blockSize.height - legendModel.size - legendModel.margin.bottom;
74
+ return coordinate;
75
+ }
76
+ static getContentRenderingOptions(chartNotation, legendPosition, legendBlockModel) {
77
+ const itemsDirection = this.service.getLegendItemsDirection(legendPosition);
78
+ const legendLabelClass = this.getLegendClassByChartNotation(chartNotation);
79
+ return {
80
+ wrapperClasses: [
81
+ Legend.legendBlockClass,
82
+ chartNotation === "2d" ? "legend-block-centered" : "",
83
+ this.service.getWrapperClassByItemsDirection(itemsDirection),
84
+ this.service.getWrapperClassByWrappingItems(legendPosition, chartNotation)
85
+ ],
86
+ shouldCropLabels: chartNotation === "2d",
87
+ blockModel: legendBlockModel,
88
+ itemsOptions: {
89
+ markerClass: Legend.markerClass,
90
+ labelClass: this.service.getLegendLabelClassByPosition(legendPosition, chartNotation, legendLabelClass),
91
+ wrapperClasses: [Legend.itemClass, this.service.getItemClasses(itemsDirection)]
92
+ }
93
+ };
94
+ }
95
+ static getLegendClassByChartNotation(chartNotation) {
96
+ const legendClasses = {
97
+ "2d": Legend.label2DClass,
98
+ polar: Legend.labelPolarClass,
99
+ interval: Legend.labelIntervalClass
100
+ };
101
+ return `${Legend.labelClass} ${legendClasses[chartNotation]}`;
102
+ }
98
103
  }
99
104
  LegendHelper.service = new LegendHelperService();
@@ -2,10 +2,17 @@ import { ChartNotation } from "../../../config/config";
2
2
  import { LegendItemsDirection } from "../../../model/featuresModel/legendModel/legendCanvasModel";
3
3
  import { LegendPosition } from "../../../model/model";
4
4
  export declare class LegendHelperService {
5
- getWrapperClassByItemsDirection(itemsDirection: LegendItemsDirection): "legend-block-column" | "legend-block-row";
6
- getWrapperClassByWrappingItems(legendPosition: LegendPosition, chartNotation: ChartNotation): "legend-wrapper-with-wrap" | "legend-wrapper-without-wrap";
7
- getLegendLabelClassByPosition(legendPosition: LegendPosition, chartNotation: ChartNotation, initialLabelClass: string): string;
8
- getItemClasses(itemsDirection: LegendItemsDirection): string;
9
- getLegendItemsDirection(legendPosition: LegendPosition): LegendItemsDirection;
10
- private doesLegendInTopBy2d;
5
+ getWrapperClassByItemsDirection(itemsDirection: LegendItemsDirection): "legend-block-column" | "legend-block-row";
6
+ getWrapperClassByWrappingItems(
7
+ legendPosition: LegendPosition,
8
+ chartNotation: ChartNotation
9
+ ): "legend-wrapper-with-wrap" | "legend-wrapper-without-wrap";
10
+ getLegendLabelClassByPosition(
11
+ legendPosition: LegendPosition,
12
+ chartNotation: ChartNotation,
13
+ initialLabelClass: string
14
+ ): string;
15
+ getItemClasses(itemsDirection: LegendItemsDirection): string;
16
+ getLegendItemsDirection(legendPosition: LegendPosition): LegendItemsDirection;
17
+ private doesLegendInTopBy2d;
11
18
  }
@@ -1,27 +1,26 @@
1
1
  export class LegendHelperService {
2
- getWrapperClassByItemsDirection(itemsDirection) {
3
- return itemsDirection === "column" ? "legend-block-column" : "legend-block-row";
4
- }
5
- getWrapperClassByWrappingItems(legendPosition, chartNotation) {
6
- if (this.doesLegendInTopBy2d(legendPosition, chartNotation)) {
7
- return "legend-wrapper-without-wrap";
8
- }
9
- return "legend-wrapper-with-wrap";
10
- }
11
- getLegendLabelClassByPosition(legendPosition, chartNotation, initialLabelClass) {
12
- if (this.doesLegendInTopBy2d(legendPosition, chartNotation))
13
- return `${initialLabelClass} ${initialLabelClass + "-nowrap"}`;
14
- return initialLabelClass;
15
- }
16
- getItemClasses(itemsDirection) {
17
- return itemsDirection === "column" ? "legend-item-row" : "legend-item-inline";
18
- }
19
- getLegendItemsDirection(legendPosition) {
20
- if (legendPosition === "right" || legendPosition === "left")
21
- return "column";
22
- return "row";
23
- }
24
- doesLegendInTopBy2d(legendPosition, chartNotation) {
25
- return (legendPosition === "top" || legendPosition === "bottom") && chartNotation === "2d";
26
- }
2
+ getWrapperClassByItemsDirection(itemsDirection) {
3
+ return itemsDirection === "column" ? "legend-block-column" : "legend-block-row";
4
+ }
5
+ getWrapperClassByWrappingItems(legendPosition, chartNotation) {
6
+ if (this.doesLegendInTopBy2d(legendPosition, chartNotation)) {
7
+ return "legend-wrapper-without-wrap";
8
+ }
9
+ return "legend-wrapper-with-wrap";
10
+ }
11
+ getLegendLabelClassByPosition(legendPosition, chartNotation, initialLabelClass) {
12
+ if (this.doesLegendInTopBy2d(legendPosition, chartNotation))
13
+ return `${initialLabelClass} ${initialLabelClass + "-nowrap"}`;
14
+ return initialLabelClass;
15
+ }
16
+ getItemClasses(itemsDirection) {
17
+ return itemsDirection === "column" ? "legend-item-row" : "legend-item-inline";
18
+ }
19
+ getLegendItemsDirection(legendPosition) {
20
+ if (legendPosition === "right" || legendPosition === "left") return "column";
21
+ return "row";
22
+ }
23
+ doesLegendInTopBy2d(legendPosition, chartNotation) {
24
+ return (legendPosition === "top" || legendPosition === "bottom") && chartNotation === "2d";
25
+ }
27
26
  }
@@ -1,21 +1,30 @@
1
1
  import { BaseType, Selection } from "d3-selection";
2
2
  import { ChartLegendModel } from "../../../model/model";
3
3
  interface MarkerCreationOptions extends ChartLegendModel {
4
- color: string;
4
+ color: string;
5
5
  }
6
6
  declare type MarkerParentSelection = Selection<BaseType, any, BaseType, any>;
7
7
  export declare class LegendMarkerCreator {
8
- create(selection: MarkerParentSelection, options: MarkerCreationOptions): Selection<BaseType, ChartLegendModel, BaseType, unknown>;
9
- updateColorForItem(selection: MarkerParentSelection, options: MarkerCreationOptions): void;
8
+ create(
9
+ selection: MarkerParentSelection,
10
+ options: MarkerCreationOptions
11
+ ): Selection<BaseType, ChartLegendModel, BaseType, unknown>;
12
+ updateColorForItem(selection: MarkerParentSelection, options: MarkerCreationOptions): void;
10
13
  }
11
14
  export interface MarkerCreator {
12
- renderMarker(selection: MarkerParentSelection, color: string): Selection<BaseType, ChartLegendModel, BaseType, unknown>;
13
- updateColors(selection: MarkerParentSelection, color: string): void;
15
+ renderMarker(
16
+ selection: MarkerParentSelection,
17
+ color: string
18
+ ): Selection<BaseType, ChartLegendModel, BaseType, unknown>;
19
+ updateColors(selection: MarkerParentSelection, color: string): void;
14
20
  }
15
21
  interface MakerCreatorCustomOptions {
16
- default?: {
17
- cssClass: string;
18
- };
22
+ default?: {
23
+ cssClass: string;
24
+ };
19
25
  }
20
- export declare function getMarkerCreator(options: ChartLegendModel, customOptions?: MakerCreatorCustomOptions): MarkerCreator;
26
+ export declare function getMarkerCreator(
27
+ options: ChartLegendModel,
28
+ customOptions?: MakerCreatorCustomOptions
29
+ ): MarkerCreator;
21
30
  export {};
@@ -3,90 +3,93 @@ import { HatchPatternDef } from "../../block/defs/hatchPattern";
3
3
  import { applyLineDash } from "../../twoDimensionalNotation/line/lineHelper";
4
4
  import { getClipPathValue } from "../../../engine/twoDimensionalNotation/bar/barHelper";
5
5
  export class LegendMarkerCreator {
6
- create(selection, options) {
7
- const creator = getMarkerCreator(options);
8
- return creator.renderMarker(selection, options.color);
9
- }
10
- updateColorForItem(selection, options) {
11
- const creator = getMarkerCreator(options);
12
- creator.updateColors(selection, options.color);
13
- }
6
+ create(selection, options) {
7
+ const creator = getMarkerCreator(options);
8
+ return creator.renderMarker(selection, options.color);
9
+ }
10
+ updateColorForItem(selection, options) {
11
+ const creator = getMarkerCreator(options);
12
+ creator.updateColors(selection, options.color);
13
+ }
14
14
  }
15
15
  export function getMarkerCreator(options, customOptions) {
16
- var _a;
17
- if (options.markerShape === "bar")
18
- return new BarMarkerCreator(options.barViewOptions);
19
- if (options.markerShape === "line")
20
- return new LineMarkerCreator(options.lineViewOptions);
21
- return new DefaultMarkerCreator((_a = customOptions === null || customOptions === void 0 ? void 0 : customOptions.default) === null || _a === void 0 ? void 0 : _a.cssClass);
16
+ var _a;
17
+ if (options.markerShape === "bar") return new BarMarkerCreator(options.barViewOptions);
18
+ if (options.markerShape === "line") return new LineMarkerCreator(options.lineViewOptions);
19
+ return new DefaultMarkerCreator(
20
+ (_a = customOptions === null || customOptions === void 0 ? void 0 : customOptions.default) === null ||
21
+ _a === void 0
22
+ ? void 0
23
+ : _a.cssClass
24
+ );
22
25
  }
23
26
  class DefaultMarkerCreator {
24
- constructor(cssClass = Legend.markerCircle) {
25
- this.cssClass = cssClass;
26
- }
27
- renderMarker(selection, color) {
28
- return selection.append("span").style("background-color", color).classed(this.cssClass, true);
29
- }
30
- updateColors(selection, color) {
31
- selection.select(`.${this.cssClass}`).style("background-color", color);
32
- }
27
+ constructor(cssClass = Legend.markerCircle) {
28
+ this.cssClass = cssClass;
29
+ }
30
+ renderMarker(selection, color) {
31
+ return selection.append("span").style("background-color", color).classed(this.cssClass, true);
32
+ }
33
+ updateColors(selection, color) {
34
+ selection.select(`.${this.cssClass}`).style("background-color", color);
35
+ }
33
36
  }
34
37
  class SvgMarkerCreator {
35
- renderSvg(selection) {
36
- return selection
37
- .append("svg")
38
- .style("display", "inline-block")
39
- .style("height", "8px")
40
- .classed(Legend.markerClass, true);
41
- }
38
+ renderSvg(selection) {
39
+ return selection
40
+ .append("svg")
41
+ .style("display", "inline-block")
42
+ .style("height", "8px")
43
+ .classed(Legend.markerClass, true);
44
+ }
42
45
  }
43
46
  class BarMarkerCreator extends SvgMarkerCreator {
44
- constructor(options) {
45
- super();
46
- this.options = options;
47
- }
48
- renderMarker(selection, color) {
49
- const svg = this.renderSvg(selection).style("width", this.options.width);
50
- const bars = svg
51
- .append("rect")
52
- .attr("x", 0)
53
- .attr("y", 0)
54
- .attr("height", this.options.width)
55
- .attr("width", this.options.width)
56
- .style("fill", color)
57
- .style("clip-path", getClipPathValue(this.options.borderRadius));
58
- if (this.options.hatch.on) {
59
- bars.style("mask", HatchPatternDef.getMaskValue());
60
- }
61
- return bars;
62
- }
63
- updateColors(selection, color) {
64
- selection.select("svg rect").style("fill", color);
65
- }
47
+ constructor(options) {
48
+ super();
49
+ this.options = options;
50
+ }
51
+ renderMarker(selection, color) {
52
+ const svg = this.renderSvg(selection).style("width", this.options.width);
53
+ const bars = svg
54
+ .append("rect")
55
+ .attr("x", 0)
56
+ .attr("y", 0)
57
+ .attr("height", this.options.width)
58
+ .attr("width", this.options.width)
59
+ .style("fill", color)
60
+ .style("clip-path", getClipPathValue(this.options.borderRadius));
61
+ if (this.options.hatch.on) {
62
+ bars.style("mask", HatchPatternDef.getMaskValue());
63
+ }
64
+ return bars;
65
+ }
66
+ updateColors(selection, color) {
67
+ selection.select("svg rect").style("fill", color);
68
+ }
66
69
  }
67
70
  class LineMarkerCreator extends SvgMarkerCreator {
68
- constructor(options) {
69
- super();
70
- this.options = options;
71
- }
72
- renderMarker(selection, color) {
73
- const svg = this.renderSvg(selection).style("width", this.options.length);
74
- const line = svg
75
- .append("line")
76
- .style("stroke", "red")
77
- .classed("line", true)
78
- .attr("x1", 0)
79
- .attr("x2", this.options.length)
80
- .attr("y1", 5)
81
- .attr("y2", 5)
82
- .style("stroke", color)
83
- .style("stroke-width", this.options.strokeWidth);
84
- if (this.options.dashedStyles.on) {
85
- applyLineDash(line, this.options.dashedStyles.dashSize, this.options.dashedStyles.gapSize);
86
- }
87
- return line;
88
- }
89
- updateColors(selection, color) {
90
- selection.select("svg line").style("stroke", color);
91
- }
71
+ constructor(options) {
72
+ super();
73
+ this.options = options;
74
+ }
75
+ renderMarker(selection, color) {
76
+ const svg = this.renderSvg(selection).style("width", this.options.length);
77
+ const line = svg
78
+ .append("line")
79
+ .style("stroke", "red")
80
+ .classed("line", true)
81
+ .attr("x1", 0)
82
+ .attr("x2", this.options.length)
83
+ .attr("y1", 5)
84
+ .attr("y2", 5)
85
+ .style("stroke", color)
86
+ .style("stroke-width", this.options.strokeWidth);
87
+ if (this.options.dashedStyles.on) {
88
+ applyLineDash(line, this.options.dashedStyles.dashSize, this.options.dashedStyles.gapSize);
89
+ }
90
+ return line;
91
+ }
92
+ updateColors(selection, color) {
93
+ selection.select("svg line").style("stroke", color);
94
+ }
92
95
  }
@@ -1,16 +1,16 @@
1
1
  declare type SizePx = number;
2
2
  interface WidthCalculatorConfig {
3
- wrapper: LegendWrapperConfig;
4
- items: LegendItemConfig[];
3
+ wrapper: LegendWrapperConfig;
4
+ items: LegendItemConfig[];
5
5
  }
6
6
  export declare function getNewLegendItemWidths(config: WidthCalculatorConfig): SizePx[];
7
7
  interface LegendWrapperConfig {
8
- maxRowsAmount: number;
9
- width: SizePx;
8
+ maxRowsAmount: number;
9
+ width: SizePx;
10
10
  }
11
11
  export interface LegendItemConfig {
12
- marginLeft: SizePx;
13
- marginRight: SizePx;
14
- width: SizePx;
12
+ marginLeft: SizePx;
13
+ marginRight: SizePx;
14
+ width: SizePx;
15
15
  }
16
16
  export {};