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,16 +1,16 @@
1
- import { select } from 'd3-selection';
1
+ import { select } from "d3-selection";
2
2
  import { EmbeddedLabels } from "../../features/embeddedLabels/embeddedLabels";
3
3
  import { EmbeddedLabelsHelper } from "../../features/embeddedLabels/embeddedLabelsHelper";
4
4
  import { BarHelper, onBarChartInit } from "./barHelper";
5
5
  import { sum } from "d3-array";
6
6
  import { DomHelper } from "../../helpers/domHelper";
7
7
  import { Helper } from "../../helpers/helper";
8
- import { getStackedDataWithOwn } from './stackedData/dataStacker';
9
- import { Pipeline } from '../../helpers/pipeline/Pipeline';
8
+ import { getStackedDataWithOwn } from "./stackedData/dataStacker";
9
+ import { Pipeline } from "../../helpers/pipeline/Pipeline";
10
10
  export class Bar {
11
11
  constructor() {
12
12
  this.barItemClass = Bar.barItemClass;
13
- this.barSegmentGroupClass = 'bar-segment-group';
13
+ this.barSegmentGroupClass = "bar-segment-group";
14
14
  this.createBarPipeline = new Pipeline();
15
15
  this.createSegmentGroupBarsPipeline = new Pipeline();
16
16
  onBarChartInit(this.createBarPipeline, this.createSegmentGroupBarsPipeline);
@@ -36,9 +36,10 @@ export class Bar {
36
36
  }
37
37
  updateColors(block, chart) {
38
38
  chart.data.valueFields.forEach((_vf, index) => {
39
- const bars = block.svg.getChartGroup(chart.index)
39
+ const bars = block.svg
40
+ .getChartGroup(chart.index)
40
41
  .selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}${Helper.getCssClassesLine(Helper.getCssClassesWithElementIndex(chart.cssClasses, index))}`);
41
- DomHelper.setChartStyle(bars, chart.style, index, 'fill');
42
+ DomHelper.setChartStyle(bars, chart.style, index, "fill");
42
43
  });
43
44
  }
44
45
  getAllBarsForChart(block, chartCssClasses) {
@@ -46,41 +47,39 @@ export class Bar {
46
47
  }
47
48
  renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart, barsAmounts, blockSize, barSettings) {
48
49
  chart.data.valueFields.forEach((field, index) => {
49
- let bars = block.svg.getChartGroup(chart.index)
50
+ let bars = block.svg
51
+ .getChartGroup(chart.index)
50
52
  .selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}${Helper.getCssClassesLine(Helper.getCssClassesWithElementIndex(chart.cssClasses, index))}`)
51
53
  .data(data)
52
54
  .enter()
53
- .append('rect')
54
- .attr('class', this.barItemClass)
55
- .style('clip-path', `url(#${block.svg.getClipPathId()})`);
55
+ .append("rect")
56
+ .attr("class", this.barItemClass)
57
+ .style("clip-path", `url(#${block.svg.getClipPathId()})`);
56
58
  bars = this.createBarPipeline.execute(bars, chart);
57
59
  const barAttrs = BarHelper.getGroupedBarAttrs(keyAxisOrient, scales, margin, keyField.name, field.name, chart.barViewOptions.barIndexes[index], sum(barsAmounts), barSettings);
58
60
  this.fillBarAttrs(bars, barAttrs);
59
61
  DomHelper.setCssClasses(bars, Helper.getCssClassesWithElementIndex(chart.cssClasses, index));
60
- DomHelper.setChartStyle(bars, chart.style, index, 'fill');
62
+ DomHelper.setChartStyle(bars, chart.style, index, "fill");
61
63
  this.setInitialAttrsInfo(bars, keyAxisOrient, barSettings);
62
- if (chart.embeddedLabels !== 'none')
64
+ if (chart.embeddedLabels !== "none")
63
65
  EmbeddedLabels.render(block, bars, barAttrs, EmbeddedLabelsHelper.getLabelField(chart.embeddedLabels, chart.data.valueFields, keyField, index), chart.embeddedLabels, keyAxisOrient, blockSize, margin, index, chart.cssClasses);
64
66
  });
65
67
  }
