mdt-charts 1.28.1 → 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
@@ -6,137 +6,167 @@ import { Helper } from "../../helpers/helper";
6
6
  import { Pipeline } from "../../helpers/pipeline/Pipeline";
7
7
  import { LineBuilder } from "../../../engine/twoDimensionalNotation/line/lineBuilder";
8
8
  export class Line {
9
- constructor(options) {
10
- this.options = options;
11
- this.creatingPipeline = new Pipeline();
12
- this.lineChartClass = Line.lineChartClass; //TODO: remove after refactor
13
- onLineChartInit(this.creatingPipeline);
14
- }
15
- static get(options) {
16
- return new Line(options);
17
- }
18
- render(block, scales, data, keyField, margin, keyAxisOrient, chart) {
19
- if (chart.isSegmented)
20
- this.renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart);
21
- else
22
- this.renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart);
23
- }
24
- update(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
25
- let promises;
26
- if (chart.isSegmented) {
27
- promises = this.updateSegmented(block, scales, newData, keyField, margin, keyAxisOrient, chart);
28
- }
29
- else {
30
- promises = this.updateGrouped(block, scales, newData, keyField, margin, keyAxisOrient, chart);
31
- }
32
- return promises;
33
- }
34
- updateColors(block, chart) {
35
- chart.data.valueFields.forEach((_vf, valueIndex) => {
36
- const path = block.svg
37
- .getChartGroup(chart.index)
38
- .select(`.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueIndex}`);
39
- DomHelper.setChartStyle(path, chart.style, valueIndex, "stroke");
40
- MarkDot.updateColors(block, chart, valueIndex);
41
- });
42
- }
43
- renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart) {
44
- const generatorFactory = new LineGeneratorFactory({
45
- keyAxisOrient,
46
- scales,
47
- keyFieldName: keyField.name,
48
- margin,
49
- curve: this.options.staticSettings.shape.curve.type,
50
- shouldRender: chart.lineLikeViewOptions.renderForKey
51
- });
52
- chart.data.valueFields.forEach((valueField, valueIndex) => {
53
- const lineGenerator = generatorFactory.getLineGenerator(valueField.name);
54
- let path = block.svg
55
- .getChartGroup(chart.index)
56
- .append("path")
57
- .attr("d", lineGenerator(data))
58
- .attr("class", this.lineChartClass)
59
- .style("fill", "none")
60
- .style("clip-path", `url(#${block.svg.getClipPathId()})`)
61
- .style("pointer-events", "none");
62
- path = this.creatingPipeline.execute(path, chart);
63
- DomHelper.setCssClasses(path, Helper.getCssClassesWithElementIndex(chart.cssClasses, valueIndex));
64
- DomHelper.setChartStyle(path, chart.style, valueIndex, "stroke");
65
- MarkDot.render(block, data, keyAxisOrient, scales, margin, keyField.name, valueIndex, valueField.name, chart);
66
- });
67
- }
68
- renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart) {
69
- let stackedData = getStackedData(data, chart);
70
- const generatorFactory = this.createLineGeneratorFactory(chart, scales, margin, keyAxisOrient, keyField);
71
- const lineGenerator = generatorFactory.getSegmentedLineGenerator();
72
- const lineBuilder = new LineBuilder({
73
- elementAccessors: { getBlock: () => block }
74
- }, chart, lineGenerator);
75
- let lines = lineBuilder.renderSegmented(stackedData, Line.lineChartClass);
76
- lines = this.creatingPipeline.execute(lines, chart);
77
- lineBuilder.setSegmentColor(lines, chart.style.elementColors);
78
- lines.each(function (_, i) {
79
- DomHelper.setCssClasses(select(this), Helper.getCssClassesWithElementIndex(chart.cssClasses, i));
80
- });
81
- stackedData.forEach((dataset, stackIndex) => {
82
- MarkDot.render(block, dataset, keyAxisOrient, scales, margin, keyField.name, stackIndex, "1", chart);
83
- });
84
- }
85
- updateGrouped(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
86
- const promises = [];
87
- const generatorFactory = this.createLineGeneratorFactory(chart, scales, margin, keyAxisOrient, keyField);
88
- chart.data.valueFields.forEach((valueField, valueFieldIndex) => {
89
- const lineGenerator = generatorFactory.getLineGenerator(valueField.name);
90
- const lineObject = block.svg
91
- .getChartGroup(chart.index)
92
- .select(`.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueFieldIndex}`);
93
- const prom = Line.updateGroupedPath(block, lineObject, lineGenerator, newData);
94
- promises.push(prom);
95
- MarkDot.update(block, newData, keyAxisOrient, scales, margin, keyField.name, valueFieldIndex, valueField.name, chart);
96
- });
97
- return promises;
98
- }
99
- updateSegmented(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
100
- let stackedData = getStackedData(newData, chart);
101
- const generatorFactory = this.createLineGeneratorFactory(chart, scales, margin, keyAxisOrient, keyField);
102
- const lineGenerator = generatorFactory.getSegmentedLineGenerator();
103
- const lineBuilder = new LineBuilder({
104
- elementAccessors: { getBlock: () => block }
105
- }, chart, lineGenerator);
106
- let lines = lineBuilder.getAllLinesWithNewData(stackedData, Line.lineChartClass);
107
- const prom = lineBuilder.updateSegmentedPath(lines);
108
- lines.each((dataset, index) => {
109
- MarkDot.update(block, dataset, keyAxisOrient, scales, margin, keyField.name, index, "1", chart);
110
- });
111
- return [prom];
112
- }
113
- static updateGroupedPath(block, lineObject, lineGenerator, newData) {
114
- return new Promise((resolve) => {
115
- if (lineObject.size() === 0) {
116
- resolve("");
117
- return;
118
- }
119
- let lineHandler = lineObject;
120
- if (block.transitionManager.durations.chartUpdate > 0)
121
- lineHandler = lineHandler
122
- .interrupt()
123
- .transition()
124
- .duration(block.transitionManager.durations.chartUpdate)
125
- .on("end", () => resolve(""));
126
- lineHandler.attr("d", lineGenerator(newData));
127
- if (block.transitionManager.durations.chartUpdate <= 0)
128
- resolve("");
129
- });
130
- }
131
- createLineGeneratorFactory(chart, scales, margin, keyAxisOrient, keyField) {
132
- return new LineGeneratorFactory({
133
- keyAxisOrient,
134
- scales,
135
- keyFieldName: keyField.name,
136
- margin,
137
- shouldRender: chart.lineLikeViewOptions.renderForKey,
138
- curve: this.options.staticSettings.shape.curve.type
139
- });
140
- }
9
+ constructor(options) {
10
+ this.options = options;
11
+ this.creatingPipeline = new Pipeline();
12
+ this.lineChartClass = Line.lineChartClass; //TODO: remove after refactor
13
+ onLineChartInit(this.creatingPipeline);
14
+ }
15
+ static get(options) {
16
+ return new Line(options);
17
+ }
18
+ render(block, scales, data, keyField, margin, keyAxisOrient, chart) {
19
+ if (chart.isSegmented) this.renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart);
20
+ else this.renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart);
21
+ }
22
+ update(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
23
+ let promises;
24
+ if (chart.isSegmented) {
25
+ promises = this.updateSegmented(block, scales, newData, keyField, margin, keyAxisOrient, chart);
26
+ } else {
27
+ promises = this.updateGrouped(block, scales, newData, keyField, margin, keyAxisOrient, chart);
28
+ }
29
+ return promises;
30
+ }
31
+ updateColors(block, chart) {
32
+ chart.data.valueFields.forEach((_vf, valueIndex) => {
33
+ const path = block.svg
34
+ .getChartGroup(chart.index)
35
+ .select(
36
+ `.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueIndex}`
37
+ );
38
+ DomHelper.setChartStyle(path, chart.style, valueIndex, "stroke");
39
+ MarkDot.updateColors(block, chart, valueIndex);
40
+ });
41
+ }
42
+ renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart) {
43
+ const generatorFactory = new LineGeneratorFactory({
44
+ keyAxisOrient,
45
+ scales,
46
+ keyFieldName: keyField.name,
47
+ margin,
48
+ curve: this.options.staticSettings.shape.curve.type,
49
+ shouldRender: chart.lineLikeViewOptions.renderForKey
50
+ });
51
+ chart.data.valueFields.forEach((valueField, valueIndex) => {
52
+ const lineGenerator = generatorFactory.getLineGenerator(valueField.name);
53
+ let path = block.svg
54
+ .getChartGroup(chart.index)
55
+ .append("path")
56
+ .attr("d", lineGenerator(data))
57
+ .attr("class", this.lineChartClass)
58
+ .style("fill", "none")
59
+ .style("clip-path", `url(#${block.svg.getClipPathId()})`)
60
+ .style("pointer-events", "none");
61
+ path = this.creatingPipeline.execute(path, chart);
62
+ DomHelper.setCssClasses(path, Helper.getCssClassesWithElementIndex(chart.cssClasses, valueIndex));
63
+ DomHelper.setChartStyle(path, chart.style, valueIndex, "stroke");
64
+ MarkDot.render(
65
+ block,
66
+ data,
67
+ keyAxisOrient,
68
+ scales,
69
+ margin,
70
+ keyField.name,
71
+ valueIndex,
72
+ valueField.name,
73
+ chart
74
+ );
75
+ });
76
+ }
77
+ renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart) {
78
+ let stackedData = getStackedData(data, chart);
79
+ const generatorFactory = this.createLineGeneratorFactory(chart, scales, margin, keyAxisOrient, keyField);
80
+ const lineGenerator = generatorFactory.getSegmentedLineGenerator();
81
+ const lineBuilder = new LineBuilder(
82
+ {
83
+ elementAccessors: { getBlock: () => block }
84
+ },
85
+ chart,
86
+ lineGenerator
87
+ );
88
+ let lines = lineBuilder.renderSegmented(stackedData, Line.lineChartClass);
89
+ lines = this.creatingPipeline.execute(lines, chart);
90
+ lineBuilder.setSegmentColor(lines, chart.style.elementColors);
91
+ lines.each(function (_, i) {
92
+ DomHelper.setCssClasses(select(this), Helper.getCssClassesWithElementIndex(chart.cssClasses, i));
93
+ });
94
+ stackedData.forEach((dataset, stackIndex) => {
95
+ MarkDot.render(block, dataset, keyAxisOrient, scales, margin, keyField.name, stackIndex, "1", chart);
96
+ });
97
+ }
98
+ updateGrouped(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
99
+ const promises = [];
100
+ const generatorFactory = this.createLineGeneratorFactory(chart, scales, margin, keyAxisOrient, keyField);
101
+ chart.data.valueFields.forEach((valueField, valueFieldIndex) => {
102
+ const lineGenerator = generatorFactory.getLineGenerator(valueField.name);
103
+ const lineObject = block.svg
104
+ .getChartGroup(chart.index)
105
+ .select(
106
+ `.${this.lineChartClass}${Helper.getCssClassesLine(
107
+ chart.cssClasses
108
+ )}.chart-element-${valueFieldIndex}`
109
+ );
110
+ const prom = Line.updateGroupedPath(block, lineObject, lineGenerator, newData);
111
+ promises.push(prom);
112
+ MarkDot.update(
113
+ block,
114
+ newData,
115
+ keyAxisOrient,
116
+ scales,
117
+ margin,
118
+ keyField.name,
119
+ valueFieldIndex,
120
+ valueField.name,
121
+ chart
122
+ );
123
+ });
124
+ return promises;
125
+ }
126
+ updateSegmented(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
127
+ let stackedData = getStackedData(newData, chart);
128
+ const generatorFactory = this.createLineGeneratorFactory(chart, scales, margin, keyAxisOrient, keyField);
129
+ const lineGenerator = generatorFactory.getSegmentedLineGenerator();
130
+ const lineBuilder = new LineBuilder(
131
+ {
132
+ elementAccessors: { getBlock: () => block }
133
+ },
134
+ chart,
135
+ lineGenerator
136
+ );
137
+ let lines = lineBuilder.getAllLinesWithNewData(stackedData, Line.lineChartClass);
138
+ const prom = lineBuilder.updateSegmentedPath(lines);
139
+ lines.each((dataset, index) => {
140
+ MarkDot.update(block, dataset, keyAxisOrient, scales, margin, keyField.name, index, "1", chart);
141
+ });
142
+ return [prom];
143
+ }
144
+ static updateGroupedPath(block, lineObject, lineGenerator, newData) {
145
+ return new Promise((resolve) => {
146
+ if (lineObject.size() === 0) {
147
+ resolve("");
148
+ return;
149
+ }
150
+ let lineHandler = lineObject;
151
+ if (block.transitionManager.durations.chartUpdate > 0)
152
+ lineHandler = lineHandler
153
+ .interrupt()
154
+ .transition()
155
+ .duration(block.transitionManager.durations.chartUpdate)
156
+ .on("end", () => resolve(""));
157
+ lineHandler.attr("d", lineGenerator(newData));
158
+ if (block.transitionManager.durations.chartUpdate <= 0) resolve("");
159
+ });
160
+ }
161
+ createLineGeneratorFactory(chart, scales, margin, keyAxisOrient, keyField) {
162
+ return new LineGeneratorFactory({
163
+ keyAxisOrient,
164
+ scales,
165
+ keyFieldName: keyField.name,
166
+ margin,
167
+ shouldRender: chart.lineLikeViewOptions.renderForKey,
168
+ curve: this.options.staticSettings.shape.curve.type
169
+ });
170
+ }
141
171
  }
