mdt-charts 1.27.1 → 1.27.2

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 (144) hide show
  1. package/.prettierrc +6 -0
  2. package/lib/config/config.d.ts +13 -13
  3. package/lib/designer/designerConfig.d.ts +1 -1
  4. package/lib/engine/block/block.js +14 -14
  5. package/lib/engine/block/blockHelper.js +2 -2
  6. package/lib/engine/block/blockSvg.js +25 -28
  7. package/lib/engine/block/defs/LinearGradientDef.js +9 -8
  8. package/lib/engine/contentManager/contentManagerFactory.js +1 -1
  9. package/lib/engine/elementHighlighter/elementHighlighter.d.ts +3 -3
  10. package/lib/engine/elementHighlighter/elementHighlighter.js +52 -54
  11. package/lib/engine/elementHighlighter/selectHighlighter.js +7 -7
  12. package/lib/engine/engine.d.ts +4 -4
  13. package/lib/engine/engine.js +5 -5
  14. package/lib/engine/features/aggregator/aggregator.d.ts +1 -1
  15. package/lib/engine/features/aggregator/aggregator.js +43 -45
  16. package/lib/engine/features/axis/axis.d.ts +1 -1
  17. package/lib/engine/features/axis/axis.js +53 -48
  18. package/lib/engine/features/axis/axisDomHelper.d.ts +3 -3
  19. package/lib/engine/features/axis/axisDomHelper.js +6 -8
  20. package/lib/engine/features/axis/axisHelper.d.ts +2 -2
  21. package/lib/engine/features/axis/axisHelper.js +14 -21
  22. package/lib/engine/features/axis/axisLabelDomHelper.d.ts +3 -3
  23. package/lib/engine/features/axis/axisLabelDomHelper.js +74 -66
  24. package/lib/engine/features/axis/axisLabelsEventManager.js +11 -11
  25. package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +3 -3
  26. package/lib/engine/features/embeddedLabels/embeddedLabels.js +44 -44
  27. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +1 -1
  28. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +3 -6
  29. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +2 -2
  30. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +22 -20
  31. package/lib/engine/features/gridLine/gidLineHelper.d.ts +1 -1
  32. package/lib/engine/features/gridLine/gidLineHelper.js +5 -5
  33. package/lib/engine/features/gridLine/gridLine.js +14 -23
  34. package/lib/engine/features/legend/legend.js +27 -36
  35. package/lib/engine/features/legend/legendDomHelper.js +18 -9
  36. package/lib/engine/features/legend/legendEventsManager.js +18 -13
  37. package/lib/engine/features/legend/legendHelper.js +19 -19
  38. package/lib/engine/features/legend/legendHelperService.js +5 -5
  39. package/lib/engine/features/legend/legendMarkerCreator.js +23 -22
  40. package/lib/engine/features/legend/legendWidthCalculator.js +5 -7
  41. package/lib/engine/features/markDots/markDot.d.ts +2 -2
  42. package/lib/engine/features/markDots/markDot.js +35 -34
  43. package/lib/engine/features/markDots/markDotsHelper.js +6 -6
  44. package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +11 -11
  45. package/lib/engine/features/scale/scale.d.ts +4 -5
  46. package/lib/engine/features/scale/scale.js +16 -25
  47. package/lib/engine/features/tipBox/tipBox.d.ts +2 -2
  48. package/lib/engine/features/tipBox/tipBox.js +13 -17
  49. package/lib/engine/features/tipBox/tipBoxHelper.js +5 -5
  50. package/lib/engine/features/title/title.d.ts +1 -1
  51. package/lib/engine/features/title/title.js +8 -11
  52. package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +1 -1
  53. package/lib/engine/features/tolltip/newTooltip/newTooltip.js +6 -8
  54. package/lib/engine/features/tolltip/tooltip.d.ts +2 -2
  55. package/lib/engine/features/tolltip/tooltip.js +47 -42
  56. package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +2 -2
  57. package/lib/engine/features/tolltip/tooltipComponentsManager.js +49 -52
  58. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +1 -1
  59. package/lib/engine/features/tolltip/tooltipDomHelper.js +41 -33
  60. package/lib/engine/features/tolltip/tooltipHelper.js +15 -11
  61. package/lib/engine/features/valueLabels/valueLabels.js +24 -37
  62. package/lib/engine/features/valueLabels/valueLabelsHelper.js +6 -6
  63. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +9 -10
  64. package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.js +4 -4
  65. package/lib/engine/filterManager/filterEventManager.js +18 -15
  66. package/lib/engine/helpers/domHelper.d.ts +3 -4
  67. package/lib/engine/helpers/domHelper.js +9 -13
  68. package/lib/engine/helpers/fontResizer/fontResizer.js +2 -2
  69. package/lib/engine/helpers/helper.js +14 -9
  70. package/lib/engine/helpers/namesHelper.js +2 -2
  71. package/lib/engine/polarNotation/donut/DonutHelper.js +6 -8
  72. package/lib/engine/polarNotation/donut/donut.d.ts +3 -3
  73. package/lib/engine/polarNotation/donut/donut.js +47 -58
  74. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +11 -11
  75. package/lib/engine/polarNotation/polarManager.js +3 -5
  76. package/lib/engine/transitionManager.js +4 -7
  77. package/lib/engine/twoDimensionalNotation/area/area.d.ts +1 -1
  78. package/lib/engine/twoDimensionalNotation/area/area.js +77 -62
  79. package/lib/engine/twoDimensionalNotation/area/areaGenerator.js +4 -10
  80. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +3 -3
  81. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +21 -13
  82. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +2 -2
  83. package/lib/engine/twoDimensionalNotation/bar/bar.js +70 -67
  84. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +40 -35
  85. package/lib/engine/twoDimensionalNotation/dot/dotChart.js +60 -42
  86. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +7 -7
  87. package/lib/engine/twoDimensionalNotation/line/line.d.ts +4 -4
  88. package/lib/engine/twoDimensionalNotation/line/line.js +45 -28
  89. package/lib/engine/twoDimensionalNotation/line/lineBuilder.js +18 -16
  90. package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +2 -4
  91. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +6 -6
  92. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +26 -17
  93. package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.js +1 -1
  94. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +25 -21
  95. package/lib/engine/valueFormatter.d.ts +1 -1
  96. package/lib/main.d.ts +1 -0
  97. package/lib/main.js +8 -7
  98. package/lib/model/chartStyleModel/chartStyleModel.js +5 -3
  99. package/lib/model/chartStyleModel/colorRange.js +1 -3
  100. package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.js +9 -7
  101. package/lib/model/dataManagerModel/dataManagerModel.js +28 -16
  102. package/lib/model/featuresModel/axisModel.d.ts +6 -3
  103. package/lib/model/featuresModel/axisModel.js +59 -32
  104. package/lib/model/featuresModel/axisModelService.js +2 -2
  105. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +1 -1
  106. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +12 -12
  107. package/lib/model/featuresModel/legendModel/legendModel.js +2 -2
  108. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
  109. package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +4 -5
  110. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +4 -5
  111. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +3 -5
  112. package/lib/model/featuresModel/scaleModel/scaleDomainService.js +10 -12
  113. package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +8 -4
  114. package/lib/model/featuresModel/scaleModel/scaleModel.js +20 -12
  115. package/lib/model/featuresModel/scaleModel/scaleModelServices.js +5 -5
  116. package/lib/model/featuresModel/tooltipModel.js +1 -1
  117. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +5 -5
  118. package/lib/model/helpers/modelHelper.js +6 -4
  119. package/lib/model/helpers/twoDimensionalModelHelper.d.ts +1 -1
  120. package/lib/model/helpers/twoDimensionalModelHelper.js +23 -23
  121. package/lib/model/helpers/unitsReader.js +1 -1
  122. package/lib/model/margin/marginModel.js +1 -1
  123. package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -0
  124. package/lib/model/margin/twoDim/twoDimMarginModel.js +38 -28
  125. package/lib/model/model.d.ts +17 -4
  126. package/lib/model/modelBuilder.d.ts +4 -4
  127. package/lib/model/modelBuilder.js +19 -18
  128. package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +1 -1
  129. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.d.ts +5 -0
  130. package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.js +8 -0
  131. package/lib/model/modelInstance/configReader.js +11 -10
  132. package/lib/model/modelInstance/dataModel/dataRepository.js +5 -5
  133. package/lib/model/modelInstance/modelInstance.d.ts +4 -2
  134. package/lib/model/modelInstance/modelInstance.js +5 -3
  135. package/lib/model/modelInstance/titleConfigReader.js +5 -5
  136. package/lib/model/notations/polar/donut/donutModel.js +1 -1
  137. package/lib/model/notations/polar/polarModel.js +6 -6
  138. package/lib/model/notations/twoDimensional/styles.d.ts +2 -2
  139. package/lib/model/notations/twoDimensional/styles.js +8 -8
  140. package/lib/model/notations/twoDimensionalModel.d.ts +0 -1
  141. package/lib/model/notations/twoDimensionalModel.js +32 -29
  142. package/package.json +59 -59
  143. package/tsconfig.production.json +14 -24
  144. package/README.md +0 -2
