mdt-charts 1.9.7 → 1.9.11

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 (150) hide show
  1. package/README.md +190 -190
  2. package/dist/index.html +363 -48
  3. package/dist/listeners.89e1e272264c0e680de8.js +278 -0
  4. package/dist/main.f8b6bc6fee33cef1116c.js +228 -0
  5. package/dist/src_engine_engine_ts.ccee2a280374e0083541.js +759 -0
  6. package/dist/vendors-node_modules_chroma-js_chroma_js-node_modules_d3-array_src_max_js-node_modules_d3-arr-c3fc24.b32acc465b8557229277.js +1869 -0
  7. package/package.json +57 -57
  8. package/dist/bundle.js +0 -2
  9. package/dist/bundle.js.LICENSE.txt +0 -56
  10. package/lib/config/config.d.ts +0 -146
  11. package/lib/config/config.js +0 -1
  12. package/lib/designer/designerConfig.d.ts +0 -71
  13. package/lib/designer/designerConfig.js +0 -1
  14. package/lib/engine/block/block.d.ts +0 -35
  15. package/lib/engine/block/block.js +0 -110
  16. package/lib/engine/block/blockHelper.d.ts +0 -12
  17. package/lib/engine/block/blockHelper.js +0 -19
  18. package/lib/engine/contentManager.d.ts +0 -9
  19. package/lib/engine/contentManager.js +0 -29
  20. package/lib/engine/elementHighlighter/elementHighlighter.d.ts +0 -30
  21. package/lib/engine/elementHighlighter/elementHighlighter.js +0 -197
  22. package/lib/engine/elementHighlighter/selectHighlighter.d.ts +0 -11
  23. package/lib/engine/elementHighlighter/selectHighlighter.js +0 -95
  24. package/lib/engine/engine.d.ts +0 -20
  25. package/lib/engine/engine.js +0 -64
  26. package/lib/engine/features/aggregator/aggregator.d.ts +0 -22
  27. package/lib/engine/features/aggregator/aggregator.js +0 -95
  28. package/lib/engine/features/axis/axis.d.ts +0 -12
  29. package/lib/engine/features/axis/axis.js +0 -118
  30. package/lib/engine/features/axis/axisDomHelper.d.ts +0 -7
  31. package/lib/engine/features/axis/axisDomHelper.js +0 -24
  32. package/lib/engine/features/axis/axisHelper.d.ts +0 -9
  33. package/lib/engine/features/axis/axisHelper.js +0 -53
  34. package/lib/engine/features/axis/axisLabelDomHelper.d.ts +0 -17
  35. package/lib/engine/features/axis/axisLabelDomHelper.js +0 -143
  36. package/lib/engine/features/axis/axisLabelsEventManager.d.ts +0 -6
  37. package/lib/engine/features/axis/axisLabelsEventManager.js +0 -36
  38. package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +0 -23
  39. package/lib/engine/features/embeddedLabels/embeddedLabels.js +0 -147
  40. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +0 -8
  41. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +0 -30
  42. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +0 -27
  43. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +0 -65
  44. package/lib/engine/features/gridLine/gidLineHelper.d.ts +0 -13
  45. package/lib/engine/features/gridLine/gidLineHelper.js +0 -30
  46. package/lib/engine/features/gridLine/gridLine.d.ts +0 -11
  47. package/lib/engine/features/gridLine/gridLine.js +0 -67
  48. package/lib/engine/features/legend/legend.d.ts +0 -22
  49. package/lib/engine/features/legend/legend.js +0 -109
  50. package/lib/engine/features/legend/legendDomHelper.d.ts +0 -8
  51. package/lib/engine/features/legend/legendDomHelper.js +0 -48
  52. package/lib/engine/features/legend/legendEventsManager.d.ts +0 -12
  53. package/lib/engine/features/legend/legendEventsManager.js +0 -47
  54. package/lib/engine/features/legend/legendHelper.d.ts +0 -21
  55. package/lib/engine/features/legend/legendHelper.js +0 -97
  56. package/lib/engine/features/markDots/markDot.d.ts +0 -20
  57. package/lib/engine/features/markDots/markDot.js +0 -68
  58. package/lib/engine/features/markDots/markDotsHelper.d.ts +0 -6
  59. package/lib/engine/features/markDots/markDotsHelper.js +0 -16
  60. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
  61. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
  62. package/lib/engine/features/scale/scale.d.ts +0 -16
  63. package/lib/engine/features/scale/scale.js +0 -74
  64. package/lib/engine/features/tipBox/tipBox.d.ts +0 -11
  65. package/lib/engine/features/tipBox/tipBox.js +0 -32
  66. package/lib/engine/features/tipBox/tipBoxHelper.d.ts +0 -16
  67. package/lib/engine/features/tipBox/tipBoxHelper.js +0 -48
  68. package/lib/engine/features/title/title.d.ts +0 -9
  69. package/lib/engine/features/title/title.js +0 -35
  70. package/lib/engine/features/tolltip/tooltip.d.ts +0 -19
  71. package/lib/engine/features/tolltip/tooltip.js +0 -180
  72. package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +0 -17
  73. package/lib/engine/features/tolltip/tooltipComponentsManager.js +0 -127
  74. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +0 -36
  75. package/lib/engine/features/tolltip/tooltipDomHelper.js +0 -114
  76. package/lib/engine/features/tolltip/tooltipHelper.d.ts +0 -16
  77. package/lib/engine/features/tolltip/tooltipHelper.js +0 -99
  78. package/lib/engine/filterManager/filterEventManager.d.ts +0 -33
  79. package/lib/engine/filterManager/filterEventManager.js +0 -127
  80. package/lib/engine/helpers/domHelper.d.ts +0 -30
  81. package/lib/engine/helpers/domHelper.js +0 -68
  82. package/lib/engine/helpers/helper.d.ts +0 -30
  83. package/lib/engine/helpers/helper.js +0 -89
  84. package/lib/engine/helpers/namesHelper.d.ts +0 -5
  85. package/lib/engine/helpers/namesHelper.js +0 -9
  86. package/lib/engine/intervalNotation/gantt.d.ts +0 -10
  87. package/lib/engine/intervalNotation/gantt.js +0 -62
  88. package/lib/engine/intervalNotation/intervalManager.d.ts +0 -7
  89. package/lib/engine/intervalNotation/intervalManager.js +0 -30
  90. package/lib/engine/polarNotation/donut/DonutHelper.d.ts +0 -15
  91. package/lib/engine/polarNotation/donut/DonutHelper.js +0 -58
  92. package/lib/engine/polarNotation/donut/donut.d.ts +0 -32
  93. package/lib/engine/polarNotation/donut/donut.js +0 -124
  94. package/lib/engine/polarNotation/polarManager.d.ts +0 -10
  95. package/lib/engine/polarNotation/polarManager.js +0 -55
  96. package/lib/engine/transitionManager.d.ts +0 -19
  97. package/lib/engine/transitionManager.js +0 -64
  98. package/lib/engine/twoDimensionalNotation/area/area.d.ts +0 -17
  99. package/lib/engine/twoDimensionalNotation/area/area.js +0 -131
  100. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +0 -9
  101. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +0 -40
  102. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +0 -34
  103. package/lib/engine/twoDimensionalNotation/bar/bar.js +0 -216
  104. package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +0 -24
  105. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +0 -103
  106. package/lib/engine/twoDimensionalNotation/line/line.d.ts +0 -17
  107. package/lib/engine/twoDimensionalNotation/line/line.js +0 -132
  108. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +0 -8
  109. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +0 -28
  110. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +0 -11
  111. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +0 -101
  112. package/lib/engine/valueFormatter.d.ts +0 -6
  113. package/lib/engine/valueFormatter.js +0 -8
  114. package/lib/main.d.ts +0 -79
  115. package/lib/main.js +0 -85
  116. package/lib/model/chartStyleModel.d.ts +0 -16
  117. package/lib/model/chartStyleModel.js +0 -67
  118. package/lib/model/dataManagerModel.d.ts +0 -22
  119. package/lib/model/dataManagerModel.js +0 -137
  120. package/lib/model/featuresModel/axisModel.d.ts +0 -18
  121. package/lib/model/featuresModel/axisModel.js +0 -111
  122. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +0 -7
  123. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +0 -86
  124. package/lib/model/featuresModel/legendModel/legendModel.d.ts +0 -13
  125. package/lib/model/featuresModel/legendModel/legendModel.js +0 -78
  126. package/lib/model/featuresModel/otherComponents.d.ts +0 -6
  127. package/lib/model/featuresModel/otherComponents.js +0 -12
  128. package/lib/model/featuresModel/scaleModel.d.ts +0 -17
  129. package/lib/model/featuresModel/scaleModel.js +0 -100
  130. package/lib/model/featuresModel/titleModel.d.ts +0 -4
  131. package/lib/model/featuresModel/titleModel.js +0 -14
  132. package/lib/model/featuresModel/tooltipModel.d.ts +0 -4
  133. package/lib/model/featuresModel/tooltipModel.js +0 -7
  134. package/lib/model/marginModel.d.ts +0 -19
  135. package/lib/model/marginModel.js +0 -126
  136. package/lib/model/model.d.ts +0 -220
  137. package/lib/model/model.js +0 -1
  138. package/lib/model/modelBuilder.d.ts +0 -16
  139. package/lib/model/modelBuilder.js +0 -128
  140. package/lib/model/modelHelper.d.ts +0 -7
  141. package/lib/model/modelHelper.js +0 -41
  142. package/lib/model/notations/intervalModel.d.ts +0 -8
  143. package/lib/model/notations/intervalModel.js +0 -93
  144. package/lib/model/notations/polarModel.d.ts +0 -7
  145. package/lib/model/notations/polarModel.js +0 -27
  146. package/lib/model/notations/twoDimensionalModel.d.ts +0 -19
  147. package/lib/model/notations/twoDimensionalModel.js +0 -85
  148. package/lib/style/charts-main.css +0 -240
  149. package/lib/style/charts-main.less +0 -240
  150. package/test.html +0 -196