142
172
  Line.lineChartClass = "line";
@@ -5,18 +5,21 @@ import { BaseType, Selection } from "d3-selection";
5
5
  import { Segment } from "../../../engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware";
6
6
  import { Line as ILine } from "d3-shape";
7
7
  interface LineBuilderOptions {
8
- elementAccessors: {
9
- getBlock: () => Block;
10
- };
8
+ elementAccessors: {
9
+ getBlock: () => Block;
10
+ };
11
11
  }
12
12
  export declare class LineBuilder {
13
- private readonly options;
14
- private readonly chart;
15
- private readonly lineGenerator;
16
- constructor(options: LineBuilderOptions, chart: TwoDimensionalChartModel, lineGenerator: ILine<MdtChartsDataRow>);
17
- renderSegmented(stakedData: Segment[][], lineClass: string): Selection<SVGPathElement, Segment[], SVGGElement, any>;
18
- setSegmentColor(segments: Selection<SVGGElement, unknown, SVGGElement, unknown>, colorPalette: string[]): void;
19
- updateSegmentedPath(linesObjects: Selection<BaseType, any, BaseType, any>): Promise<any>;
20
- getAllLinesWithNewData(stakedData: Segment[][], lineClass: string): Selection<SVGPathElement, Segment[], SVGGElement, any>;
13
+ private readonly options;
14
+ private readonly chart;
15
+ private readonly lineGenerator;
16
+ constructor(options: LineBuilderOptions, chart: TwoDimensionalChartModel, lineGenerator: ILine<MdtChartsDataRow>);
17
+ renderSegmented(stakedData: Segment[][], lineClass: string): Selection<SVGPathElement, Segment[], SVGGElement, any>;
18
+ setSegmentColor(segments: Selection<SVGGElement, unknown, SVGGElement, unknown>, colorPalette: string[]): void;
19
+ updateSegmentedPath(linesObjects: Selection<BaseType, any, BaseType, any>): Promise<any>;
20
+ getAllLinesWithNewData(
21
+ stakedData: Segment[][],
22
+ lineClass: string
23
+ ): Selection<SVGPathElement, Segment[], SVGGElement, any>;
21
24
  }
