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
@@ -1,25 +1,25 @@
1
- import { select, pointer, } from 'd3-selection';
1
+ import { select, pointer } from "d3-selection";
2
2
  import { TooltipDomHelper } from "./tooltipDomHelper";
3
3
  import { Donut } from "../../polarNotation/donut/donut";
4
- import { TooltipComponentsManager } from './tooltipComponentsManager';
5
- import { ElementHighlighter } from '../../elementHighlighter/elementHighlighter';
6
- import { DonutHelper } from '../../polarNotation/donut/DonutHelper';
7
- import { TipBox } from '../tipBox/tipBox';
8
- import { TipBoxHelper } from '../tipBox/tipBoxHelper';
9
- import { Helper } from '../../helpers/helper';
10
- import { TooltipHelper } from './tooltipHelper';
11
- import { DomHelper } from '../../helpers/domHelper';
12
- import { NewTooltip } from './newTooltip/newTooltip';
4
+ import { TooltipComponentsManager } from "./tooltipComponentsManager";
5
+ import { ElementHighlighter } from "../../elementHighlighter/elementHighlighter";
6
+ import { DonutHelper } from "../../polarNotation/donut/DonutHelper";
7
+ import { TipBox } from "../tipBox/tipBox";
8
+ import { TipBoxHelper } from "../tipBox/tipBoxHelper";
9
+ import { Helper } from "../../helpers/helper";
10
+ import { TooltipHelper } from "./tooltipHelper";
11
+ import { DomHelper } from "../../helpers/domHelper";
12
+ import { NewTooltip } from "./newTooltip/newTooltip";
13
13
  import { MarkDot } from "../../../engine/features/markDots/markDot";