@@ -2,11 +2,10 @@ import { GridLineHelper } from "./gidLineHelper";
2
2
  export class GridLine {
3
3
  static render(block, options, axes, blockSize, margin, scales) {
4
4
  if (options.flag.value) {
5
- const lineLength = GridLineHelper.getGridLineLength('value', axes.key, axes.value, blockSize, margin);
5
+ const lineLength = GridLineHelper.getGridLineLength("value", axes.key, axes.value, blockSize, margin);
6
6
  const lineAttributes = GridLineHelper.getLineAttributes(axes.value, lineLength);
7
- this.renderLine(block, axes.value, lineAttributes, options)
8
- .style('display', (d, i, group) => {
9
- return d === 0 ? 'none' : 'block';
7
+ this.renderLine(block, axes.value, lineAttributes, options).style("display", (d, i, group) => {
8
+ return d === 0 ? "none" : "block";
10
9
  });
11
10
  }
12
11
  if (options.flag.key) {
@@ -22,28 +21,20 @@ export class GridLine {
22
21
  const gridLine = block
23
22
  .getSvg()
24
23
  .selectAll(`.${axis.cssClass}`)
25
- .selectAll('g.tick')
26
- .append('line')
27
- .attr('class', this.gridLineClass)
28
- .attr('x1', lineAttributes.x1)
29
- .attr('y1', lineAttributes.y1)
30
- .attr('x2', lineAttributes.x2)
31
- .attr('y2', lineAttributes.y2);
24
+ .selectAll("g.tick")
25
+ .append("line")
26
+ .attr("class", this.gridLineClass)
27
+ .attr("x1", lineAttributes.x1)
28
+ .attr("y1", lineAttributes.y1)
29
+ .attr("x2", lineAttributes.x2)
30
+ .attr("y2", lineAttributes.y2);
32
31
  if (options.styles.dash.on)
33
- gridLine.style('stroke-dasharray', 3);
32
+ gridLine.style("stroke-dasharray", 3);
34
33
  return gridLine;
35
34
  }
36
35
  static clear(block, keyAxisClass, valueAxisClass) {
37
- block.getSvg()
38
- .selectAll(`.${keyAxisClass} `)
39
- .selectAll('g.tick')
40
- .selectAll(`.${this.gridLineClass}`)
41
- .remove();
42
- block.getSvg()
43
- .selectAll(`.${valueAxisClass}`)
44
- .selectAll('g.tick')
45
- .selectAll(`.${this.gridLineClass}`)
46
- .remove();
36
+ block.getSvg().selectAll(`.${keyAxisClass} `).selectAll("g.tick").selectAll(`.${this.gridLineClass}`).remove();
37
+ block.getSvg().selectAll(`.${valueAxisClass}`).selectAll("g.tick").selectAll(`.${this.gridLineClass}`).remove();
47
38
  }
48
39
  }
49
- GridLine.gridLineClass = 'grid-line';
40
+ GridLine.gridLineClass = "grid-line";
@@ -13,13 +13,13 @@ export class Legend {
13
13
  return new Legend();
14
14
  }
15
15
  render(block, data, options, model) {
16
- if (options.legend.position !== 'off') {
16
+ if (options.legend.position !== "off") {
17
17
  const legendObject = this.renderObject(block, options.legend.position, model.otherComponents.legendBlock, model.blockCanvas.size);
18
18
  this.setContent(block, data, options, legendObject, model.otherComponents.legendBlock);
19
19
  }
20
20
  }
21
21
  update(block, data, model) {
22
- if (model.options.legend.position !== 'off') {
22
+ if (model.options.legend.position !== "off") {
23
23
  const legendObject = this.getObject(block);
24
24
  const legendCoordinate = LegendHelper.getLegendCoordinateByPosition(model.options.legend.position, model.otherComponents.legendBlock, model.blockCanvas.size);
25
25
  this.fillCoordinate(legendObject, legendCoordinate);
@@ -32,8 +32,7 @@ export class Legend {
32
32
  return;
33
33
  const legendObject = this.getObject(block);
34
34
  const colors = LegendHelper.getMarksColor(options);
35
- const itemWrappers = legendObject
36
- .selectAll(`.${Legend.itemClass}`);
35
+ const itemWrappers = legendObject.selectAll(`.${Legend.itemClass}`);
37
36
  const markerCreator = this.markerCreator;
38
37
  itemWrappers.each(function (d, i) {
39
38
  const selection = select(this);
@@ -44,8 +43,8 @@ export class Legend {
44
43
  return block
45
44
  .getSvg()
46
45
  .selectAll(`.${this.itemClass}`)
47
- .filter(d => {
48
- const index = keys.findIndex(k => k === d.textContent);
46
+ .filter((d) => {
47
+ const index = keys.findIndex((k) => k === d.textContent);
49
48
  return condition === SelectionCondition.Include ? index !== -1 : index === -1;
50
49
  });
51
50
  }
@@ -54,7 +53,7 @@ export class Legend {
54
53
  const colors = LegendHelper.getMarksColor(options, data[options.data.dataSource]);
55
54
  const renderingOptions = LegendHelper.getContentRenderingOptions(options.type, options.legend.position, legendBlockModel);
56
55
  const itemBlocks = this.renderContent(legendObject, items, colors, renderingOptions);
57
- if (options.type === 'polar') {
56
+ if (options.type === "polar") {
58
57
  LegendEventsManager.setListeners(block, options.data.keyField.name, itemBlocks, options.selectable);
59
58
  }
60
59
  else {
@@ -62,58 +61,50 @@ export class Legend {
62
61
  }
63
62
  }
64
63
  renderObject(block, legendPosition, legendBlockModel, blockSize) {
65
- const legendObject = block.getSvg()
66
- .append('foreignObject')
67
- .attr('class', Legend.objectClass);
64
+ const legendObject = block.getSvg().append("foreignObject").attr("class", Legend.objectClass);
68
65
  const legendCoordinate = LegendHelper.getLegendCoordinateByPosition(legendPosition, legendBlockModel, blockSize);
69
66
  this.fillCoordinate(legendObject, legendCoordinate);
70
67
  return legendObject;
71
68
  }
72
69
  renderContent(foreignObject, items, colorPalette, options) {
73
- const wrapper = foreignObject.append('xhtml:div');
70
+ const wrapper = foreignObject.append("xhtml:div");
74
71
  wrapper.classed(options.wrapperClasses.join(" "), true);
75
- const itemWrappers = wrapper
76
- .selectAll(`.${Legend.itemClass}`)
77
- .data(items)
78
- .enter()
79
- .append('div');
72
+ const itemWrappers = wrapper.selectAll(`.${Legend.itemClass}`).data(items).enter().append("div");
80
73
  itemWrappers.classed(options.itemsOptions.wrapperClasses.join(" "), true);
81
74
  const markerCreator = this.markerCreator;
82
- itemWrappers
83
- .each(function (d, i) {
75
+ itemWrappers.each(function (d, i) {
84
76
  const selection = select(this);
85
77
  const markers = markerCreator.create(selection, Object.assign(Object.assign({}, d), { color: colorPalette[i % colorPalette.length] }));
86
78
  markers.classed(options.itemsOptions.markerClass, true);
87
79
  });
88
80
  itemWrappers
89
- .append('span')
90
- .attr('class', options.itemsOptions.labelClass)
91
- .text(d => d.textContent);
81
+ .append("span")
82
+ .attr("class", options.itemsOptions.labelClass)
83
+ .text((d) => d.textContent);
92
84
  if (options.shouldCropLabels)
93
85
  LegendDomHelper.decreaseRowLabels(foreignObject, itemWrappers, options.blockModel.static);
94
86
  return itemWrappers;
95
87
  }
96
88
  getObject(block) {
97
- return block.getSvg()
98
- .select(`foreignObject.${Legend.objectClass}`);
89
+ return block.getSvg().select(`foreignObject.${Legend.objectClass}`);
99
90
  }
100
91
  removeContent(legendObject) {
101
92
  legendObject.select(`.${Legend.legendBlockClass}`).remove();
102
93
  }
103
94
  fillCoordinate(legendBlock, coordinate) {
104
95
  legendBlock
105
- .attr('x', coordinate.x)
106
- .attr('y', coordinate.y)
107
- .attr('width', coordinate.width)
108
- .attr('height', coordinate.height);
96
+ .attr("x", coordinate.x)
97
+ .attr("y", coordinate.y)
98
+ .attr("width", coordinate.width)
99
+ .attr("height", coordinate.height);
109
100
  }
110
101
  }
111
- Legend.objectClass = 'legend-object';
112
- Legend.labelClass = 'legend-label';
113
- Legend.label2DClass = 'legend-2d-label';
114
- Legend.labelPolarClass = 'legend-polar-label';
115
- Legend.labelIntervalClass = 'legend-interval-label';
116
- Legend.itemClass = 'legend-item';
117
- Legend.markerClass = 'legend-marker';
118
- Legend.markerCircle = 'legend-circle';
119
- Legend.legendBlockClass = 'legend-block';
102
+ Legend.objectClass = "legend-object";
103
+ Legend.labelClass = "legend-label";
104
+ Legend.label2DClass = "legend-2d-label";
105
+ Legend.labelPolarClass = "legend-polar-label";
106
+ Legend.labelIntervalClass = "legend-interval-label";
107
+ Legend.itemClass = "legend-item";
108
+ Legend.markerClass = "legend-marker";
109
+ Legend.markerCircle = "legend-circle";
110
+ Legend.legendBlockClass = "legend-block";
@@ -5,17 +5,24 @@ import { LegendHelper } from "./legendHelper";
5
5
  import { getNewLegendItemWidths } from "./legendWidthCalculator";
6
6
  export class LegendDomHelper {
7
7
  static setItemsTitles(items) {
8
- items.attr('title', d => d.textContent);
8
+ items.attr("title", (d) => d.textContent);
9
9
  }
10
10
  static decreaseRowLabels(legendBlock, items, staticLegend) {
11
11
  let itemsRightMargins = this.getItemsRightMargins(items);
12
12
  const itemConfig = [];
13
13
  items.nodes().forEach((node, i) => {
14
- itemConfig.push({ width: node.getBoundingClientRect().width, marginLeft: 0, marginRight: itemsRightMargins[i] });
14
+ itemConfig.push({
15
+ width: node.getBoundingClientRect().width,
16
+ marginLeft: 0,
17
+ marginRight: itemsRightMargins[i]
18
+ });
15
19
  });
16
20
  const newWidths = getNewLegendItemWidths({
17
21
  items: itemConfig,
18
- wrapper: { maxRowsAmount: staticLegend.maxLinesAmount, width: legendBlock.node().getBoundingClientRect().width }
22
+ wrapper: {
23
+ maxRowsAmount: staticLegend.maxLinesAmount,
24
+ width: legendBlock.node().getBoundingClientRect().width
25
+ }
19
26
  });
20
27
  items.nodes().forEach((node, i) => {
21
28
  node.style.width = `${newWidths[i]}px`;
@@ -27,23 +34,23 @@ export class LegendDomHelper {
27
34
  let itemsLeftMargins = this.getItemsRightMargins(items);
28
35
  let itemsWidth = this.getItemsWidth(items);
29
36
  let sumOfItemsWidth = LegendHelper.getSumOfItemsWidths(itemsWidth, itemsLeftMargins);
30
- const maxItemWidth = LegendHelper.getMaxItemWidth(legendBlock.attr('width'), itemsLeftMargins, 'row');
37
+ const maxItemWidth = LegendHelper.getMaxItemWidth(legendBlock.attr("width"), itemsLeftMargins, "row");
31
38
  let index = 0;
32
39
  let loopFlag = true; // if at least one label has no text, loop ends
33
40
  while (sumOfItemsWidth > maxWidth && loopFlag) {
34
- items.nodes().forEach(node => {
41
+ items.nodes().forEach((node) => {
35
42
  const textBlock = node.querySelector(`.${Legend.labelClass}`);
36
43
  if (node.getBoundingClientRect().width > maxItemWidth && textBlock.textContent) {
37
44
  let labelText = index > 0
38
45
  ? textBlock.textContent.substr(0, textBlock.textContent.length - 3)
39
46
  : textBlock.textContent;
40
47
  labelText = labelText.substr(0, labelText.length - 1);
41
- textBlock.textContent = labelText + '...';
48
+ textBlock.textContent = labelText + "...";
42
49
  itemsLeftMargins = this.getItemsRightMargins(items);
43
50
  itemsWidth = this.getItemsWidth(items);
44
51
  sumOfItemsWidth = LegendHelper.getSumOfItemsWidths(itemsWidth, itemsLeftMargins);
45
52
  if (labelText.length === 0) {
46
- textBlock.textContent = '';
53
+ textBlock.textContent = "";
47
54
  loopFlag = false;
48
55
  }
49
56
  }
@@ -52,9 +59,11 @@ export class LegendDomHelper {
52
59
  }
53
60
  }
54
61
  static getItemsRightMargins(items) {
55
- return items.nodes().map(node => Helper.getPXValueFromString(DomHelper.getCssPropertyValue(node, 'margin-right')));
62
+ return items
63
+ .nodes()
64
+ .map((node) => Helper.getPXValueFromString(DomHelper.getCssPropertyValue(node, "margin-right")));
56
65
  }
57
66
  static getItemsWidth(items) {
58
- return items.nodes().map(node => node.getBoundingClientRect().width);
67
+ return items.nodes().map((node) => node.getBoundingClientRect().width);
59
68
  }
60
69
  }
@@ -14,9 +14,10 @@ export class LegendEventsManager {
14
14
  }
15
15
  static setHoverListeners(block, keyFieldName, legendItems) {
16
16
  const arcItems = Donut.getAllArcGroups(block);
17
- legendItems.on('mousemove', function (e, keyValue) {
18
- arcItems.filter((row) => row.data[keyFieldName] === keyValue.textContent)
19
- .dispatch('mousemove', {
17
+ legendItems.on("mousemove", function (e, keyValue) {
18
+ arcItems
19
+ .filter((row) => row.data[keyFieldName] === keyValue.textContent)
20
+ .dispatch("mousemove", {
20
21
  bubbles: false,
21
22
  cancelable: true,
22
23
  detail: {
@@ -25,23 +26,27 @@ export class LegendEventsManager {
25
26
  }
26
27
  });
27
28
  });
28
- legendItems.on('mouseover', function (e, keyValue) {
29
- arcItems.filter((row) => row.data[keyFieldName] === keyValue.textContent)
30
- .dispatch('mouseover');
29
+ legendItems.on("mouseover", function (e, keyValue) {
30
+ arcItems.filter((row) => row.data[keyFieldName] === keyValue.textContent).dispatch("mouseover");
31
31
  ElementHighlighter.toggleActivityStyle(select(this), true);
32
32
  });
33
- legendItems.on('mouseleave', function (e, keyValue) {
34
- arcItems.filter((row) => row.data[keyFieldName] === keyValue.textContent)
35
- .dispatch('mouseleave');
36
- if (!block.filterEventManager.isSelected(keyValue.textContent) && block.filterEventManager.getSelectedKeys().length > 0)
33
+ legendItems.on("mouseleave", function (e, keyValue) {
34
+ arcItems.filter((row) => row.data[keyFieldName] === keyValue.textContent).dispatch("mouseleave");
35
+ if (!block.filterEventManager.isSelected(keyValue.textContent) &&
36
+ block.filterEventManager.getSelectedKeys().length > 0)
37
37
  ElementHighlighter.toggleActivityStyle(select(this), false);
38
38
  });
39
39
  }
40
40
  static setClickListeners(block, keyFieldName, legendItems) {
41
41
  const arcItems = Donut.getAllArcGroups(block);
42
- legendItems.on('click', (e, keyValue) => {
43
- arcItems.filter((row) => row.data[keyFieldName] === keyValue.textContent)
44
- .dispatch('click', { bubbles: false, cancelable: true, detail: { multySelect: e.ctrlKey || e.metaKey } });
42
+ legendItems.on("click", (e, keyValue) => {
43
+ arcItems
44
+ .filter((row) => row.data[keyFieldName] === keyValue.textContent)
45
+ .dispatch("click", {
46
+ bubbles: false,
47
+ cancelable: true,
48
+ detail: { multySelect: e.ctrlKey || e.metaKey }
49
+ });
45
50
  });
46
51
  }
47
52
  }
@@ -1,12 +1,12 @@
1
- import { Helper } from '../../helpers/helper';
1
+ import { Helper } from "../../helpers/helper";
2
2
  import { Legend } from "./legend";
3
3
  import { LegendHelperService } from "./legendHelperService";
4
4
  export class LegendHelper {
5
5
  static getLegendItemsContent(options, data) {
6
- if (options.type === '2d') {
6
+ if (options.type === "2d") {
7
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 }))));
8
+ options.charts.forEach((chart) => {
9
+ texts = texts.concat(chart.data.valueFields.map((field) => (Object.assign(Object.assign({}, chart.legend), { textContent: field.title }))));
10
10
  });
11
11
  return texts;
12
12
  }
@@ -15,21 +15,21 @@ export class LegendHelper {
15
15
  }
16
16
  }
17
17
  static getMarksColor(options, dataRows) {
18
- if (options.type === '2d') {
18
+ if (options.type === "2d") {
19
19
  let colors = [];
20
- options.charts.forEach(chart => {
20
+ options.charts.forEach((chart) => {
21
21
  colors = colors.concat(chart.style.elementColors);
22
22
  });
23
23
  return colors;
24
24
  }
25
- else if (options.type === 'polar') {
25
+ else if (options.type === "polar") {
26
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]);
27
+ return options.charts.map((chart) => chart.style.elementColors)[0];
28
+ return dataRows.map((row) => row[options.charts[0].data.colorField]);
29
29
  }
30
30
  }
31
31
  static getMaxItemWidth(legendBlockWidth, marginsLeft, itemsDirection) {
32
- if (itemsDirection === 'row') {
32
+ if (itemsDirection === "row") {
33
33
  const sumOfMargins = Helper.getSumOfNumeric(marginsLeft);
34
34
  return (parseFloat(legendBlockWidth) - sumOfMargins) / marginsLeft.length;
35
35
  }
@@ -48,23 +48,23 @@ export class LegendHelper {
48
48
  width: 0,
49
49
  height: 0
50
50
  };
51
- if (legendPosition === 'left' || legendPosition === 'right') {
51
+ if (legendPosition === "left" || legendPosition === "right") {
52
52
  coordinate.y = legendModel.margin.top + legendModel.pad;
53
53
  coordinate.width = legendModel.size;
54
54
  coordinate.height = blockSize.height - legendModel.margin.top - legendModel.margin.bottom;
55
55
  }
56
- else if (legendPosition === 'bottom' || legendPosition === 'top') {
56
+ else if (legendPosition === "bottom" || legendPosition === "top") {
57
57
  coordinate.x = legendModel.margin.left;
58
58
  coordinate.width = blockSize.width - legendModel.margin.left - legendModel.margin.right;
59
59
  coordinate.height = legendModel.size;
60
60
  }
61
- if (legendPosition === 'left')
61
+ if (legendPosition === "left")
62
62
  coordinate.x = legendModel.margin.left;
63
- else if (legendPosition === 'right')
63
+ else if (legendPosition === "right")
64
64
  coordinate.x = blockSize.width - legendModel.size - legendModel.margin.right;
65
- else if (legendPosition === 'top')
65
+ else if (legendPosition === "top")
66
66
  coordinate.y = legendModel.margin.top + legendModel.pad;
67
- else if (legendPosition === 'bottom')
67
+ else if (legendPosition === "bottom")
68
68
  coordinate.y = blockSize.height - legendModel.size - legendModel.margin.bottom;
69
69
  return coordinate;
70
70
  }
@@ -89,9 +89,9 @@ export class LegendHelper {
89
89
  }
90
90
  static getLegendClassByChartNotation(chartNotation) {
91
91
  const legendClasses = {
92
- '2d': Legend.label2DClass,
93
- 'polar': Legend.labelPolarClass,
94
- 'interval': Legend.labelIntervalClass
92
+ "2d": Legend.label2DClass,
93
+ polar: Legend.labelPolarClass,
94
+ interval: Legend.labelIntervalClass
95
95
  };
96
96
  return `${Legend.labelClass} ${legendClasses[chartNotation]}`;
97
97
  }
@@ -10,18 +10,18 @@ export class LegendHelperService {
10
10
  }
11
11
  getLegendLabelClassByPosition(legendPosition, chartNotation, initialLabelClass) {
12
12
  if (this.doesLegendInTopBy2d(legendPosition, chartNotation))
13
- return `${initialLabelClass} ${initialLabelClass + '-nowrap'}`;
13
+ return `${initialLabelClass} ${initialLabelClass + "-nowrap"}`;
14
14
  return initialLabelClass;
15
15
  }
16
16
  getItemClasses(itemsDirection) {
17
- return itemsDirection === 'column' ? 'legend-item-row' : 'legend-item-inline';
17
+ return itemsDirection === "column" ? "legend-item-row" : "legend-item-inline";
18
18
  }
19
19
  getLegendItemsDirection(legendPosition) {
20
- if (legendPosition === 'right' || legendPosition === 'left')
21
- return 'column';
20
+ if (legendPosition === "right" || legendPosition === "left")
21
+ return "column";
22
22
  return "row";
23
23
  }
24
24
  doesLegendInTopBy2d(legendPosition, chartNotation) {
25
- return (legendPosition === 'top' || legendPosition === 'bottom') && chartNotation === "2d";
25
+ return (legendPosition === "top" || legendPosition === "bottom") && chartNotation === "2d";
26
26
  }
27
27
  }
@@ -25,17 +25,18 @@ class DefaultMarkerCreator {
25
25
  this.cssClass = cssClass;
26
26
  }
27
27
  renderMarker(selection, color) {
28
- return selection.append('span').style('background-color', color).classed(this.cssClass, true);
28
+ return selection.append("span").style("background-color", color).classed(this.cssClass, true);
29
29
  }
30
30
  updateColors(selection, color) {
31
- selection.select(`.${this.cssClass}`).style('background-color', color);
31
+ selection.select(`.${this.cssClass}`).style("background-color", color);
32
32
  }
33
33
  }
34
34
  class SvgMarkerCreator {
35
35
  renderSvg(selection) {
36
- return selection.append('svg')
36
+ return selection
37
+ .append("svg")
37
38
  .style("display", "inline-block")
38
- .style("height", '8px')
39
+ .style("height", "8px")
39
40
  .classed(Legend.markerClass, true);
40
41
  }
41
42
  }
@@ -47,20 +48,20 @@ class BarMarkerCreator extends SvgMarkerCreator {
47
48
  renderMarker(selection, color) {
48
49
  const svg = this.renderSvg(selection).style("width", this.options.width);
49
50
  const bars = svg
50
- .append('rect')
51
- .attr('x', 0)
52
- .attr('y', 0)
53
- .attr('height', this.options.width)
54
- .attr('width', this.options.width)
55
- .style('fill', color)
56
- .style('clip-path', getClipPathValue(this.options.borderRadius));
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));
57
58
  if (this.options.hatch.on) {
58
- bars.style('mask', HatchPatternDef.getMaskValue());
59
+ bars.style("mask", HatchPatternDef.getMaskValue());
59
60
  }
60
61
  return bars;
61
62
  }
62
63
  updateColors(selection, color) {
63
- selection.select('svg rect').style('fill', color);
64
+ selection.select("svg rect").style("fill", color);
64
65
  }
65
66
  }
66
67
  class LineMarkerCreator extends SvgMarkerCreator {
@@ -71,21 +72,21 @@ class LineMarkerCreator extends SvgMarkerCreator {
71
72
  renderMarker(selection, color) {
72
73
  const svg = this.renderSvg(selection).style("width", this.options.length);
73
74
  const line = svg
74
- .append('line')
75
- .style('stroke', 'red')
75
+ .append("line")
76
+ .style("stroke", "red")
76
77
  .classed("line", true)
77
- .attr('x1', 0)
78
- .attr('x2', this.options.length)
79
- .attr('y1', 5)
80
- .attr('y2', 5)
81
- .style('stroke', color)
82
- .style('stroke-width', this.options.strokeWidth);
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);
83
84
  if (this.options.dashedStyles.on) {
84
85
  applyLineDash(line, this.options.dashedStyles.dashSize, this.options.dashedStyles.gapSize);
85
86
  }
86
87
  return line;
87
88
  }
88
89
  updateColors(selection, color) {
89
- selection.select('svg line').style('stroke', color);
90
+ selection.select("svg line").style("stroke", color);
90
91
  }
91
92
  }
@@ -1,6 +1,6 @@
1
1
  export function getNewLegendItemWidths(config) {
2
2
  const wrapper = new LegendWrapper(config.wrapper);
3
- const collection = new LegendItemCollection(config.items.map(i => new LegendItem(i)));
3
+ const collection = new LegendItemCollection(config.items.map((i) => new LegendItem(i)));
4
4
  return getNewWidths(collection, wrapper);
5
5
  }
6
6
  function getNewWidths(collection, wrapper) {
@@ -13,9 +13,7 @@ function getNewWidths(collection, wrapper) {
13
13
  let avgExtra = extra / biggerThanAvg.length;
14
14
  biggerThanAvg.forEach((item, index) => {
15
15
  const avgDiff = item.getCurrentWidth() - avgWidth;
16
- const decreaseBy = index === biggerThanAvg.length - 1
17
- ? extra
18
- : (avgDiff < avgExtra ? avgDiff : avgExtra);
16
+ const decreaseBy = index === biggerThanAvg.length - 1 ? extra : avgDiff < avgExtra ? avgDiff : avgExtra;
19
17
  item.decreaseBy(decreaseBy);
20
18
  extra -= decreaseBy;
21
19
  avgExtra = extra / (biggerThanAvg.length - index - 1);
@@ -101,7 +99,7 @@ class LegendItemCollection {
101
99
  return this.items.reduce((acc, item) => acc + item.getCurrentTotalWidth(), 0);
102
100
  }
103
101
  getActualWidths() {
104
- return this.items.map(item => item.getCurrentWidth());
102
+ return this.items.map((item) => item.getCurrentWidth());
105
103
  }
106
104
  getTotalMarginSizes() {
107
105
  return this.items.reduce((acc, item) => acc + item.getTotalMarginSize(), 0);
@@ -111,7 +109,7 @@ class LegendItemCollection {
111
109
  }
112
110
  getItemsWithWidthBiggerThan(thanWidth) {
113
111
  return this.items
114
- .filter(item => item.getCurrentWidth() > thanWidth)
112
+ .filter((item) => item.getCurrentWidth() > thanWidth)
115
113
  .sort((a, b) => a.getCurrentWidth() - b.getCurrentWidth());
116
114
  }
117
115
  getFirstItem() {
@@ -130,7 +128,7 @@ class LegendItemCollection {
130
128
  this.items.push(...items);
131
129
  }
132
130
  resetItemsToOriginalWidth() {
133
- this.items.forEach(item => item.resetWidthToOriginal());
131
+ this.items.forEach((item) => item.resetWidthToOriginal());
134
132
  return this;
135
133
  }
136
134
  }
@@ -1,5 +1,5 @@
1
- import { Selection, BaseType } from 'd3-selection';
2
- import { MdtChartsDataRow } from '../../../config/config';
1
+ import { Selection, BaseType } from "d3-selection";
2
+ import { MdtChartsDataRow } from "../../../config/config";
3
3
  import { BlockMargin, MarkersOptions, Orient, TwoDimensionalChartModel } from "../../../model/model";
4
4
  import { Block } from "../../block/block";
5
5
  import { Scales } from "../scale/scale";