22
25
  export {};
@@ -1,51 +1,50 @@
1
1
  import { Helper } from "../../../engine/helpers/helper";
2
2
  export class LineBuilder {
3
- constructor(options, chart, lineGenerator) {
4
- this.options = options;
5
- this.chart = chart;
6
- this.lineGenerator = lineGenerator;
7
- }
8
- renderSegmented(stakedData, lineClass) {
9
- const block = this.options.elementAccessors.getBlock();
10
- return block.svg
11
- .getChartGroup(this.chart.index)
12
- .selectAll(`.${lineClass}${Helper.getCssClassesLine(this.chart.cssClasses)}`)
13
- .data(stakedData)
14
- .enter()
15
- .append("path")
16
- .attr("d", (d) => this.lineGenerator(d))
17
- .attr("class", lineClass)
18
- .style("fill", "none")
19
- .style("clip-path", `url(#${block.svg.getClipPathId()})`)
20
- .style("pointer-events", "none");
21
- }
22
- setSegmentColor(segments, colorPalette) {
23
- segments.style("stroke", (d, i) => colorPalette[i % colorPalette.length]);
24
- }
25
- updateSegmentedPath(linesObjects) {
26
- const block = this.options.elementAccessors.getBlock();
27
- return new Promise((resolve) => {
28
- if (linesObjects.size() === 0) {
29
- resolve("");
30
- return;
31
- }
32
- let linesHandler = linesObjects;
33
- if (block.transitionManager.durations.chartUpdate > 0)
34
- linesHandler = linesHandler
35
- .interrupt()
36
- .transition()
37
- .duration(block.transitionManager.durations.chartUpdate)
38
- .on("end", () => resolve(""));
39
- linesHandler.attr("d", (d) => this.lineGenerator(d));
40
- if (block.transitionManager.durations.chartUpdate <= 0)
41
- resolve("");
42
- });
43
- }
44
- getAllLinesWithNewData(stakedData, lineClass) {
45
- const block = this.options.elementAccessors.getBlock();
46
- return block.svg
47
- .getChartGroup(this.chart.index)
48
- .selectAll(`path.${lineClass}${Helper.getCssClassesLine(this.chart.cssClasses)}`)
49
- .data(stakedData);
50
- }
3
+ constructor(options, chart, lineGenerator) {
4
+ this.options = options;
5
+ this.chart = chart;
6
+ this.lineGenerator = lineGenerator;
7
+ }
8
+ renderSegmented(stakedData, lineClass) {
9
+ const block = this.options.elementAccessors.getBlock();
10
+ return block.svg
11
+ .getChartGroup(this.chart.index)
12
+ .selectAll(`.${lineClass}${Helper.getCssClassesLine(this.chart.cssClasses)}`)
13
+ .data(stakedData)
14
+ .enter()
15
+ .append("path")
16
+ .attr("d", (d) => this.lineGenerator(d))
17
+ .attr("class", lineClass)
18
+ .style("fill", "none")
19
+ .style("clip-path", `url(#${block.svg.getClipPathId()})`)
20
+ .style("pointer-events", "none");
21
+ }
22
+ setSegmentColor(segments, colorPalette) {
23
+ segments.style("stroke", (d, i) => colorPalette[i % colorPalette.length]);
24
+ }
25
+ updateSegmentedPath(linesObjects) {
26
+ const block = this.options.elementAccessors.getBlock();
27
+ return new Promise((resolve) => {
28
+ if (linesObjects.size() === 0) {
29
+ resolve("");
30
+ return;
31
+ }
32
+ let linesHandler = linesObjects;
33
+ if (block.transitionManager.durations.chartUpdate > 0)
34
+ linesHandler = linesHandler
35
+ .interrupt()
36
+ .transition()
37
+ .duration(block.transitionManager.durations.chartUpdate)
38
+ .on("end", () => resolve(""));
39
+ linesHandler.attr("d", (d) => this.lineGenerator(d));
40
+ if (block.transitionManager.durations.chartUpdate <= 0) resolve("");
41
+ });
42
+ }
43
+ getAllLinesWithNewData(stakedData, lineClass) {
44
+ const block = this.options.elementAccessors.getBlock();
45
+ return block.svg
46
+ .getChartGroup(this.chart.index)
47
+ .selectAll(`path.${lineClass}${Helper.getCssClassesLine(this.chart.cssClasses)}`)
48
+ .data(stakedData);
49
+ }
51
50
  }