14
14
  export class Tooltip {
15
15
  static render(block, model, data, tooltipOptions, scales) {
16
16
  TooltipComponentsManager.renderTooltipWrapper(block);
17
17
  const withTooltipIndex = model.options.charts.findIndex((chart) => chart.tooltip.show);
18
18
  if (withTooltipIndex !== -1) {
19
- if (model.options.type === '2d') {
19
+ if (model.options.type === "2d") {
20
20
  this.renderTooltipFor2DCharts(block, data, model.blockCanvas.size, model.chartBlock.margin, scales, model.options, tooltipOptions);
21
21
  }
22
- else if (model.options.type === 'polar') {
22
+ else if (model.options.type === "polar") {
23
23
  this.renderTooltipForPolar(block, model.options, data, model.blockCanvas.size, model.chartBlock.margin, DonutHelper.getThickness(model.options.chartCanvas, model.blockCanvas.size, model.chartBlock.margin), model.otherComponents.tooltipBlock);
24
24
  }
25
25
  }
@@ -32,7 +32,7 @@ export class Tooltip {
32
32
  if (scales.key.domain().length === 0)
33
33
  return;
34
34
  const tooltipParams = {
35
- type: '2d',
35
+ type: "2d",
36
36
  scales,
37
37
  margin,
38
38
  blockSize,
@@ -47,7 +47,7 @@ export class Tooltip {
47
47
  this.renderLineTooltip(block, data, tooltipParams);
48
48
  }
49
49
  static renderTooltipForPolar(block, options, data, blockSize, margin, chartThickness, tooltipOptions) {
50
- const attrTransform = block.getSvg().select(`.${Donut.donutBlockClass}`).attr('transform');
50
+ const attrTransform = block.getSvg().select(`.${Donut.donutBlockClass}`).attr("transform");
51
51
  const translateNums = Helper.getTranslateNumbers(attrTransform);
52
52
  const arcItems = Donut.getAllArcGroups(block);
53
53
  this.renderTooltipForDonut(block, arcItems, data, options.data, options.charts[0], blockSize, margin, chartThickness, tooltipOptions, options.tooltip, { x: translateNums[0], y: translateNums[1] });
@@ -58,29 +58,30 @@ export class Tooltip {
58
58
  const tooltipLine = TooltipComponentsManager.renderTooltipLine(block);
59
59
  const tipBox = TipBox.renderOrGet(block, args.margin, args.blockSize);
60
60
  let currentKey = null;
61
- tipBox.on('mousemove', function (e) {
62
- const keyValue = e.detail.keyValue || TipBoxHelper.getKeyValueByPointer(pointer(e, this), args.chartOrientation, args.margin, args.blockSize, args.scales.key, args.scaleKeyModel.type);
63
- if (args.tooltipSettings.position === 'followCursor') {
61
+ tipBox.on("mousemove", function (e) {
62
+ const keyValue = e.detail.keyValue ||
63
+ TipBoxHelper.getKeyValueByPointer(pointer(e, this), args.chartOrientation, args.margin, args.blockSize, args.scales.key, args.scaleKeyModel.type);
64
+ if (args.tooltipSettings.position === "followCursor") {
64
65
  const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(e.detail.pointer || pointer(e, this), block.getSvg().node().getBoundingClientRect(), tooltipBlock.getEl().node().getBoundingClientRect());
65
66
  TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, 0);
66
67
  }
67
68
  if (!currentKey || currentKey !== keyValue) {
68
69
  TooltipComponentsManager.showComponent(tooltipBlock.getEl());
69
- if (args.type === '2d')
70
- TooltipDomHelper.fillForMulti2DCharts(tooltipContent, args.charts.filter(ch => ch.tooltip.show), data, args.dataOptions, keyValue, args.tooltipOptions);
71
- if (args.tooltipSettings.position === 'fixed') {
70
+ if (args.type === "2d")
71
+ TooltipDomHelper.fillForMulti2DCharts(tooltipContent, args.charts.filter((ch) => ch.tooltip.show), data, args.dataOptions, keyValue, args.tooltipOptions);
72
+ if (args.tooltipSettings.position === "fixed") {
72
73
  const tooltipCoordinate = TooltipHelper.getTooltipFixedCoordinate(args.scales.key, args.margin, keyValue, block.getSvg().node().getBoundingClientRect(), tooltipContent.node().getBoundingClientRect(), args.keyAxisOrient, window.innerWidth, window.innerHeight);
73
74
  TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, block.transitionManager.durations.tooltipSlide);
74
75
  }
75
76
  const tooltipLineAttributes = TooltipHelper.getTooltipLineAttributes(args.scales.key, args.margin, keyValue, args.chartOrientation, args.blockSize);
76
77
  TooltipComponentsManager.setTooltipLineAttributes(tooltipLine, tooltipLineAttributes, block.transitionManager.durations.tooltipSlide);
77
78
  TooltipComponentsManager.showComponent(tooltipLine);
78
- if (args.type === '2d') {
79
- args.charts.forEach(chart => {
79
+ if (args.type === "2d") {
80
+ args.charts.forEach((chart) => {
80
81
  const elements = DomHelper.get2DChartElements(block, chart);
81
82
  if (!block.filterEventManager.isSelected(currentKey)) {
82
83
  const oldElements = DomHelper.getChartElementsByKeys(elements, chart.isSegmented, args.dataOptions.keyField.name, [currentKey]);
83
- if (chart.type !== 'bar')
84
+ if (chart.type !== "bar")
84
85
  MarkDot.tryMakeMarkDotVisible(oldElements, chart.markersOptions, false);
85
86
  ElementHighlighter.toggle2DElements(oldElements, false, chart, block.transitionManager.durations.markerHover);
86
87
  if (block.filterEventManager.getSelectedKeys().length > 0) {
@@ -88,10 +89,11 @@ export class Tooltip {
88
89
  }
89
90
  }
90
91
  const selectedElements = DomHelper.getChartElementsByKeys(elements, chart.isSegmented, args.dataOptions.keyField.name, [keyValue]);
91
- if (chart.type !== 'bar')
92
+ if (chart.type !== "bar")
92
93
  MarkDot.tryMakeMarkDotVisible(selectedElements, chart.markersOptions, true);
93
94
  ElementHighlighter.toggleActivityStyle(selectedElements, true);
94
- if (block.filterEventManager.getSelectedKeys().length === 0 || block.filterEventManager.isSelected(keyValue)) {
95
+ if (block.filterEventManager.getSelectedKeys().length === 0 ||
96
+ block.filterEventManager.isSelected(keyValue)) {
95
97
  ElementHighlighter.toggle2DElements(selectedElements, true, chart, block.transitionManager.durations.markerHover);
96
98
  }
97
99
  });
@@ -99,10 +101,10 @@ export class Tooltip {
99
101
  currentKey = keyValue;
100
102
  }
101
103
  });
102
- tipBox.on('mouseleave', function () {
104
+ tipBox.on("mouseleave", function () {
103
105
  TooltipComponentsManager.hideComponent(tooltipBlock.getEl());
104
106
  TooltipComponentsManager.hideComponent(tooltipLine);
105
- if (args.type === '2d')
107
+ if (args.type === "2d")
106
108
  ElementHighlighter.removeUnselected2DHighlight(block, args.dataOptions.keyField.name, args.charts, block.transitionManager.durations.markerHover);
107
109
  currentKey = null;
108
110
  });
@@ -111,19 +113,21 @@ export class Tooltip {
111
113
  const tooltipBlock = TooltipComponentsManager.renderTooltipBlock(block);
112
114
  const tooltipContent = TooltipComponentsManager.renderTooltipContentBlock(tooltipBlock);
113
115
  let tooltipArrow;
114
- if (tooltipSettings.position === 'fixed')
116
+ if (tooltipSettings.position === "fixed")
115
117
  tooltipArrow = TooltipComponentsManager.renderTooltipArrow(tooltipBlock.getEl());
116
- if (tooltipSettings.position === 'followCursor') {
117
- elements.on('mousemove', function (e) {
118
- const pointerCoordinate = !pointer(e, block.getSvg().node())[0] ? e.detail.pointer : pointer(e, block.getSvg().node());
118
+ if (tooltipSettings.position === "followCursor") {
119
+ elements.on("mousemove", function (e) {
120
+ const pointerCoordinate = !pointer(e, block.getSvg().node())[0]
121
+ ? e.detail.pointer
122
+ : pointer(e, block.getSvg().node());
119
123
  const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(pointerCoordinate, block.getSvg().node().getBoundingClientRect(), tooltipBlock.getEl().node().getBoundingClientRect());
120
124
  tooltipBlock.setCoordinate(tooltipCoordinate);
121
125
  });
122
126
  }
123
- elements.on('mouseover', function (e, dataRow) {
127
+ elements.on("mouseover", function (e, dataRow) {
124
128
  TooltipComponentsManager.showComponent(tooltipBlock.getEl());
125
- TooltipDomHelper.fillForPolarChart(tooltipContent, chart, data, dataOptions, dataRow.data[dataOptions.keyField.name], select(this).select('path').style('fill'), tooltipOptions);
126
- if (tooltipSettings.position === 'fixed') {
129
+ TooltipDomHelper.fillForPolarChart(tooltipContent, chart, data, dataOptions, dataRow.data[dataOptions.keyField.name], select(this).select("path").style("fill"), tooltipOptions);
130
+ if (tooltipSettings.position === "fixed") {
127
131
  const coordinatePointer = TooltipDomHelper.getRecalcedCoordinateByArrow(DonutHelper.getArcCentroid(blockSize, margin, dataRow, donutThickness), tooltipBlock.getEl(), blockSize, tooltipArrow, translate.x, translate.y);
128
132
  coordinatePointer[0] = coordinatePointer[0] + translate.x;
129
133
  coordinatePointer[1] = coordinatePointer[1] + translate.y;
@@ -131,13 +135,14 @@ export class Tooltip {
131
135
  tooltipBlock.setCoordinate(tooltipCoordinate);
132
136
  }
133
137
  ElementHighlighter.toggleActivityStyle(select(this), true);
134
- const clones = Donut.getAllArcClones(block)
135
- .filter((d) => d.data[dataOptions.keyField.name] === dataRow.data[dataOptions.keyField.name]);
136
- if (clones.nodes().length === 0 && (block.filterEventManager.getSelectedKeys().length === 0 || block.filterEventManager.isSelected(dataRow.data[dataOptions.keyField.name]))) {
138
+ const clones = Donut.getAllArcClones(block).filter((d) => d.data[dataOptions.keyField.name] === dataRow.data[dataOptions.keyField.name]);
139
+ if (clones.nodes().length === 0 &&
140
+ (block.filterEventManager.getSelectedKeys().length === 0 ||
141
+ block.filterEventManager.isSelected(dataRow.data[dataOptions.keyField.name]))) {
137
142
  ElementHighlighter.renderArcCloneAndHighlight(block, margin, select(this), blockSize, donutThickness);
138
143
  }
139
144
  });
140
- elements.on('mouseleave', function (e, dataRow) {
145
+ elements.on("mouseleave", function (e, dataRow) {
141
146
  TooltipComponentsManager.hideComponent(tooltipBlock.getEl());
142
147
  if (!block.filterEventManager.isSelected(dataRow.data[dataOptions.keyField.name])) {
143
148
  ElementHighlighter.removeCloneForElem(block, dataOptions.keyField.name, select(this));
@@ -151,7 +156,7 @@ export class Tooltip {
151
156
  }
152
157
  }
153
158
  Tooltip.tooltipBlockClass = NewTooltip.tooltipBlockClass;
154
- Tooltip.tooltipLineClass = 'mdt-charts-tooltip-line';
155
- Tooltip.tooltipWrapperClass = 'mdt-charts-tooltip-wrapper';
156
- Tooltip.tooltipContentClass = 'mdt-charts-tooltip-content';
157
- Tooltip.tooltipArrowClass = 'mdt-charts-tooltip-arrow';
159
+ Tooltip.tooltipLineClass = "mdt-charts-tooltip-line";
160
+ Tooltip.tooltipWrapperClass = "mdt-charts-tooltip-wrapper";
161
+ Tooltip.tooltipContentClass = "mdt-charts-tooltip-content";
162
+ Tooltip.tooltipArrowClass = "mdt-charts-tooltip-arrow";
@@ -1,8 +1,8 @@
1
- import { Selection, BaseType } from 'd3-selection';
1
+ import { Selection, BaseType } from "d3-selection";
2
2
  import { Block } from "../../block/block";
3
3
  import { TooltipLineAttributes } from "./tooltipDomHelper";
4
4
  import { ChartOrientation } from "../../../config/config";
5
- import { NewTooltip, TooltipCoordinate } from './newTooltip/newTooltip';
5
+ import { NewTooltip, TooltipCoordinate } from "./newTooltip/newTooltip";
6
6
  export declare class TooltipComponentsManager {
7
7
  static showComponent(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): void;
8
8
  static hideComponent(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): void;
@@ -1,23 +1,20 @@
1
- import { select } from 'd3-selection';
1
+ import { select } from "d3-selection";
2
2
  import { ARROW_DEFAULT_POSITION, ARROW_SIZE } from "./tooltipDomHelper";
3
- import { easeLinear } from 'd3-ease';
4
- import { interrupt } from 'd3-transition';
5
- import { Tooltip } from './tooltip';
6
- import { NewTooltip } from './newTooltip/newTooltip';
3
+ import { easeLinear } from "d3-ease";
4
+ import { interrupt } from "d3-transition";
5
+ import { Tooltip } from "./tooltip";
6
+ import { NewTooltip } from "./newTooltip/newTooltip";
7
7
  export class TooltipComponentsManager {
8
8
  static showComponent(tooltipBlock) {
9
- tooltipBlock.style('display', 'block');
9
+ tooltipBlock.style("display", "block");
10
10
  }
11
11
  static hideComponent(tooltipBlock) {
12
- tooltipBlock.style('display', 'none');
12
+ tooltipBlock.style("display", "none");
13
13
  }
14
14
  static renderTooltipWrapper(block) {
15
- let tooltipWrapper = block.getWrapper()
16
- .select(`.${Tooltip.tooltipWrapperClass}`);
15
+ let tooltipWrapper = block.getWrapper().select(`.${Tooltip.tooltipWrapperClass}`);
17
16
  if (tooltipWrapper.empty())
18
- block.getWrapper()
19
- .append('div')
20
- .attr('class', Tooltip.tooltipWrapperClass);
17
+ block.getWrapper().append("div").attr("class", Tooltip.tooltipWrapperClass);
21
18
  }
22
19
  static renderTooltipBlock(block, translateX = 0, translateY = 0) {
23
20
  const wrapper = block.getWrapper().select(`.${Tooltip.tooltipWrapperClass}`);
@@ -25,70 +22,63 @@ export class TooltipComponentsManager {
25
22
  let tooltipBlock = tooltipService.findInWrapper(wrapper);
26
23
  if (tooltipBlock.empty()) {
27
24
  tooltipBlock = tooltipService.render(wrapper);
28
- tooltipBlock
29
- .style('position', 'absolute')
30
- .style('display', 'none');
25
+ tooltipBlock.style("position", "absolute").style("display", "none");
31
26
  }
32
27
  if (translateX !== 0 || translateY !== 0)
33
- tooltipBlock.style('transform', `translate(${translateX}px, ${translateY}px)`);
28
+ tooltipBlock.style("transform", `translate(${translateX}px, ${translateY}px)`);
34
29
  return tooltipService;
35
30
  }
36
31
  static renderTooltipContentBlock(tooltipBlock) {
37
32
  let tooltipContentBlock = tooltipBlock.getEl().select(`.${Tooltip.tooltipContentClass}`);
38
33
  if (tooltipContentBlock.empty()) {
39
- tooltipContentBlock = select(document.createElement("div"))
40
- .attr("class", Tooltip.tooltipContentClass);
34
+ tooltipContentBlock = select(document.createElement("div")).attr("class", Tooltip.tooltipContentClass);
41
35
  tooltipBlock.appendContent(tooltipContentBlock.node());
42
36
  }
43
37
  return tooltipContentBlock;
44
38
  }
45
39
  static renderTooltipLine(block) {
46
- let tooltipLine = block.svg.getChartBlock()
47
- .select(`.${Tooltip.tooltipLineClass}`);
40
+ let tooltipLine = block.svg.getChartBlock().select(`.${Tooltip.tooltipLineClass}`);
48
41
  if (tooltipLine.empty())
49
- tooltipLine = block.svg.getChartBlock()
50
- .append('line')
51
- .attr('class', Tooltip.tooltipLineClass)
52
- .lower();
42
+ tooltipLine = block.svg.getChartBlock().append("line").attr("class", Tooltip.tooltipLineClass).lower();
53
43
  return tooltipLine;
54
44
  }
55
45
  static setTooltipLineAttributes(tooltipLine, attributes, transition) {
56
46
  interrupt(tooltipLine.node());
57
- if (transition > 0 && tooltipLine.style('display') === 'block') {
47
+ if (transition > 0 && tooltipLine.style("display") === "block") {
58
48
  tooltipLine
59
49
  .interrupt()
60
50
  .transition()
61
51
  .duration(transition)
62
52
  .ease(easeLinear)
63
- .attr('x1', attributes.x1)
64
- .attr('x2', attributes.x2)
65
- .attr('y1', attributes.y1)
66
- .attr('y2', attributes.y2);
53
+ .attr("x1", attributes.x1)
54
+ .attr("x2", attributes.x2)
55
+ .attr("y1", attributes.y1)
56
+ .attr("y2", attributes.y2);
67
57
  }
68
58
  else {
69
59
  tooltipLine
70
- .attr('x1', attributes.x1)
71
- .attr('x2', attributes.x2)
72
- .attr('y1', attributes.y1)
73
- .attr('y2', attributes.y2);
60
+ .attr("x1", attributes.x1)
61
+ .attr("x2", attributes.x2)
62
+ .attr("y1", attributes.y1)
63
+ .attr("y2", attributes.y2);
74
64
  }
75
65
  }
76
66
  static getLineWidth(tooltipLine) {
77
- return parseFloat(tooltipLine.style('stroke-width'));
67
+ return parseFloat(tooltipLine.style("stroke-width"));
78
68
  }
79
69
  static renderTooltipArrow(tooltipBlock) {
80
70
  let arrowSize = ARROW_SIZE / 2;
81
71
  let tooltipArrow = tooltipBlock.select(`.${Tooltip.tooltipArrowClass}`);
82
72
  if (tooltipArrow.empty())
83
73
  tooltipArrow = tooltipBlock
84
- .append('div')
85
- .attr('class', Tooltip.tooltipArrowClass)
86
- .style('position', 'absolute')
87
- .style('left', `${ARROW_DEFAULT_POSITION}px`)
88
- .style('border-top-width', `${arrowSize}px`)
89
- .style('border-right-width', `${arrowSize}px`)
90
- .style('border-bottom-width', `0px`)
91
- .style('border-left-width', `${arrowSize}px`);
74
+ .append("div")
75
+ .attr("class", Tooltip.tooltipArrowClass)
76
+ .style("position", "absolute")
77
+ .style("left", `${ARROW_DEFAULT_POSITION}px`)
78
+ .style("border-top-width", `${arrowSize}px`)
79
+ .style("border-right-width", `${arrowSize}px`)
80
+ .style("border-bottom-width", `0px`)
81
+ .style("border-left-width", `${arrowSize}px`);
92
82
  return tooltipArrow;
93
83
  }
94
84
  static setLineTooltipCoordinate(tooltip, tooltipCoordinate, chartOrientation, transition = null) {
@@ -96,27 +86,34 @@ export class TooltipComponentsManager {
96
86
  interrupt(tooltipBlock.node());
97
87
  if (!transition || transition <= 0)
98
88
  tooltip.setCoordinate(tooltipCoordinate);
99
- if (chartOrientation === 'vertical' && tooltipBlock.style('left') !== '0px' && tooltipBlock.style('right') !== '0px' && tooltipCoordinate.right !== '0px' && tooltipCoordinate.left !== null) {
89
+ if (chartOrientation === "vertical" &&
90
+ tooltipBlock.style("left") !== "0px" &&
91
+ tooltipBlock.style("right") !== "0px" &&
92
+ tooltipCoordinate.right !== "0px" &&
93
+ tooltipCoordinate.left !== null) {
100
94
  tooltipBlock
101
- .style('right', tooltipCoordinate.right)
102
- .style('bottom', tooltipCoordinate.bottom)
103
- .style('top', tooltipCoordinate.top)
95
+ .style("right", tooltipCoordinate.right)
96
+ .style("bottom", tooltipCoordinate.bottom)
97
+ .style("top", tooltipCoordinate.top)
104
98
  .interrupt()
105
99
  .transition()
106
100
  .duration(transition)
107
101
  .ease(easeLinear)
108
- .style('left', tooltipCoordinate.left);
102
+ .style("left", tooltipCoordinate.left);
109
103
  }
110
- else if (chartOrientation === 'horizontal' && tooltipBlock.style('top') !== '0px' && parseInt(tooltipBlock.style('bottom')) > 0 && tooltipCoordinate.bottom === null) {
104
+ else if (chartOrientation === "horizontal" &&
105
+ tooltipBlock.style("top") !== "0px" &&
106
+ parseInt(tooltipBlock.style("bottom")) > 0 &&
107
+ tooltipCoordinate.bottom === null) {
111
108
  tooltipBlock
112
- .style('right', tooltipCoordinate.right)
113
- .style('bottom', tooltipCoordinate.bottom)
114
- .style('left', tooltipCoordinate.left)
109
+ .style("right", tooltipCoordinate.right)
110
+ .style("bottom", tooltipCoordinate.bottom)
111
+ .style("left", tooltipCoordinate.left)
115
112
  .interrupt()
116
113
  .transition()
117
114
  .duration(transition)
118
115
  .ease(easeLinear)
119
- .style('top', tooltipCoordinate.top);
116
+ .style("top", tooltipCoordinate.top);
120
117
  }
121
118
  else {
122
119
  tooltip.setCoordinate(tooltipCoordinate);
@@ -1,4 +1,4 @@
1
- import { Selection, BaseType } from 'd3-selection';
1
+ import { Selection, BaseType } from "d3-selection";
2
2
  import { MdtChartsDataSource, TooltipOptions } from "../../../config/config";
3
3
  import { OptionsModelData, PolarChartModel, TwoDimensionalChartModel } from "../../../model/model";
4
4
  import { Size } from "../../../config/config";
@@ -1,7 +1,7 @@
1
- import { ValueFormatter, } from "../../valueFormatter";
2
- import { TooltipHelper } from './tooltipHelper';
3
- import { Helper } from '../../helpers/helper';
4
- import { getMarkerCreator } from '../legend/legendMarkerCreator';
1
+ import { ValueFormatter } from "../../valueFormatter";
2
+ import { TooltipHelper } from "./tooltipHelper";
3
+ import { Helper } from "../../helpers/helper";
4
+ import { getMarkerCreator } from "../legend/legendMarkerCreator";
5
5
  export const ARROW_SIZE = 20;
6
6
  export const ARROW_DEFAULT_POSITION = 9;
7
7
  export const TOOLTIP_ARROW_PADDING_X = ARROW_DEFAULT_POSITION - (ARROW_SIZE * Math.sqrt(2) - ARROW_SIZE) / 2 + 14;
@@ -9,7 +9,7 @@ export const TOOLTIP_ARROW_PADDING_Y = 13;
9
9
  export class TooltipDomHelper {
10
10
  static fillForMulti2DCharts(contentBlock, charts, data, dataOptions, keyValue, tooltipOptions) {
11
11
  const chartDataRows = [];
12
- charts.forEach(chart => {
12
+ charts.forEach((chart) => {
13
13
  chart.data.valueFields.forEach((field, index) => {
14
14
  chartDataRows.push({
15
15
  field,
@@ -21,11 +21,13 @@ export class TooltipDomHelper {
21
21
  this.fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions);
22
22
  }
23
23
  static fillForPolarChart(contentBlock, chart, data, dataOptions, keyValue, markColor, tooltipOptions) {
24
- const chartDataRows = [{
24
+ const chartDataRows = [
25
+ {
25
26
  field: chart.data.valueField,
26
27
  markColor,
27
28
  markerCreator: this.getMarkerCreator(chart.legend)
28
- }];
29
+ }
30
+ ];
29
31
  this.fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions);
30
32
  }
31
33
  static getRecalcedCoordinateByArrow(coordinate, tooltipBlock, blockSize, tooltipArrow, translateX = 0, translateY = 0) {
@@ -33,25 +35,25 @@ export class TooltipDomHelper {
33
35
  const horizontalPad = TooltipHelper.getHorizontalPad(coordinate[0], tooltipBlockNode.getBoundingClientRect().width, blockSize, translateX);
34
36
  const verticalPad = TooltipHelper.getVerticalPad(coordinate[1], tooltipBlockNode.getBoundingClientRect().height, translateY);
35
37
  this.setTooltipArrowCoordinate(tooltipArrow, TooltipHelper.getTooltipArrowPadding(tooltipBlockNode.getBoundingClientRect().width, horizontalPad));
36
- return [coordinate[0] - TOOLTIP_ARROW_PADDING_X - horizontalPad,
37
- coordinate[1] - TOOLTIP_ARROW_PADDING_Y - tooltipBlockNode.getBoundingClientRect().height - verticalPad];
38
+ return [
39
+ coordinate[0] - TOOLTIP_ARROW_PADDING_X - horizontalPad,
40
+ coordinate[1] - TOOLTIP_ARROW_PADDING_Y - tooltipBlockNode.getBoundingClientRect().height - verticalPad
41
+ ];
38
42
  }
39
43
  static renderHead(contentBlock, keyValue) {
40
- contentBlock.append('div')
41
- .attr('class', `${this.groupClass} ${this.headClass}`)
42
- .text(keyValue);
44
+ contentBlock.append("div").attr("class", `${this.groupClass} ${this.headClass}`).text(keyValue);
43
45
  }
44
46
  static fillValuesContent(contentBlock, { markColor, tooltipHtml, markerCreator }) {
45
- const group = contentBlock.append('div')
46
- .attr('class', this.groupClass);
47
+ const group = contentBlock.append("div").attr("class", this.groupClass);
47
48
  if (markColor) {
48
- const colorBlock = group.append('div').attr('class', 'tooltip-color');
49
+ const colorBlock = group.append("div").attr("class", "tooltip-color");
49
50
  markerCreator === null || markerCreator === void 0 ? void 0 : markerCreator.renderMarker(colorBlock, markColor);
50
51
  }
51
- group.append('div')
52
- .attr('class', 'tooltip-texts')
53
- .append('div')
54
- .attr('class', this.textItemClass)
52
+ group
53
+ .append("div")
54
+ .attr("class", "tooltip-texts")
55
+ .append("div")
56
+ .attr("class", this.textItemClass)
55
57
  .html(tooltipHtml);
56
58
  }
57
59
  static getTooltipItemHtml(row, valueField, tooltipOptions) {
@@ -70,18 +72,18 @@ export class TooltipDomHelper {
70
72
  }
71
73
  static setTooltipArrowCoordinate(tooltipArrow, horizontalPad) {
72
74
  if (horizontalPad !== 0)
73
- tooltipArrow.style('left', `${ARROW_DEFAULT_POSITION + Math.floor(horizontalPad)}px`);
75
+ tooltipArrow.style("left", `${ARROW_DEFAULT_POSITION + Math.floor(horizontalPad)}px`);
74
76
  else
75
- tooltipArrow.style('left', `${ARROW_DEFAULT_POSITION}px`);
77
+ tooltipArrow.style("left", `${ARROW_DEFAULT_POSITION}px`);
76
78
  }
77
79
  static fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler) {
78
80
  const row = Helper.getRowsByKeys([keyValue], dataOptions.keyField.name, data[dataOptions.dataSource])[0];
79
81
  contentBlock.html(htmlHandler(row));
80
82
  this.setWhiteSpaceForTextBlocks(contentBlock);
81
- contentBlock.selectAll('.tooltip-text-item').style('display', 'block');
83
+ contentBlock.selectAll(".tooltip-text-item").style("display", "block");
82
84
  }
83
85
  static setWhiteSpaceForTextBlocks(contentBlock) {
84
- contentBlock.selectAll(`.${this.textItemClass}`).style('white-space', 'pre-wrap');
86
+ contentBlock.selectAll(`.${this.textItemClass}`).style("white-space", "pre-wrap");
85
87
  }
86
88
  static getMarkerCreator(options) {
87
89
  return getMarkerCreator(options, { default: { cssClass: TooltipDomHelper.tooltipLegendDefaultMarker } });
@@ -89,19 +91,23 @@ export class TooltipDomHelper {
89
91
  static addAggregatorTooltipItem(tooltipOptions, data, tooltipItems) {
90
92
  if (tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.aggregator) {
91
93
  const aggregatorContent = tooltipOptions.aggregator.content({ row: data });
92
- const aggregatorHtml = aggregatorContent.type === 'plainText'
94
+ const aggregatorHtml = aggregatorContent.type === "plainText"
93
95
  ? aggregatorContent.textContent
94
96
  : this.getTooltipContentItemHtml(aggregatorContent.caption, aggregatorContent.value);
95
- const tooltipAggregatorItem = { markColor: undefined, tooltipHtml: aggregatorHtml, markerCreator: undefined };
96
- if (tooltipOptions.aggregator.position === 'underValues')
97
+ const tooltipAggregatorItem = {
98
+ markColor: undefined,
99
+ tooltipHtml: aggregatorHtml,
100
+ markerCreator: undefined
101
+ };
102
+ if (tooltipOptions.aggregator.position === "underValues")
97
103
  tooltipItems.push(tooltipAggregatorItem);
98
104
  else
99
105
  tooltipItems.unshift(tooltipAggregatorItem);
100
106
  }
101
107
  }
102
108
  static fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions) {
103
- const row = data[dataOptions.dataSource].find(d => d[dataOptions.keyField.name] === keyValue);
104
- contentBlock.html('');
109
+ const row = data[dataOptions.dataSource].find((d) => d[dataOptions.keyField.name] === keyValue);
110
+ contentBlock.html("");
105
111
  if (!(tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.html)) {
106
112
  const tooltipItems = [];
107
113
  this.renderHead(contentBlock, keyValue);
@@ -114,14 +120,16 @@ export class TooltipDomHelper {
114
120
  });
115
121
  });
116
122
  this.addAggregatorTooltipItem(tooltipOptions, row, tooltipItems);
117
- tooltipItems.forEach(item => { this.fillValuesContent(contentBlock, item); });
123
+ tooltipItems.forEach((item) => {
124
+ this.fillValuesContent(contentBlock, item);
125
+ });
118
126
  }
119
127
  else {
120
128
  this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, tooltipOptions.html);
121
129
  }
122
130
  }
123
131
  }
124
- TooltipDomHelper.groupClass = 'tooltip-group';
125
- TooltipDomHelper.headClass = 'tooltip-head';
126
- TooltipDomHelper.textItemClass = 'tooltip-text-item';
127
- TooltipDomHelper.tooltipLegendDefaultMarker = 'tooltip-circle';
132
+ TooltipDomHelper.groupClass = "tooltip-group";
133
+ TooltipDomHelper.headClass = "tooltip-head";
134
+ TooltipDomHelper.textItemClass = "tooltip-text-item";
135
+ TooltipDomHelper.tooltipLegendDefaultMarker = "tooltip-circle";
@@ -10,7 +10,8 @@ export class TooltipHelper {
10
10
  }
11
11
  static getVerticalPad(coordinateY, tooltipBlockHeight, translateY) {
12
12
  let pad = 0;
13
- if (coordinateY - TOOLTIP_ARROW_PADDING_Y - tooltipBlockHeight + translateY < -tooltipBlockHeight - TOOLTIP_ARROW_PADDING_Y)
13
+ if (coordinateY - TOOLTIP_ARROW_PADDING_Y - tooltipBlockHeight + translateY <
14
+ -tooltipBlockHeight - TOOLTIP_ARROW_PADDING_Y)
14
15
  pad = coordinateY;
15
16
  return pad; // return zero or sub zero
16
17
  }
@@ -26,8 +27,8 @@ export class TooltipHelper {
26
27
  right: null,
27
28
  bottom: null
28
29
  };
29
- coordinate.left = pointer[0] + 'px';
30
- coordinate.top = pointer[1] + 'px';
30
+ coordinate.left = pointer[0] + "px";
31
+ coordinate.top = pointer[1] + "px";
31
32
  return coordinate;
32
33
  }
33
34
  static getTooltipFixedCoordinate(scaleKey, margin, keyValue, blockBoundingRect, tooltipBoundingRect, keyAxisOrient, winWidth, winHeight) {
@@ -35,16 +36,16 @@ export class TooltipHelper {
35
36
  top: null,
36
37
  left: null
37
38
  };
38
- if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top') {
39
+ if (keyAxisOrient === "bottom" || keyAxisOrient === "top") {
39
40
  coordinate.left = Scale.getScaledValue(scaleKey, keyValue) + margin.left - tooltipBoundingRect.width / 2;
40
- if (keyAxisOrient === 'bottom')
41
+ if (keyAxisOrient === "bottom")
41
42
  coordinate.top = margin.top - 5 - tooltipBoundingRect.height;
42
43
  else
43
44
  coordinate.top = blockBoundingRect.height - margin.bottom;
44
45
  }
45
- if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
46
+ if (keyAxisOrient === "left" || keyAxisOrient === "right") {
46
47
  coordinate.top = Scale.getScaledValue(scaleKey, keyValue) + margin.top - tooltipBoundingRect.height / 2;
47
- if (keyAxisOrient === 'left')
48
+ if (keyAxisOrient === "left")
48
49
  coordinate.left = blockBoundingRect.width - margin.right;
49
50
  else
50
51
  coordinate.left = margin.left - tooltipBoundingRect.width;
@@ -61,9 +62,12 @@ export class TooltipHelper {
61
62
  }
62
63
  static getTooltipLineAttributes(scaleKey, margin, key, chartOrientation, blockSize) {
63
64
  const attributes = {
64
- x1: 0, x2: 0, y1: 0, y2: 0
65
+ x1: 0,
66
+ x2: 0,
67
+ y1: 0,
68
+ y2: 0
65
69
  };
66
- if (chartOrientation === 'vertical') {
70
+ if (chartOrientation === "vertical") {
67
71
  attributes.x1 = Math.ceil(Scale.getScaledValue(scaleKey, key) + margin.left) - 0.5;
68
72
  attributes.x2 = Math.ceil(Scale.getScaledValue(scaleKey, key) + margin.left) - 0.5;
69
73
  attributes.y1 = margin.top - this.convexsize;
@@ -83,8 +87,8 @@ export class TooltipHelper {
83
87
  height: winHeight
84
88
  }, blockBounding);
85
89
  return {
86
- left: res.left + 'px',
87
- top: res.top + 'px',
90
+ left: res.left + "px",
91
+ top: res.top + "px",
88
92
  right: null,
89
93
  bottom: null
90
94
  };