66
68
  renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart, barsAmounts, barSettings) {
67
- const stackedData = getStackedDataWithOwn(data, chart.data.valueFields.map(field => field.name));
68
- let groups = block.svg.getChartGroup(chart.index)
69
+ const stackedData = getStackedDataWithOwn(data, chart.data.valueFields.map((field) => field.name));
70
+ let groups = block.svg
71
+ .getChartGroup(chart.index)
69
72
  .selectAll(`g.${this.barSegmentGroupClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
70
73
  .data(stackedData);
71
74
  if (groups.empty())
72
- groups = groups
73
- .data(stackedData)
74
- .enter()
75
- .append('g')
76
- .attr('class', this.barSegmentGroupClass);
75
+ groups = groups.data(stackedData).enter().append("g").attr("class", this.barSegmentGroupClass);
77
76
  let bars = groups
78
77
  .selectAll(`rect${Helper.getCssClassesLine(chart.cssClasses)}`)
79
- .data(d => d)
78
+ .data((d) => d)
80
79
  .enter()
81
- .append('rect')
82
- .attr('class', this.barItemClass)
83
- .style('clip-path', `url(#${block.svg.getClipPathId()})`);
80
+ .append("rect")
81
+ .attr("class", this.barItemClass)
82
+ .style("clip-path", `url(#${block.svg.getClipPathId()})`);
84
83
  bars = this.createBarPipeline.execute(bars, chart);
85
84
  const barAttrs = BarHelper.getStackedBarAttr(keyAxisOrient, scales, margin, keyField.name, chart.barViewOptions.barIndexes[0], sum(barsAmounts), barSettings);
86
85
  this.fillBarAttrs(bars, barAttrs);
@@ -99,10 +98,11 @@ export class Bar {
99
98
  const promises = [];
100
99
  chart.data.valueFields.forEach((valueField, index) => {
101
100
  const indexesOfRemoved = [];
102
- block.svg.getChartGroup(chart.index)
101
+ block.svg
102
+ .getChartGroup(chart.index)
103
103
  .selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${index}`)
104
104
  .filter((d, i) => {
105
- if (newData.findIndex(row => row[keyField.name] === d[keyField.name]) === -1) {
105
+ if (newData.findIndex((row) => row[keyField.name] === d[keyField.name]) === -1) {
106
106
  indexesOfRemoved.push(i); // Набор индексов для встроенных лейблов
107
107
  return true;
108
108
  }
@@ -110,31 +110,31 @@ export class Bar {
110
110
  })
111
111
  .transition()
112
112
  .duration(block.transitionManager.durations.elementFadeOut)
113
- .style('opacity', 0)
113
+ .style("opacity", 0)
114
114
  .remove();
115
- const bars = block.svg.getChartGroup(chart.index)
115
+ const bars = block.svg
116
+ .getChartGroup(chart.index)
116
117
  .selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${index}`)
117
- .filter(d => newData.findIndex(row => row[keyField.name] === d[keyField.name]) !== -1)
118
- .style('opacity', 1)
118
+ .filter((d) => newData.findIndex((row) => row[keyField.name] === d[keyField.name]) !== -1)
119
+ .style("opacity", 1)
119
120
  .data(newData);
120
121
  let newBars = bars
121
122
  .enter()
122
- .append('rect')
123
- .attr('class', this.barItemClass)
124
- .style('clip-path', `url(#${block.svg.getClipPathId()})`);
123
+ .append("rect")
124
+ .attr("class", this.barItemClass)
125
+ .style("clip-path", `url(#${block.svg.getClipPathId()})`);
125
126
  newBars = this.createBarPipeline.execute(newBars, chart);
126
127
  const barAttrs = BarHelper.getGroupedBarAttrs(keyAxisOrient, scales, margin, keyField.name, valueField.name, chart.barViewOptions.barIndexes[index], sum(barsAmounts), barSettings);
127
- const prom = this.fillBarAttrs(bars, barAttrs, block.transitionManager.durations.chartUpdate)
128
- .then(() => {
129
- bars.style('opacity', null);
128
+ const prom = this.fillBarAttrs(bars, barAttrs, block.transitionManager.durations.chartUpdate).then(() => {
129
+ bars.style("opacity", null);
130
130
  this.setInitialAttrsInfo(bars, keyAxisOrient, barSettings);
131
131
  });
132
132
  this.fillBarAttrs(newBars, barAttrs);
133
133
  promises.push(prom);
134
134
  this.setInitialAttrsInfo(newBars, keyAxisOrient, barSettings);
135
135
  DomHelper.setCssClasses(newBars, Helper.getCssClassesWithElementIndex(chart.cssClasses, index));
136
- DomHelper.setChartStyle(newBars, chart.style, index, 'fill');
137
- if (chart.embeddedLabels !== 'none') {
136
+ DomHelper.setChartStyle(newBars, chart.style, index, "fill");
137
+ if (chart.embeddedLabels !== "none") {
138
138
  EmbeddedLabels.removeUnused(block, chart.cssClasses, index, indexesOfRemoved);
139
139
  EmbeddedLabels.update(block, bars, keyAxisOrient, barAttrs, margin, valueField, chart.embeddedLabels, blockSize, newData, index, chart.cssClasses);
140
140
  if (!newBars.empty())
@@ -145,32 +145,34 @@ export class Bar {
145
145
  return promises;
146
146
  }
147
147
  updateSegmented(block, newData, scales, margin, keyAxisOrient, chart, barsAmounts, keyField, barSettings) {
148
- const stackedData = getStackedDataWithOwn(newData, chart.data.valueFields.map(field => field.name));
149
- block.svg.getChartGroup(chart.index)
148
+ const stackedData = getStackedDataWithOwn(newData, chart.data.valueFields.map((field) => field.name));
149
+ block.svg
150
+ .getChartGroup(chart.index)
150
151
  .selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
151
- .filter(d => newData.findIndex(row => row[keyField.name] === d.data[keyField.name]) === -1)
152
+ .filter((d) => newData.findIndex((row) => row[keyField.name] === d.data[keyField.name]) === -1)
152
153
  .transition()
153
154
  .duration(block.transitionManager.durations.elementFadeOut)
154
- .style('opacity', 0)
155
+ .style("opacity", 0)
155
156
  .remove();
156
- const groups = block.svg.getChartGroup(chart.index)
157
+ const groups = block.svg
158
+ .getChartGroup(chart.index)
157
159
  .selectAll(`g.${this.barSegmentGroupClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
158
160
  .data(stackedData);
159
161
  const bars = groups
160
162
  .selectAll(`.${this.barItemClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
161
- .filter(d => newData.findIndex(row => row[keyField.name] === d.data[keyField.name]) !== -1)
162
- .style('opacity', 1)
163
- .data(d => d);
164
- let newBars = bars.enter()
165
- .append('rect')
166
- .attr('class', this.barItemClass)
167
- .style('clip-path', `url(#${block.svg.getClipPathId()})`);
163
+ .filter((d) => newData.findIndex((row) => row[keyField.name] === d.data[keyField.name]) !== -1)
164
+ .style("opacity", 1)
165
+ .data((d) => d);
166
+ let newBars = bars
167
+ .enter()
168
+ .append("rect")
169
+ .attr("class", this.barItemClass)
170
+ .style("clip-path", `url(#${block.svg.getClipPathId()})`);
168
171
  newBars = this.createBarPipeline.execute(newBars, chart);
169
172
  const barAttrs = BarHelper.getStackedBarAttr(keyAxisOrient, scales, margin, keyField.name, chart.barViewOptions.barIndexes[0], sum(barsAmounts), barSettings);
170
- const prom = this.fillBarAttrs(bars, barAttrs, block.transitionManager.durations.chartUpdate)
171
- .then(() => {
173
+ const prom = this.fillBarAttrs(bars, barAttrs, block.transitionManager.durations.chartUpdate).then(() => {
172
174
  this.setInitialAttrsInfo(bars, keyAxisOrient, barSettings);
173
- bars.style('opacity', null);
175
+ bars.style("opacity", null);
174
176
  });
175
177
  this.fillBarAttrs(newBars, barAttrs);
176
178
  this.setInitialAttrsInfo(newBars, keyAxisOrient, barSettings);
@@ -187,7 +189,7 @@ export class Bar {
187
189
  fillBarAttrs(bars, barAttrs, transitionDuration = 0) {
188
190
  return new Promise((resolve) => {
189
191
  if (bars.size() === 0) {
190
- resolve('');
192
+ resolve("");
191
193
  return;
192
194
  }
193
195
  let barsHandler = bars;
@@ -196,32 +198,33 @@ export class Bar {
196
198
  .interrupt()
197
199
  .transition()
198
200
  .duration(transitionDuration)
199
- .on('end', () => resolve(''));
201
+ .on("end", () => resolve(""));
200
202
  }
201
- barsHandler.attr('x', d => barAttrs.x(d))
202
- .attr('y', d => barAttrs.y(d))
203
- .attr('height', d => barAttrs.height(d))
204
- .attr('width', d => barAttrs.width(d));
203
+ barsHandler
204
+ .attr("x", (d) => barAttrs.x(d))
205
+ .attr("y", (d) => barAttrs.y(d))
206
+ .attr("height", (d) => barAttrs.height(d))
207
+ .attr("width", (d) => barAttrs.width(d));
205
208
  if (transitionDuration <= 0)
206
- resolve('');
209
+ resolve("");
207
210
  });
208
211
  }
209
212
  setSegmentColor(segments, colorPalette, segmentedIndex) {
210
- segments.style('fill', colorPalette[segmentedIndex % colorPalette.length]);
213
+ segments.style("fill", colorPalette[segmentedIndex % colorPalette.length]);
211
214
  }
212
215
  /**
213
216
  * Устнановка координат для удобного обновления.
214
217
  */
215
218
  setInitialAttrsInfo(bars, keyAxisOrient, barSettings) {
216
219
  bars.each(function () {
217
- const width = DomHelper.getSelectionNumericAttr(select(this), 'width');
218
- const height = DomHelper.getSelectionNumericAttr(select(this), 'height');
219
- const orient = keyAxisOrient === 'left' || keyAxisOrient === 'right' ? 'horizontal' : 'vertical';
220
- let scaleSize = 0.06 * (orient === 'vertical' ? width : height);
220
+ const width = DomHelper.getSelectionNumericAttr(select(this), "width");
221
+ const height = DomHelper.getSelectionNumericAttr(select(this), "height");
222
+ const orient = keyAxisOrient === "left" || keyAxisOrient === "right" ? "horizontal" : "vertical";
223
+ let scaleSize = 0.06 * (orient === "vertical" ? width : height);
221
224
  scaleSize = scaleSize > barSettings.barDistance / 2 ? barSettings.barDistance / 2 : scaleSize;
222
225
  this.attrs = {
223
- x: DomHelper.getSelectionNumericAttr(select(this), 'x'),
224
- y: DomHelper.getSelectionNumericAttr(select(this), 'y'),
226
+ x: DomHelper.getSelectionNumericAttr(select(this), "x"),
227
+ y: DomHelper.getSelectionNumericAttr(select(this), "y"),
225
228
  width,
226
229
  height,
227
230
  orient,
@@ -230,4 +233,4 @@ export class Bar {
230
233
  });
231
234
  }
232
235
  }
233
- Bar.barItemClass = 'bar-item';
236
+ Bar.barItemClass = "bar-item";
@@ -22,12 +22,13 @@ export class BarSettingsStore {
22
22
  return barSize;
23
23
  }
24
24
  getBandItemPad(barIndex) {
25
- const barDiff = (this.getBarStep() - this.getBandItemSize()) * this.canvasConfig.barsAmount / 2; // if bar bigger than maxWidth, diff for x coordinate
25
+ const barDiff = ((this.getBarStep() - this.getBandItemSize()) * this.canvasConfig.barsAmount) / 2; // if bar bigger than maxWidth, diff for x coordinate
26
26
  const barPad = this.getBandItemSize() * barIndex + this.modelSettings.barDistance * barIndex + barDiff; // Отступ бара от края. Зависит от количества баров в одной группе и порядке текущего бара
27
27
  return barPad;
28
28
  }
29
29
  getBarStep() {
30
- return (this.canvasConfig.scaleBandWidth - this.modelSettings.barDistance * (this.canvasConfig.barsAmount - 1)) / this.canvasConfig.barsAmount; // Space for one bar
30
+ return ((this.canvasConfig.scaleBandWidth - this.modelSettings.barDistance * (this.canvasConfig.barsAmount - 1)) /
31
+ this.canvasConfig.barsAmount); // Space for one bar
31
32
  }
32
33
  }
33
34
  export class BarHelper {
@@ -56,65 +57,69 @@ export class BarHelper {
56
57
  static getBarsInGroupAmount(charts) {
57
58
  let amounts = [];
58
59
  charts.forEach((chart) => {
59
- if (chart.type === 'bar' && chart.isSegmented)
60
+ if (chart.type === "bar" && chart.isSegmented)
60
61
  amounts.push(1); // Сегментированный бар содержит все свои valueFields в одном баре
61
- else if (chart.type === 'bar')
62
+ else if (chart.type === "bar")
62
63
  amounts.push(chart.data.valueFields.length);
63
64
  });
64
65
  return amounts;
65
66
  }
66
67
  static setBarAttrsByKey(attrs, keyAxisOrient, scaleKey, margin, keyField, barIndex, settingsStore, isSegmented) {
67
- if (keyAxisOrient === 'top' || keyAxisOrient === 'bottom') {
68
- attrs.x = d => scaleKey(Helper.getKeyFieldValue(d, keyField, isSegmented)) + margin.left + settingsStore.getBandItemPad(barIndex);
69
- attrs.width = d => settingsStore.getBandItemSize();
68
+ if (keyAxisOrient === "top" || keyAxisOrient === "bottom") {
69
+ attrs.x = (d) => scaleKey(Helper.getKeyFieldValue(d, keyField, isSegmented)) +
70
+ margin.left +
71
+ settingsStore.getBandItemPad(barIndex);
72
+ attrs.width = (d) => settingsStore.getBandItemSize();
70
73
  }
71
- if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
72
- attrs.y = d => scaleKey(Helper.getKeyFieldValue(d, keyField, isSegmented)) + margin.top + settingsStore.getBandItemPad(barIndex);
73
- attrs.height = d => settingsStore.getBandItemSize();
74
+ if (keyAxisOrient === "left" || keyAxisOrient === "right") {
75
+ attrs.y = (d) => scaleKey(Helper.getKeyFieldValue(d, keyField, isSegmented)) +
76
+ margin.top +
77
+ settingsStore.getBandItemPad(barIndex);
78
+ attrs.height = (d) => settingsStore.getBandItemSize();
74
79
  }
75
80
  }
76
81
  static setGroupedBarAttrsByValue(attrs, keyAxisOrient, margin, scaleValue, valueFieldName) {
77
82
  this.setGroupedBandStartCoordinateAttr(attrs, keyAxisOrient, scaleValue, margin, valueFieldName);
78
- if (keyAxisOrient === 'top' || keyAxisOrient === 'bottom') {
83
+ if (keyAxisOrient === "top" || keyAxisOrient === "bottom") {
79
84
  attrs.height = this.getBandItemValueStretch(scaleValue, valueFieldName);
80
85
  }
81
- if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
86
+ if (keyAxisOrient === "left" || keyAxisOrient === "right") {
82
87
  attrs.width = this.getBandItemValueStretch(scaleValue, valueFieldName);
83
88
  }
84
89
  }
85
90
  static getBandItemValueStretch(scaleValue, valueFieldName) {
86
- return d => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
91
+ return (d) => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
87
92
  }
88
93
  static setGroupedBandStartCoordinateAttr(attrs, keyAxisOrient, scaleValue, margin, valueFieldName) {
89
- if (keyAxisOrient === 'top') {
90
- attrs.y = d => scaleValue(Math.min(d[valueFieldName], 0)) + margin.top;
94
+ if (keyAxisOrient === "top") {
95
+ attrs.y = (d) => scaleValue(Math.min(d[valueFieldName], 0)) + margin.top;
91
96
  }
92
- if (keyAxisOrient === 'bottom') {
93
- attrs.y = d => scaleValue(Math.max(d[valueFieldName], 0)) + margin.top;
97
+ if (keyAxisOrient === "bottom") {
98
+ attrs.y = (d) => scaleValue(Math.max(d[valueFieldName], 0)) + margin.top;
94
99
  }
95
- if (keyAxisOrient === 'left') {
96
- attrs.x = d => scaleValue(Math.min(d[valueFieldName], 0)) + margin.left;
100
+ if (keyAxisOrient === "left") {
101
+ attrs.x = (d) => scaleValue(Math.min(d[valueFieldName], 0)) + margin.left;
97
102
  }
98
- if (keyAxisOrient === 'right') {
99
- attrs.x = d => scaleValue(Math.max(d[valueFieldName], 0)) + margin.left;
103
+ if (keyAxisOrient === "right") {
104
+ attrs.x = (d) => scaleValue(Math.max(d[valueFieldName], 0)) + margin.left;
100
105
  }
101
106
  }
102
107
  static setSegmentedBarAttrsByValue(attrs, keyAxisOrient, scaleValue, margin) {
103
- if (keyAxisOrient === 'top') {
104
- attrs.y = d => scaleValue(Math.min(d[1], d[0])) + margin.top;
105
- attrs.height = d => Math.abs(scaleValue(d[1]) - scaleValue(d[0]));
108
+ if (keyAxisOrient === "top") {
109
+ attrs.y = (d) => scaleValue(Math.min(d[1], d[0])) + margin.top;
110
+ attrs.height = (d) => Math.abs(scaleValue(d[1]) - scaleValue(d[0]));
106
111
  }
107
- if (keyAxisOrient === 'bottom') {
108
- attrs.y = d => scaleValue(Math.max(d[1], d[0])) + margin.top;
109
- attrs.height = d => Math.abs(scaleValue(d[1]) - scaleValue(d[0]));
112
+ if (keyAxisOrient === "bottom") {
113
+ attrs.y = (d) => scaleValue(Math.max(d[1], d[0])) + margin.top;
114
+ attrs.height = (d) => Math.abs(scaleValue(d[1]) - scaleValue(d[0]));
110
115
  }
111
- if (keyAxisOrient === 'left') {
112
- attrs.x = d => scaleValue(Math.min(d[1], d[0])) + margin.left;
113
- attrs.width = d => Math.abs(scaleValue(d[1]) - scaleValue(d[0]));
116
+ if (keyAxisOrient === "left") {
117
+ attrs.x = (d) => scaleValue(Math.min(d[1], d[0])) + margin.left;
118
+ attrs.width = (d) => Math.abs(scaleValue(d[1]) - scaleValue(d[0]));
114
119
  }
115
- if (keyAxisOrient === 'right') {
116
- attrs.x = d => scaleValue(Math.max(d[1], d[0])) + margin.left;
117
- attrs.width = d => Math.abs(scaleValue(d[1]) - scaleValue(d[0]));
120
+ if (keyAxisOrient === "right") {
121
+ attrs.x = (d) => scaleValue(Math.max(d[1], d[0])) + margin.left;
122
+ attrs.width = (d) => Math.abs(scaleValue(d[1]) - scaleValue(d[0]));
118
123
  }
119
124
  }
120
125
  }
@@ -125,10 +130,10 @@ export function onBarChartInit(createBarPipeline, createSegmentGroupBarsPipeline
125
130
  }
126
131
  function roundSegmentedBars(bars, segment) {
127
132
  const radiusValues = segment.chart.barViewOptions.borderRadius.segmented.handle(segment.segmentIndex);
128
- return bars.style('clip-path', getClipPathValue(radiusValues));
133
+ return bars.style("clip-path", getClipPathValue(radiusValues));
129
134
  }
130
135
  function roundGroupedBars(bars, chart) {
131
- return bars.style('clip-path', getClipPathValue(chart.barViewOptions.borderRadius.grouped));
136
+ return bars.style("clip-path", getClipPathValue(chart.barViewOptions.borderRadius.grouped));
132
137
  }
133
138
  export function getClipPathValue({ topLeft, topRight, bottomLeft, bottomRight }) {
134
139
  return `inset(0px round ${topLeft}px ${topRight}px ${bottomRight}px ${bottomLeft}px)`;
@@ -16,53 +16,59 @@ export class CanvasDotChart {
16
16
  if (this.renderedChart)
17
17
  return;
18
18
  const valueFieldIndex = 0;
19
- const elements = this.options.elementAccessors.getBlock().svg.getChartGroup(chart.index)
19
+ const elements = this.options.elementAccessors
20
+ .getBlock()
21
+ .svg.getChartGroup(chart.index)
20
22
  .selectAll(`.${this.dotChartItemClass}${Helper.getCssClassesLine(chart.cssClasses)}${Helper.getCssClassesLine(Helper.getCssClassesWithElementIndex(chart.cssClasses, valueFieldIndex))}`)
21
23
  .data(records)
22
24
  .enter()
23
- .append('line')
25
+ .append("line")
24
26
  .style("stroke-width", chart.dotViewOptions.shape.width)
25
- .attr('class', this.dotChartItemClass);
27
+ .attr("class", this.dotChartItemClass);
26
28
  const attrs = this.getAttrs(scales, chart, chart.data.valueFields[0], margin);
27
- elements.attr('x1', d => attrs.x1(d))
28
- .attr('y1', d => attrs.y1(d))
29
- .attr('x2', d => attrs.x2(d))
30
- .attr('y2', d => attrs.y2(d));
29
+ elements
30
+ .attr("x1", (d) => attrs.x1(d))
31
+ .attr("y1", (d) => attrs.y1(d))
32
+ .attr("x2", (d) => attrs.x2(d))
33
+ .attr("y2", (d) => attrs.y2(d));
31
34
  DomHelper.setCssClasses(elements, Helper.getCssClassesWithElementIndex(chart.cssClasses, valueFieldIndex));
32
- DomHelper.setChartStyle(elements, chart.style, valueFieldIndex, 'stroke');
35
+ DomHelper.setChartStyle(elements, chart.style, valueFieldIndex, "stroke");
33
36
  this.renderedChart = chart;
34
37
  }
35
38
  update(scales, newRecords, margin) {
36
39
  if (!this.renderedChart)
37
40
  return;
38
41
  const valueFieldIndex = 0;
39
- const elements = this.options.elementAccessors.getBlock().svg.getChartGroup(this.renderedChart.index)
42
+ const elements = this.options.elementAccessors
43
+ .getBlock()
44
+ .svg.getChartGroup(this.renderedChart.index)
40
45
  .selectAll(`.${this.dotChartItemClass}${Helper.getCssClassesLine(this.renderedChart.cssClasses)}${Helper.getCssClassesLine(Helper.getCssClassesWithElementIndex(this.renderedChart.cssClasses, valueFieldIndex))}`)
41
46
  .data(newRecords);
42
47
  elements.exit().remove();
43
48
  const newElements = elements
44
49
  .enter()
45
- .append('line')
50
+ .append("line")
46
51
  .style("stroke-width", this.renderedChart.dotViewOptions.shape.width)
47
- .attr('class', this.dotChartItemClass);
52
+ .attr("class", this.dotChartItemClass);
48
53
  const attrs = this.getAttrs(scales, this.renderedChart, this.renderedChart.data.valueFields[0], margin);
49
- newElements.attr('x1', d => attrs.x1(d))
50
- .attr('y1', d => attrs.y1(d))
51
- .attr('x2', d => attrs.x2(d))
52
- .attr('y2', d => attrs.y2(d));
54
+ newElements
55
+ .attr("x1", (d) => attrs.x1(d))
56
+ .attr("y1", (d) => attrs.y1(d))
57
+ .attr("x2", (d) => attrs.x2(d))
58
+ .attr("y2", (d) => attrs.y2(d));
53
59
  DomHelper.setCssClasses(newElements, Helper.getCssClassesWithElementIndex(this.renderedChart.cssClasses, valueFieldIndex));
54
- DomHelper.setChartStyle(newElements, this.renderedChart.style, valueFieldIndex, 'stroke');
60
+ DomHelper.setChartStyle(newElements, this.renderedChart.style, valueFieldIndex, "stroke");
55
61
  return [
56
- new Promise(resolve => {
62
+ new Promise((resolve) => {
57
63
  elements
58
64
  .interrupt()
59
65
  .transition()
60
66
  .duration(this.options.elementAccessors.getBlock().transitionManager.durations.chartUpdate)
61
- .attr('x1', d => attrs.x1(d))
62
- .attr('y1', d => attrs.y1(d))
63
- .attr('x2', d => attrs.x2(d))
64
- .attr('y2', d => attrs.y2(d))
65
- .on('end', () => resolve());
67
+ .attr("x1", (d) => attrs.x1(d))
68
+ .attr("y1", (d) => attrs.y1(d))
69
+ .attr("x2", (d) => attrs.x2(d))
70
+ .attr("y2", (d) => attrs.y2(d))
71
+ .on("end", () => resolve());
66
72
  })
67
73
  ];
68
74
  }
@@ -75,31 +81,43 @@ export class CanvasDotChart {
75
81
  };
76
82
  const settingsStore = new DotChartSettingsStore({ scaleBandWidth: Scale.getScaleBandWidth(scales.key) });
77
83
  // TODO: refactor
78
- if (this.options.canvas.keyAxisOrient === 'top' || this.options.canvas.keyAxisOrient === 'bottom') {
79
- const handleBase = d => scales.key(Helper.getKeyFieldValue(d, this.options.dataOptions.keyFieldName, false)) + margin.left + settingsStore.getBandItemPad();
80
- attrs.x1 = d => chart.dotViewOptions.shape.handleStartCoordinate(handleBase(d));
81
- attrs.x2 = d => chart.dotViewOptions.shape.handleEndCoordinate(handleBase(d) + settingsStore.getBandItemSize());
84
+ if (this.options.canvas.keyAxisOrient === "top" || this.options.canvas.keyAxisOrient === "bottom") {
85
+ const handleBase = (d) => scales.key(Helper.getKeyFieldValue(d, this.options.dataOptions.keyFieldName, false)) +
86
+ margin.left +
87
+ settingsStore.getBandItemPad();
88
+ attrs.x1 = (d) => chart.dotViewOptions.shape.handleStartCoordinate(handleBase(d));
89
+ attrs.x2 = (d) => chart.dotViewOptions.shape.handleEndCoordinate(handleBase(d) + settingsStore.getBandItemSize());
82
90
  }
83
- if (this.options.canvas.keyAxisOrient === 'left' || this.options.canvas.keyAxisOrient === 'right') {
84
- const handleBase = d => scales.key(Helper.getKeyFieldValue(d, this.options.dataOptions.keyFieldName, false)) + margin.top + settingsStore.getBandItemPad();
85
- attrs.y1 = d => chart.dotViewOptions.shape.handleStartCoordinate(handleBase(d));
86
- attrs.y2 = d => chart.dotViewOptions.shape.handleEndCoordinate(handleBase(d) + settingsStore.getBandItemSize());
91
+ if (this.options.canvas.keyAxisOrient === "left" || this.options.canvas.keyAxisOrient === "right") {
92
+ const handleBase = (d) => scales.key(Helper.getKeyFieldValue(d, this.options.dataOptions.keyFieldName, false)) +
93
+ margin.top +
94
+ settingsStore.getBandItemPad();
95
+ attrs.y1 = (d) => chart.dotViewOptions.shape.handleStartCoordinate(handleBase(d));
96
+ attrs.y2 = (d) => chart.dotViewOptions.shape.handleEndCoordinate(handleBase(d) + settingsStore.getBandItemSize());
87
97
  }
88
- if (this.options.canvas.keyAxisOrient === 'top') {
89
- attrs.y1 = d => scales.value(Math.min(d[field.name], 0)) + margin.top + BarHelper.getBandItemValueStretch(scales.value, field.name)(d);
90
- attrs.y2 = d => scales.value(Math.min(d[field.name], 0)) + margin.top + BarHelper.getBandItemValueStretch(scales.value, field.name)(d);
98
+ if (this.options.canvas.keyAxisOrient === "top") {
99
+ attrs.y1 = (d) => scales.value(Math.min(d[field.name], 0)) +
100
+ margin.top +
101
+ BarHelper.getBandItemValueStretch(scales.value, field.name)(d);
102
+ attrs.y2 = (d) => scales.value(Math.min(d[field.name], 0)) +
103
+ margin.top +
104
+ BarHelper.getBandItemValueStretch(scales.value, field.name)(d);
91
105
  }
92
- if (this.options.canvas.keyAxisOrient === 'bottom') {
93
- attrs.y1 = d => scales.value(Math.max(d[field.name], 0)) + margin.top;
94
- attrs.y2 = d => scales.value(Math.max(d[field.name], 0)) + margin.top;
106
+ if (this.options.canvas.keyAxisOrient === "bottom") {
107
+ attrs.y1 = (d) => scales.value(Math.max(d[field.name], 0)) + margin.top;
108
+ attrs.y2 = (d) => scales.value(Math.max(d[field.name], 0)) + margin.top;
95
109
  }
96
- if (this.options.canvas.keyAxisOrient === 'left') {
97
- attrs.x1 = d => scales.value(Math.min(d[field.name], 0)) + margin.left + BarHelper.getBandItemValueStretch(scales.value, field.name)(d);
98
- attrs.x2 = d => scales.value(Math.min(d[field.name], 0)) + margin.left + BarHelper.getBandItemValueStretch(scales.value, field.name)(d);
110
+ if (this.options.canvas.keyAxisOrient === "left") {
111
+ attrs.x1 = (d) => scales.value(Math.min(d[field.name], 0)) +
112
+ margin.left +
113
+ BarHelper.getBandItemValueStretch(scales.value, field.name)(d);
114
+ attrs.x2 = (d) => scales.value(Math.min(d[field.name], 0)) +
115
+ margin.left +
116
+ BarHelper.getBandItemValueStretch(scales.value, field.name)(d);
99
117
  }
100
- if (this.options.canvas.keyAxisOrient === 'right') {
101
- attrs.x1 = d => scales.value(Math.max(d[field.name], 0)) + margin.left;
102
- attrs.x2 = d => scales.value(Math.max(d[field.name], 0)) + margin.left;
118
+ if (this.options.canvas.keyAxisOrient === "right") {
119
+ attrs.x1 = (d) => scales.value(Math.max(d[field.name], 0)) + margin.left;
120
+ attrs.x2 = (d) => scales.value(Math.max(d[field.name], 0)) + margin.left;
103
121
  }
104
122
  return attrs;
105
123
  }
@@ -14,18 +14,18 @@ class TwoDimRecordOverflowAlertClass {
14
14
  };
15
15
  }
16
16
  getText(chartOrientation) {
17
- const isHorizontal = chartOrientation === 'horizontal';
17
+ const isHorizontal = chartOrientation === "horizontal";
18
18
  return {
19
- one: isHorizontal ? 'строка' : 'столбец',
20
- twoToFour: isHorizontal ? 'строки' : 'столбца',
21
- tenToTwenty: isHorizontal ? 'строк' : 'столбцов',
22
- other: isHorizontal ? 'строк' : 'столбцов'
19
+ one: isHorizontal ? "строка" : "столбец",
20
+ twoToFour: isHorizontal ? "строки" : "столбца",
21
+ tenToTwenty: isHorizontal ? "строк" : "столбцов",
22
+ other: isHorizontal ? "строк" : "столбцов"
23
23
  };
24
24
  }
25
25
  getPositionAttrs() {
26
26
  return {
27
- right: '0px',
28
- top: '0px'
27
+ right: "0px",
28
+ top: "0px"
29
29
  };
30
30
  }
31
31
  }
@@ -1,10 +1,10 @@
1
- import { Line as ILine } from 'd3-shape';
2
- import { BaseType, Selection } from 'd3-selection';
1
+ import { Line as ILine } from "d3-shape";
2
+ import { BaseType, Selection } from "d3-selection";
3
3
  import { BlockMargin, Field, LineLikeChartSettings, Orient, TwoDimensionalChartModel } from "../../../model/model";
4
4
  import { Scales } from "../../features/scale/scale";
5
5
  import { Block } from "../../block/block";
6
- import { MdtChartsDataRow } from '../../../config/config';
7
- import { Pipeline } from '../../helpers/pipeline/Pipeline';
6
+ import { MdtChartsDataRow } from "../../../config/config";
7
+ import { Pipeline } from "../../helpers/pipeline/Pipeline";
8
8
  interface LineChartOptions {
9
9
  staticSettings: LineLikeChartSettings;
10
10
  }