@@ -2,11 +2,11 @@ import { MdtChartsDataRow } from "../../../config/config";
2
2
  import { LineLikeGeneratorMiddleware } from "../lineLike/generatorMiddleware/lineLikeGeneratorMiddleware";
3
3
  import { CoordinateGetter } from "../lineLike/generatorFactory/lineLikeGeneratorFactory";
4
4
  interface LineGeneratorOptions {
5
- middlewares: LineLikeGeneratorMiddleware[];
5
+ middlewares: LineLikeGeneratorMiddleware[];
6
6
  }
7
7
  export declare class LineGenerator {
8
- private options;
9
- constructor(options: LineGeneratorOptions);
10
- get(xValue: CoordinateGetter, yValue: CoordinateGetter): import("d3-shape").Line<MdtChartsDataRow>;
8
+ private options;
9
+ constructor(options: LineGeneratorOptions);
10
+ get(xValue: CoordinateGetter, yValue: CoordinateGetter): import("d3-shape").Line<MdtChartsDataRow>;
11
11
  }
12
12
  export {};
@@ -1,11 +1,11 @@
1
1
  import { line } from "d3-shape";
2
2
  export class LineGenerator {
3
- constructor(options) {
4
- this.options = options;
5
- }
6
- get(xValue, yValue) {
7
- const generator = line().x(xValue).y(yValue);
8
- this.options.middlewares.forEach((middleware) => middleware.handle(generator));
9
- return generator;
10
- }
3
+ constructor(options) {
4
+ this.options = options;
5
+ }
6
+ get(xValue, yValue) {
7
+ const generator = line().x(xValue).y(yValue);
8
+ this.options.middlewares.forEach((middleware) => middleware.handle(generator));
9
+ return generator;
10
+ }
11
11
  }