@@ -1,197 +0,0 @@
1
- import { select } from 'd3-selection';
2
- import { easeLinear } from 'd3-ease';
3
- import { interrupt } from 'd3-transition';
4
- import { DonutHelper } from '../polarNotation/donut/DonutHelper';
5
- import { DomHelper, SelectionCondition } from '../helpers/domHelper';
6
- import { Donut } from '../polarNotation/donut/donut';
7
- import { MarkDot } from '../features/markDots/markDot';
8
- import { Helper } from '../helpers/helper';
9
- export class ElementHighlighter {
10
- static toggleActivityStyle(elementSelection, isActive) {
11
- elementSelection.classed(this.inactiveElemClass, !isActive);
12
- }
13
- /**
14
- * @param blurPercent процент от макс. размера блюра
15
- */
16
- static setShadowFilter(elemSelection, blurPercent = 1) {
17
- const maxBlurSize = 8;
18
- elemSelection.each(function () {
19
- const elemFill = select(this).style('fill') || 'rgb(0, 0, 0)';
20
- const shadowColor = Helper.getRgbaFromRgb(elemFill, 0.6);
21
- select(this).style('filter', `drop-shadow(0px 0px ${blurPercent * maxBlurSize}px ${shadowColor})`);
22
- });
23
- // elemSelection.style('filter', `drop-shadow(0px 0px ${blurSize}px rgba(0, 0, 0, 0.5))`);
24
- }
25
- static removeFilter(elemSelection) {
26
- elemSelection.style('filter', null);
27
- }
28
- static removeShadowClone(block, keyFieldName, selectedSegment, margin, blockSize, donutThickness) {
29
- const shadowClone = Donut.getAllArcShadows(block)
30
- .filter((d) => d.data[keyFieldName] === selectedSegment.datum().data[keyFieldName]);
31
- this.removeFilter(shadowClone.select('path'));
32
- this.toggleDonutHighlightState(shadowClone, margin, blockSize, donutThickness, block.transitionManager.durations.higlightedScale, false)
33
- .then(() => shadowClone.remove());
34
- }
35
- static removeCloneForElem(block, keyFieldName, selectedSegment) {
36
- const clone = Donut.getAllArcClones(block)
37
- .filter((d) => d.data[keyFieldName] === selectedSegment.datum().data[keyFieldName]);
38
- clone.remove();
39
- }
40
- static removeDonutArcClones(block) {
41
- Donut.getAllArcClones(block).remove();
42
- Donut.getAllArcShadows(block).remove();
43
- }
44
- static renderArcCloneAndHighlight(block, margin, arcSelection, blockSize, donutThickness) {
45
- const clone = this.makeArcClone(arcSelection, block);
46
- const shadowClone = this.makeArcShadow(arcSelection, block);
47
- this.toggleDonutHighlightState(arcSelection, margin, blockSize, donutThickness, block.transitionManager.durations.higlightedScale, true);
48
- this.toggleDonutHighlightState(clone, margin, blockSize, donutThickness, block.transitionManager.durations.higlightedScale, true);
49
- this.toggleDonutHighlightState(shadowClone, margin, blockSize, donutThickness, block.transitionManager.durations.higlightedScale, true);
50
- this.setShadowFilter(shadowClone.select('path'), donutThickness / 60);
51
- }
52
- static toggleDonutHighlightState(segment, margin, blockSize, donutThickness, transitionDuration, on) {
53
- return new Promise(resolve => {
54
- let scaleSize = 0;
55
- if (on)
56
- scaleSize = 5; // Если нужно выделить сегмент, то scaleSize не равен нулю и отображается увеличенным
57
- segment
58
- .select('path')
59
- .interrupt()
60
- .transition()
61
- .duration(transitionDuration)
62
- .on('end', () => resolve(''))
63
- .ease(easeLinear)
64
- .attr('d', (d, i) => DonutHelper.getArcGeneratorObject(blockSize, margin, donutThickness)
65
- .outerRadius(DonutHelper.getOuterRadius(margin, blockSize) + scaleSize)
66
- .innerRadius(DonutHelper.getOuterRadius(margin, blockSize) - donutThickness - scaleSize)(d, i));
67
- });
68
- }
69
- static removeDonutHighlightingByKeys(arcSegments, keyFieldName, keyValues, margin, blockSize, donutThickness) {
70
- const segments = DomHelper.getChartElementsByKeys(arcSegments, true, keyFieldName, keyValues, SelectionCondition.Exclude);
71
- this.toggleDonutHighlightState(segments, margin, blockSize, donutThickness, 0, false);
72
- }
73
- static setInactiveFor2D(block, keyFieldName, charts) {
74
- charts.forEach(chart => {
75
- const elems = DomHelper.get2DChartElements(block, chart);
76
- if (block.filterEventManager.getSelectedKeys().length === 0) {
77
- this.toggleActivityStyle(elems, true);
78
- }
79
- else {
80
- const unselectedElems = DomHelper.getChartElementsByKeys(elems, chart.isSegmented, keyFieldName, block.filterEventManager.getSelectedKeys(), SelectionCondition.Exclude);
81
- const selectedElems = DomHelper.getChartElementsByKeys(elems, chart.isSegmented, keyFieldName, block.filterEventManager.getSelectedKeys());
82
- this.toggleActivityStyle(unselectedElems, false);
83
- this.toggleActivityStyle(selectedElems, true);
84
- }
85
- });
86
- }
87
- static toggleMarkDotVisible(markDots, isHighlight) {
88
- markDots.classed(MarkDot.hiddenDotClass, !isHighlight);
89
- }
90
- static remove2DChartsFullHighlighting(block, charts, transitionDuration = 0) {
91
- charts.forEach(chart => {
92
- const elems = DomHelper.get2DChartElements(block, chart);
93
- if (chart.type !== 'bar' && !chart.markersOptions.show)
94
- elems.classed(MarkDot.hiddenDotClass, true);
95
- this.toggle2DElements(elems, false, chart.type, transitionDuration);
96
- this.toggleActivityStyle(elems, true);
97
- });
98
- }
99
- static removeUnselected2DHighlight(block, keyFieldName, charts, transitionDuration) {
100
- charts.forEach(chart => {
101
- const elems = DomHelper.get2DChartElements(block, chart);
102
- const selectedElems = DomHelper.getChartElementsByKeys(elems, chart.isSegmented, keyFieldName, block.filterEventManager.getSelectedKeys(), SelectionCondition.Exclude);
103
- if (chart.type !== 'bar' && !chart.markersOptions.show)
104
- selectedElems.classed(MarkDot.hiddenDotClass, true);
105
- this.toggle2DElements(selectedElems, false, chart.type, transitionDuration);
106
- if (block.filterEventManager.getSelectedKeys().length > 0)
107
- this.toggleActivityStyle(selectedElems, false);
108
- });
109
- }
110
- static toggle2DElements(elemSelection, isHighlight, chartType, transitionDuration) {
111
- if (chartType === 'area' || chartType === 'line') {
112
- elemSelection.call(this.toggleDot, isHighlight, transitionDuration);
113
- }
114
- else {
115
- this.toggleBar(elemSelection, isHighlight);
116
- if (isHighlight) {
117
- elemSelection.each(function (d) {
118
- const attrs = this.attrs;
119
- const blurPercent = (attrs.orient === 'vertical' ? attrs.width : attrs.height) / 30; // 30px = max bar size, 13px - max blurSize
120
- ElementHighlighter.setShadowFilter(select(this), blurPercent);
121
- });
122
- }
123
- else {
124
- this.removeFilter(elemSelection);
125
- }
126
- }
127
- }
128
- static makeArcClone(segment, block) {
129
- const clone = this.renderDonutSegmentClone(segment, `${Donut.arcCloneClass}`);
130
- block.getSvg().select(`.${Donut.arcClonesGroupClass}`).append(function () { return clone.node(); });
131
- return clone;
132
- }
133
- static makeArcShadow(segment, block) {
134
- const shadowClone = this.renderDonutSegmentClone(segment, `${Donut.arcShadowClass}`);
135
- block.getSvg().select(`.${Donut.arcShadowsGroupClass}`).append(function () { return shadowClone.node(); });
136
- return shadowClone;
137
- }
138
- static renderDonutSegmentClone(segment, newClass) {
139
- return segment
140
- .clone(true)
141
- .style('pointer-events', 'none')
142
- .classed(`${Donut.arcCloneClass}`, false)
143
- .classed(newClass, true)
144
- .remove();
145
- }
146
- static toggleBar(elemSelection, isHighlight) {
147
- const animationName = 'bar-highlight';
148
- if (isHighlight) {
149
- elemSelection.each(function () {
150
- const attrs = this.attrs;
151
- const handler = select(this).interrupt(animationName).transition(animationName).duration(200);
152
- if (attrs.orient === 'vertical') {
153
- handler
154
- .attr('x', attrs.x - attrs.scaleSize)
155
- .attr('width', attrs.width + attrs.scaleSize * 2);
156
- }
157
- else {
158
- handler
159
- .attr('y', attrs.y - attrs.scaleSize)
160
- .attr('height', attrs.height + attrs.scaleSize * 2);
161
- }
162
- });
163
- }
164
- else {
165
- elemSelection.each(function () {
166
- const attrs = this.attrs;
167
- const handler = select(this).interrupt(animationName).transition(animationName).duration(200);
168
- handler
169
- .attr('x', attrs.x)
170
- .attr('width', attrs.width)
171
- .attr('y', attrs.y)
172
- .attr('height', attrs.height);
173
- });
174
- }
175
- }
176
- static toggleDot(elementSelection, isScaled, transitionDuration = 0) {
177
- const animationName = 'size-scale';
178
- elementSelection.nodes().forEach(node => {
179
- interrupt(node, animationName);
180
- });
181
- let elementsHandler = elementSelection;
182
- if (transitionDuration > 0) {
183
- elementsHandler = elementsHandler
184
- .interrupt()
185
- .transition(animationName)
186
- .duration(transitionDuration)
187
- .ease(easeLinear);
188
- }
189
- elementsHandler
190
- .attr('r', isScaled ? 5 : 4)
191
- .style('stroke-width', (isScaled ? 3.5 : 3) + 'px')
192
- .each(function () {
193
- select(this).style('fill', isScaled ? select(this).style('stroke') : 'white');
194
- });
195
- }
196
- }
197
- ElementHighlighter.inactiveElemClass = 'charts-opacity-inactive';
@@ -1,11 +0,0 @@
1
- import { BaseType, Selection } from "d3-selection";
2
- import { PieArcDatum } from "d3-shape";
3
- import { MdtChartsDataRow, Size } from "../../config/config";
4
- import { BlockMargin, DonutChartSettings, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../model/model";
5
- import { Block } from "../block/block";
6
- export declare class SelectHighlighter {
7
- static click2DHandler(multySelection: boolean, appendKey: boolean, keyValue: string, selectedKeys: string[], block: Block, options: TwoDimensionalOptionsModel): void;
8
- static clickPolarHandler(multySelection: boolean, appendKey: boolean, selectedSegment: Selection<SVGGElement, PieArcDatum<MdtChartsDataRow>, BaseType, unknown>, selectedKeys: string[], margin: BlockMargin, blockSize: Size, block: Block, options: PolarOptionsModel, arcItems: Selection<SVGGElement, PieArcDatum<MdtChartsDataRow>, SVGGElement, unknown>, donutSettings: DonutChartSettings): void;
9
- static clear2D(block: Block, options: TwoDimensionalOptionsModel): void;
10
- static clearPolar(margin: BlockMargin, blockSize: Size, block: Block, options: PolarOptionsModel, arcItems: Selection<SVGGElement, PieArcDatum<MdtChartsDataRow>, SVGGElement, unknown>, donutSettings: DonutChartSettings): void;
11
- }
@@ -1,95 +0,0 @@
1
- import { select } from "d3-selection";
2
- import { Legend } from "../features/legend/legend";
3
- import { DomHelper, SelectionCondition } from "../helpers/domHelper";
4
- import { Donut } from "../polarNotation/donut/donut";
5
- import { DonutHelper } from "../polarNotation/donut/DonutHelper";
6
- import { ElementHighlighter } from "./elementHighlighter";
7
- export class SelectHighlighter {
8
- static click2DHandler(multySelection, appendKey, keyValue, selectedKeys, block, options) {
9
- options.charts.forEach(chart => {
10
- const selectedElements = DomHelper.getChartElementsByKeys(DomHelper.get2DChartElements(block, chart), chart.isSegmented, options.data.keyField.name, [keyValue]);
11
- const elements = DomHelper.get2DChartElements(block, chart);
12
- if (!appendKey) {
13
- ElementHighlighter.toggle2DElements(selectedElements, false, chart.type, block.transitionManager.durations.markerHover);
14
- if (chart.type !== 'bar' && !chart.markersOptions.show)
15
- ElementHighlighter.toggleMarkDotVisible(selectedElements, false);
16
- if (selectedKeys.length > 0) {
17
- ElementHighlighter.toggleActivityStyle(selectedElements, false);
18
- }
19
- else {
20
- ElementHighlighter.toggleActivityStyle(elements, true);
21
- if (chart.type !== 'bar' && !chart.markersOptions.show)
22
- ElementHighlighter.toggleMarkDotVisible(elements, false);
23
- }
24
- return;
25
- }
26
- if (multySelection) {
27
- ElementHighlighter.toggle2DElements(selectedElements, true, chart.type, block.transitionManager.durations.markerHover);
28
- ElementHighlighter.toggleActivityStyle(selectedElements, true);
29
- ElementHighlighter.toggleActivityStyle(DomHelper.getChartElementsByKeys(elements, chart.isSegmented, options.data.keyField.name, selectedKeys, SelectionCondition.Exclude), false);
30
- }
31
- else {
32
- ElementHighlighter.toggle2DElements(DomHelper.getChartElementsByKeys(elements, chart.isSegmented, options.data.keyField.name, selectedKeys, SelectionCondition.Exclude), false, chart.type, block.transitionManager.durations.markerHover);
33
- ElementHighlighter.toggleActivityStyle(elements, false);
34
- if (chart.type !== 'bar' && !chart.markersOptions.show)
35
- ElementHighlighter.toggleMarkDotVisible(elements, false);
36
- ElementHighlighter.toggleActivityStyle(selectedElements, true);
37
- ElementHighlighter.toggle2DElements(selectedElements, true, chart.type, block.transitionManager.durations.markerHover);
38
- }
39
- if (chart.type !== 'bar' && !chart.markersOptions.show)
40
- ElementHighlighter.toggleMarkDotVisible(selectedElements, true);
41
- });
42
- }
43
- static clickPolarHandler(multySelection, appendKey, selectedSegment, selectedKeys, margin, blockSize, block, options, arcItems, donutSettings) {
44
- const donutThickness = DonutHelper.getThickness(donutSettings, blockSize, margin);
45
- if (!appendKey) {
46
- ElementHighlighter.toggleDonutHighlightState(selectedSegment, margin, blockSize, donutThickness, block.transitionManager.durations.higlightedScale, false);
47
- ElementHighlighter.removeCloneForElem(block, options.data.keyField.name, selectedSegment);
48
- ElementHighlighter.removeShadowClone(block, options.data.keyField.name, selectedSegment, margin, blockSize, donutThickness);
49
- if (selectedKeys.length > 0) {
50
- ElementHighlighter.toggleActivityStyle(selectedSegment, false);
51
- ElementHighlighter.toggleActivityStyle(Legend.getItemsByKeys(block, selectedKeys, SelectionCondition.Exclude), false);
52
- }
53
- else {
54
- ElementHighlighter.toggleActivityStyle(Donut.getAllArcGroups(block), true);
55
- ElementHighlighter.toggleActivityStyle(Legend.getItemsByKeys(block, [], SelectionCondition.Exclude), true);
56
- }
57
- return;
58
- }
59
- if (multySelection) {
60
- ElementHighlighter.removeCloneForElem(block, options.data.keyField.name, selectedSegment);
61
- ElementHighlighter.removeShadowClone(block, options.data.keyField.name, selectedSegment, margin, blockSize, donutThickness);
62
- ElementHighlighter.renderArcCloneAndHighlight(block, margin, selectedSegment, blockSize, donutThickness);
63
- ElementHighlighter.toggleActivityStyle(selectedSegment, true);
64
- ElementHighlighter.toggleActivityStyle(DomHelper.getChartElementsByKeys(Donut.getAllArcGroups(block), true, options.data.keyField.name, selectedKeys, SelectionCondition.Exclude), false);
65
- }
66
- else {
67
- ElementHighlighter.removeDonutHighlightingByKeys(arcItems, options.data.keyField.name, selectedKeys, margin, blockSize, donutThickness);
68
- ElementHighlighter.removeDonutArcClones(block);
69
- ElementHighlighter.toggleActivityStyle(Donut.getAllArcGroups(block), false);
70
- ElementHighlighter.toggleActivityStyle(selectedSegment, true);
71
- ElementHighlighter.renderArcCloneAndHighlight(block, margin, selectedSegment, blockSize, donutThickness);
72
- }
73
- ElementHighlighter.toggleActivityStyle(Legend.getItemsByKeys(block, selectedKeys, SelectionCondition.Exclude), false);
74
- ElementHighlighter.toggleActivityStyle(Legend.getItemsByKeys(block, selectedKeys), true);
75
- }
76
- static clear2D(block, options) {
77
- options.charts.forEach(chart => {
78
- const elements = DomHelper.get2DChartElements(block, chart);
79
- ElementHighlighter.toggle2DElements(elements, false, chart.type, block.transitionManager.durations.markerHover);
80
- ElementHighlighter.toggleActivityStyle(elements, true);
81
- if (chart.type !== 'bar' && !chart.markersOptions.show)
82
- ElementHighlighter.toggleMarkDotVisible(elements, false);
83
- });
84
- }
85
- static clearPolar(margin, blockSize, block, options, arcItems, donutSettings) {
86
- const donutThickness = DonutHelper.getThickness(donutSettings, blockSize, margin);
87
- ElementHighlighter.toggleDonutHighlightState(arcItems, margin, blockSize, donutThickness, block.transitionManager.durations.higlightedScale, false);
88
- arcItems.each(function () {
89
- ElementHighlighter.removeCloneForElem(block, options.data.keyField.name, select(this));
90
- ElementHighlighter.removeShadowClone(block, options.data.keyField.name, select(this), margin, blockSize, donutThickness);
91
- });
92
- ElementHighlighter.toggleActivityStyle(Donut.getAllArcGroups(block), true);
93
- ElementHighlighter.toggleActivityStyle(Legend.getItemsByKeys(block, [], SelectionCondition.Exclude), true);
94
- }
95
- }
@@ -1,20 +0,0 @@
1
- import { Block } from './block/block';
2
- import { Model } from '../model/model';
3
- import { FilterCallback, FilterEventManager } from './filterManager/filterEventManager';
4
- import { MdtChartsDataSource } from '../config/config';
5
- export default class Engine {
6
- private filterCallback;
7
- private initializeSelected;
8
- block: Block;
9
- filterEventManager: FilterEventManager;
10
- data: MdtChartsDataSource;
11
- private chartId;
12
- constructor(id: number, filterCallback: FilterCallback, initializeSelected: number[]);
13
- render(model: Model, data: MdtChartsDataSource, parentElement: HTMLElement): void;
14
- updateFullBlock(model: Model, data: MdtChartsDataSource): void;
15
- destroy(): void;
16
- updateData(model: Model, newData: MdtChartsDataSource): void;
17
- updateColors(model: Model): void;
18
- private renderCharts;
19
- private setFilterEventManager;
20
- }
@@ -1,64 +0,0 @@
1
- import { Block } from './block/block';
2
- import { ValueFormatter } from './valueFormatter';
3
- import { ContentManager } from './contentManager';
4
- import { FilterEventManager } from './filterManager/filterEventManager';
5
- import { Helper } from './helpers/helper';
6
- export default class Engine {
7
- constructor(id, filterCallback, initializeSelected) {
8
- this.filterCallback = filterCallback;
9
- this.initializeSelected = initializeSelected;
10
- this.chartId = id;
11
- }
12
- render(model, data, parentElement) {
13
- this.data = data;
14
- this.setFilterEventManager(model === null || model === void 0 ? void 0 : model.options);
15
- this.block = new Block(model.blockCanvas.cssClass, parentElement, this.chartId, this.filterEventManager, model.transitions);
16
- this.filterEventManager.setBlock(this.block);
17
- this.block.renderWrapper(model.blockCanvas.size);
18
- if (model.options) {
19
- ValueFormatter.setFormatFunction(model.dataSettings.format.formatters);
20
- this.renderCharts(model, this.data);
21
- }
22
- }
23
- updateFullBlock(model, data) {
24
- this.destroy();
25
- this.render(model, data, this.block.parentElement);
26
- }
27
- destroy() {
28
- this.block.destroy();
29
- }
30
- updateData(model, newData) {
31
- if (!newData) {
32
- this.data = newData;
33
- this.block.clearWrapper();
34
- }
35
- else {
36
- if (!this.data) {
37
- this.data = newData;
38
- this.updateFullBlock(model, this.data);
39
- }
40
- else if (!Helper.compareData(this.data, newData, model.options.data.dataSource)) {
41
- for (let source in newData) {
42
- this.data[source] = newData[source];
43
- }
44
- ContentManager.updateData(this.block, model, newData);
45
- }
46
- }
47
- }
48
- updateColors(model) {
49
- ContentManager.updateColors(this, model);
50
- }
51
- renderCharts(model, data) {
52
- ContentManager.render(model, data, this);
53
- }
54
- setFilterEventManager(options) {
55
- var _a, _b, _c;
56
- let highlightIds = [];
57
- if (this.initializeSelected instanceof Array && this.initializeSelected.length > 0)
58
- highlightIds = [...this.initializeSelected];
59
- if ((_a = options === null || options === void 0 ? void 0 : options.data) === null || _a === void 0 ? void 0 : _a.dataSource)
60
- this.filterEventManager = new FilterEventManager(this.filterCallback, this.data[options.data.dataSource], options.selectable, options.data.keyField.name, highlightIds);
61
- else
62
- this.filterEventManager = new FilterEventManager(this.filterCallback, [], options === null || options === void 0 ? void 0 : options.selectable, (_c = (_b = options === null || options === void 0 ? void 0 : options.data) === null || _b === void 0 ? void 0 : _b.keyField) === null || _c === void 0 ? void 0 : _c.name, highlightIds);
63
- }
64
- }
@@ -1,22 +0,0 @@
1
- import { MdtChartsDataRow } from '../../../config/config';
2
- import { DataType } from '../../../designer/designerConfig';
3
- import { Field } from "../../../model/model";
4
- import { Block } from "../../block/block";
5
- import { Translate } from "../../polarNotation/donut/donut";
6
- export interface AggregatorInfo {
7
- name: string;
8
- value: number;
9
- format: DataType;
10
- }
11
- export declare class Aggregator {
12
- static readonly aggregatorValueClass = "aggregator-value";
13
- private static readonly aggregatorNameClass;
14
- private static readonly aggregatorObjectClass;
15
- static render(block: Block, data: MdtChartsDataRow[], valueField: Field, innerRadius: number, translate: Translate, fontSize: number, pad: number): void;
16
- static update(block: Block, data: MdtChartsDataRow[], valueField: Field, pad: number): void;
17
- private static renderText;
18
- private static updateText;
19
- private static reCalculateAggregatorFontSize;
20
- private static renderAggregatorObject;
21
- private static renderWrapper;
22
- }
@@ -1,95 +0,0 @@
1
- import { sum } from 'd3-array';
2
- import { interpolateNumber } from 'd3-interpolate';
3
- import { Helper } from '../../helpers/helper';
4
- import { ValueFormatter } from '../../valueFormatter';
5
- export class Aggregator {
6
- static render(block, data, valueField, innerRadius, translate, fontSize, pad) {
7
- const aggregator = {
8
- name: 'Сумма',
9
- value: sum(data.map(d => d[valueField.name])),
10
- format: valueField.format
11
- };
12
- this.renderText(block, innerRadius, aggregator, translate, fontSize, pad);
13
- }
14
- static update(block, data, valueField, pad) {
15
- const aggregator = {
16
- name: 'Сумма',
17
- value: sum(data.map(d => d[valueField.name])),
18
- format: valueField.format
19
- };
20
- this.updateText(block, aggregator, pad);
21
- }
22
- static renderText(block, innerRadius, aggregatorInfo, translate, fontSize, pad) {
23
- if (innerRadius > 50) {
24
- const aggregatorObject = this.renderAggregatorObject(block, innerRadius, translate);
25
- const wrapper = this.renderWrapper(aggregatorObject);
26
- wrapper
27
- .append('div')
28
- .attr('class', this.aggregatorValueClass)
29
- .style('text-align', 'center')
30
- .style('font-size', `${fontSize}px`)
31
- .text(ValueFormatter.formatField(aggregatorInfo.format, aggregatorInfo.value));
32
- wrapper
33
- .append('div')
34
- .attr('class', this.aggregatorNameClass)
35
- .style('text-align', 'center')
36
- .style('font-size', '18px')
37
- .text(aggregatorInfo.name);
38
- this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, pad);
39
- }
40
- }
41
- static updateText(block, newAggregator, pad) {
42
- const aggregatorObject = block.getSvg()
43
- .select(`.${this.aggregatorObjectClass}`);
44
- const thisClass = this;
45
- block.getSvg()
46
- .select(`.${this.aggregatorValueClass}`)
47
- .interrupt()
48
- .transition()
49
- .duration(block.transitionManager.durations.chartUpdate)
50
- .tween("text", function () {
51
- const oldValue = Helper.parseFormattedToNumber(this.textContent, ',');
52
- const precision = Helper.calcDigitsAfterDot(newAggregator.value);
53
- const interpolateFunc = interpolateNumber(oldValue, newAggregator.value);
54
- return t => {
55
- this.textContent = ValueFormatter.formatField(newAggregator.format, (interpolateFunc(t)).toFixed(precision));
56
- thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, pad);
57
- };
58
- });
59
- }
60
- static reCalculateAggregatorFontSize(wrapperSize, block, pad) {
61
- const aggreggatorValue = block.getSvg()
62
- .select(`.${this.aggregatorValueClass}`);
63
- let fontSize = parseInt(aggreggatorValue.style('font-size'));
64
- while (aggreggatorValue.node().getBoundingClientRect().width > wrapperSize - pad * 2 && fontSize > 15) {
65
- aggreggatorValue.style('font-size', `${fontSize -= 2}px`);
66
- }
67
- while (aggreggatorValue.node().getBoundingClientRect().width < wrapperSize - pad * 2 && fontSize < 60) {
68
- aggreggatorValue.style('font-size', `${fontSize += 2}px`);
69
- }
70
- }
71
- static renderAggregatorObject(block, innerRadius, translate) {
72
- return block.getSvg()
73
- .append('foreignObject')
74
- .attr('class', this.aggregatorObjectClass)
75
- .attr('transform-origin', 'center')
76
- .attr('width', innerRadius * 2)
77
- .attr('height', innerRadius * 2)
78
- .attr('transform', `translate(${translate.x - innerRadius}, ${translate.y - innerRadius})`)
79
- .style('pointer-events', `none`);
80
- }
81
- static renderWrapper(aggregatorObject) {
82
- return aggregatorObject
83
- .append('xhtml:div')
84
- .style('width', '100%')
85
- .style('height', '100%')
86
- .style('border-radius', '50%')
87
- .style('display', 'flex')
88
- .style('flex-direction', 'column')
89
- .style('justify-content', 'center')
90
- .style('align-items', 'center');
91
- }
92
- }
93
- Aggregator.aggregatorValueClass = 'aggregator-value';
94
- Aggregator.aggregatorNameClass = 'aggregator-name';
95
- Aggregator.aggregatorObjectClass = 'aggregator-object';
@@ -1,12 +0,0 @@
1
- import { IAxisModel, IScaleModel } from "../../../model/model";
2
- import { Block } from "../../block/block";
3
- import { Scales } from "../scale/scale";
4
- import { Size } from '../../../config/config';
5
- export declare class Axis {
6
- static axesClass: string;
7
- static render(block: Block, scales: Scales, scaleModel: IScaleModel, axisModel: IAxisModel, blockSize: Size): void;
8
- static update(block: Block, scales: Scales, scalesOptions: IScaleModel, axisModel: IAxisModel, blockSize: Size, keyDomainsEquality: boolean): void;
9
- private static renderAxis;
10
- private static updateValueAxis;
11
- private static updateKeyAxis;
12
- }
@@ -1,118 +0,0 @@
1
- import { Scale } from "../scale/scale";
2
- import { AXIS_VERTICAL_LABEL_PADDING } from "../../../model/marginModel";
3
- import { NamesHelper } from '../../helpers/namesHelper';
4
- import { AxisHelper } from './axisHelper';
5
- import { AxisLabelHelper } from './axisLabelDomHelper';
6
- import { AxisDomHelper } from './axisDomHelper';
7
- import { select } from 'd3-selection';
8
- import { AxisLabelsEventManager } from './axisLabelsEventManager';
9
- const MINIMAL_STEP_SIZE_FOR_WRAPPING = 38;
10
- export class Axis {
11
- static render(block, scales, scaleModel, axisModel, blockSize) {
12
- if (axisModel.value.visibility)
13
- this.renderAxis(block, scales.value, scaleModel.value, axisModel.value, blockSize);
14
- if (axisModel.key.visibility)
15
- this.renderAxis(block, scales.key, scaleModel.key, axisModel.key, blockSize);
16
- }
17
- static update(block, scales, scalesOptions, axisModel, blockSize, keyDomainsEquality) {
18
- if (axisModel.value.visibility)
19
- this.updateValueAxis(block, scales.value, scalesOptions.value, axisModel.value);
20
- if (axisModel.key.visibility)
21
- this.updateKeyAxis(block, scales.key, scalesOptions.key, axisModel.key, blockSize, keyDomainsEquality);
22
- }
23
- static renderAxis(block, scale, scaleOptions, axisOptions, blockSize) {
24
- const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scale, scaleOptions);
25
- if (axisOptions.type === 'value' && (scaleOptions.type === 'linear' || scaleOptions.type === 'datetime'))
26
- AxisHelper.setLabelsSettings(axisGenerator, scale.range(), scaleOptions);
27
- const axisElement = block.getSvg()
28
- .append('g')
29
- .attr('class', `${this.axesClass} ${axisOptions.cssClass} data-label`);
30
- AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate);
31
- if (!axisOptions.labels.visible) {
32
- AxisLabelHelper.hideLabels(axisElement);
33
- return;
34
- }
35
- if (axisOptions.type === 'key') {
36
- if (axisOptions.labels.position === 'rotated' && (axisOptions.orient === 'top' || axisOptions.orient === 'bottom'))
37
- AxisLabelHelper.rotateLabels(axisElement, axisOptions.orient);
38
- if ((axisOptions.orient === 'left' || axisOptions.orient === 'right') && Scale.getScaleStep(scale) >= MINIMAL_STEP_SIZE_FOR_WRAPPING)
39
- axisElement.selectAll('.tick text').call(AxisLabelHelper.wrapHandler, axisOptions.labels.maxSize);
40
- else
41
- AxisLabelHelper.cropLabels(block, scale, scaleOptions, axisOptions, blockSize);
42
- AxisLabelHelper.alignLabelsInKeyAxis(axisOptions, axisElement);
43
- AxisLabelsEventManager.setHoverEvents(block, axisElement);
44
- }
45
- if (axisOptions.labels.defaultTooltip)
46
- AxisLabelHelper.setTitles(axisElement);
47
- }
48
- static updateValueAxis(block, scaleValue, scaleOptions, axisOptions) {
49
- const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleValue, scaleOptions);
50
- AxisHelper.setLabelsSettings(axisGenerator, scaleValue.range(), scaleOptions);
51
- const axisElement = block.getSvg().select(`g.${axisOptions.cssClass}`);
52
- AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate, block.transitionManager.durations.chartUpdate)
53
- .then(() => {
54
- if (axisOptions.labels.defaultTooltip)
55
- AxisLabelHelper.setTitles(axisElement);
56
- });
57
- }
58
- static updateKeyAxis(block, scaleKey, scaleOptions, axisOptions, blockSize, domainNotUpdated) {
59
- const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleKey, scaleOptions);
60
- if (axisOptions.labels.position === 'rotated') { // Задание координат для перевернутых лейблов (если до этого они не были перевернуты)
61
- if (axisOptions.orient === 'bottom')
62
- axisGenerator.tickPadding(-4);
63
- else if (axisOptions.orient === 'top')
64
- axisGenerator.tickPadding(-6);
65
- }
66
- const axisElement = block.getSvg()
67
- .select(`g.${axisOptions.cssClass}`);
68
- AxisLabelsEventManager.removeEvents(axisElement);
69
- if (axisOptions.orient === 'left' || axisOptions.orient === 'right') {
70
- axisElement.selectAll('.tick text').attr('y', null);
71
- if (axisOptions.orient === 'left')
72
- axisGenerator.tickPadding(axisOptions.labels.maxSize + AXIS_VERTICAL_LABEL_PADDING);
73
- }
74
- // Если ключи оси не меняются, то обновление происходит без анимации
75
- AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate, domainNotUpdated ? 0 : block.transitionManager.durations.chartUpdate)
76
- .then(() => {
77
- if (axisOptions.orient === 'bottom' || axisOptions.orient === 'top') {
78
- AxisLabelHelper.cropLabels(block, scaleKey, scaleOptions, axisOptions, blockSize);
79
- }
80
- AxisLabelsEventManager.setHoverEvents(block, axisElement);
81
- if (axisOptions.labels.defaultTooltip)
82
- AxisLabelHelper.setTitles(axisElement);
83
- });
84
- // Ведется отсчет нескольких кадров, чтобы получить уже 100%-отрендеренные лейблы оси.
85
- let frame = 0;
86
- const labelHandler = () => {
87
- frame++;
88
- if (frame < 10)
89
- requestAnimationFrame(labelHandler);
90
- if (frame === 2) {
91
- axisElement.selectAll('.tick').each(function (d) {
92
- if (scaleKey.domain().findIndex(key => key === d) === -1) {
93
- select(this).style('opacity', 0);
94
- }
95
- else {
96
- select(this).style('opacity', 1);
97
- }
98
- });
99
- }
100
- if (axisOptions.orient === 'left' || axisOptions.orient === 'right') {
101
- if (Scale.getScaleStep(scaleKey) >= MINIMAL_STEP_SIZE_FOR_WRAPPING)
102
- axisElement.selectAll('.tick text').call(AxisLabelHelper.wrapHandler, axisOptions.labels.maxSize);
103
- else
104
- AxisLabelHelper.cropLabels(block, scaleKey, scaleOptions, axisOptions, blockSize);
105
- AxisLabelHelper.alignLabelsInKeyAxis(axisOptions, axisElement);
106
- }
107
- if (axisOptions.orient === 'bottom' || axisOptions.orient === 'top') {
108
- if (axisOptions.labels.position === 'rotated')
109
- AxisLabelHelper.rotateLabels(axisElement, axisOptions.orient);
110
- if (axisOptions.labels.position === 'straight') // Обратное выравнивание лейблов, если они были перевернуты, но теперь могут отображаться прямо
111
- AxisDomHelper.rotateElementsBack(axisElement);
112
- AxisLabelHelper.cropLabels(block, scaleKey, scaleOptions, axisOptions, blockSize);
113
- }
114
- };
115
- requestAnimationFrame(labelHandler);
116
- }
117
- }
118
- Axis.axesClass = NamesHelper.getClassName('axis');
@@ -1,7 +0,0 @@
1
- import { Selection, BaseType } from 'd3-selection';
2
- import { Axis as IAxis } from 'd3-axis';
3
- import { TranslateModel } from '../../../model/model';
4
- export declare class AxisDomHelper {
5
- static updateAxisElement(axisGenerator: IAxis<any>, axisElement: Selection<SVGGElement, any, BaseType, any>, translate: TranslateModel, transitionDuration?: number): Promise<string>;
6
- static rotateElementsBack(axisElement: Selection<SVGGElement, unknown, HTMLElement, any>): void;
7
- }