@@ -6,11 +6,17 @@ import { BaseType, Selection } from "d3-selection";
6
6
  import { Segment } from "../lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware";
7
7
  import { LineLikeGeneratorFactoryOptions } from "../lineLike/generatorFactory/lineLikeGeneratorFactory";
8
8
  export declare class LineGeneratorFactory {
9
- private options;
10
- constructor(options: LineLikeGeneratorFactoryOptions);
11
- getLineGenerator(valueFieldName: string): ILine<MdtChartsDataRow>;
12
- getSegmentedLineGenerator(): ILine<MdtChartsDataRow>;
9
+ private options;
10
+ constructor(options: LineLikeGeneratorFactoryOptions);
11
+ getLineGenerator(valueFieldName: string): ILine<MdtChartsDataRow>;
12
+ getSegmentedLineGenerator(): ILine<MdtChartsDataRow>;
13
13
  }
14
- export declare function onLineChartInit(creatingPipeline: Pipeline<Selection<SVGElement, any, BaseType, any>, TwoDimensionalChartModel>): void;
15
- export declare function applyLineDash(lineSelection: Selection<SVGElement, any, BaseType, any>, dashSize: number, gapSize: number): Selection<SVGElement, any, BaseType, any>;
14
+ export declare function onLineChartInit(
15
+ creatingPipeline: Pipeline<Selection<SVGElement, any, BaseType, any>, TwoDimensionalChartModel>
16
+ ): void;
17
+ export declare function applyLineDash(
18
+ lineSelection: Selection<SVGElement, any, BaseType, any>,
19
+ dashSize: number,
20
+ gapSize: number
21
+ ): Selection<SVGElement, any, BaseType, any>;
16
22
  export declare function getStackedData(data: MdtChartsDataRow[], chart: TwoDimensionalChartModel): Segment[][];