mdt-charts 1.9.11 → 1.10.3

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 (160) hide show
  1. package/lib/config/config.d.ts +148 -0
  2. package/lib/config/config.js +1 -0
  3. package/lib/designer/designerConfig.d.ts +71 -0
  4. package/lib/designer/designerConfig.js +1 -0
  5. package/lib/engine/block/block.d.ts +35 -0
  6. package/lib/engine/block/block.js +110 -0
  7. package/lib/engine/block/blockHelper.d.ts +12 -0
  8. package/lib/engine/block/blockHelper.js +19 -0
  9. package/lib/engine/colorReader/colorReader.d.ts +10 -0
  10. package/lib/engine/colorReader/colorReader.js +21 -0
  11. package/lib/engine/contentManager.d.ts +9 -0
  12. package/lib/engine/contentManager.js +29 -0
  13. package/lib/engine/elementHighlighter/elementHighlighter.d.ts +30 -0
  14. package/lib/engine/elementHighlighter/elementHighlighter.js +198 -0
  15. package/lib/engine/elementHighlighter/selectHighlighter.d.ts +11 -0
  16. package/lib/engine/elementHighlighter/selectHighlighter.js +95 -0
  17. package/lib/engine/engine.d.ts +20 -0
  18. package/lib/engine/engine.js +64 -0
  19. package/lib/engine/features/aggregator/aggregator.d.ts +22 -0
  20. package/lib/engine/features/aggregator/aggregator.js +95 -0
  21. package/lib/engine/features/axis/axis.d.ts +12 -0
  22. package/lib/engine/features/axis/axis.js +118 -0
  23. package/lib/engine/features/axis/axisDomHelper.d.ts +7 -0
  24. package/lib/engine/features/axis/axisDomHelper.js +24 -0
  25. package/lib/engine/features/axis/axisHelper.d.ts +9 -0
  26. package/lib/engine/features/axis/axisHelper.js +53 -0
  27. package/lib/engine/features/axis/axisLabelDomHelper.d.ts +17 -0
  28. package/lib/engine/features/axis/axisLabelDomHelper.js +143 -0
  29. package/lib/engine/features/axis/axisLabelsEventManager.d.ts +6 -0
  30. package/lib/engine/features/axis/axisLabelsEventManager.js +36 -0
  31. package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +23 -0
  32. package/lib/engine/features/embeddedLabels/embeddedLabels.js +147 -0
  33. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +8 -0
  34. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +30 -0
  35. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +27 -0
  36. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +65 -0
  37. package/lib/engine/features/gridLine/gidLineHelper.d.ts +13 -0
  38. package/lib/engine/features/gridLine/gidLineHelper.js +30 -0
  39. package/lib/engine/features/gridLine/gridLine.d.ts +11 -0
  40. package/lib/engine/features/gridLine/gridLine.js +67 -0
  41. package/lib/engine/features/legend/legend.d.ts +22 -0
  42. package/lib/engine/features/legend/legend.js +112 -0
  43. package/lib/engine/features/legend/legendDomHelper.d.ts +8 -0
  44. package/lib/engine/features/legend/legendDomHelper.js +48 -0
  45. package/lib/engine/features/legend/legendEventsManager.d.ts +12 -0
  46. package/lib/engine/features/legend/legendEventsManager.js +47 -0
  47. package/lib/engine/features/legend/legendHelper.d.ts +21 -0
  48. package/lib/engine/features/legend/legendHelper.js +99 -0
  49. package/lib/engine/features/markDots/markDot.d.ts +20 -0
  50. package/lib/engine/features/markDots/markDot.js +68 -0
  51. package/lib/engine/features/markDots/markDotsHelper.d.ts +6 -0
  52. package/lib/engine/features/markDots/markDotsHelper.js +16 -0
  53. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +14 -0
  54. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +97 -0
  55. package/lib/engine/features/scale/scale.d.ts +16 -0
  56. package/lib/engine/features/scale/scale.js +74 -0
  57. package/lib/engine/features/tipBox/tipBox.d.ts +11 -0
  58. package/lib/engine/features/tipBox/tipBox.js +32 -0
  59. package/lib/engine/features/tipBox/tipBoxHelper.d.ts +16 -0
  60. package/lib/engine/features/tipBox/tipBoxHelper.js +48 -0
  61. package/lib/engine/features/title/title.d.ts +9 -0
  62. package/lib/engine/features/title/title.js +35 -0
  63. package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +16 -0
  64. package/lib/engine/features/tolltip/newTooltip/newTooltip.js +26 -0
  65. package/lib/engine/features/tolltip/newTooltip/newTooltip.test.d.ts +1 -0
  66. package/lib/engine/features/tolltip/newTooltip/newTooltip.test.js +186 -0
  67. package/lib/engine/features/tolltip/newTooltip/newTooltipService.d.ts +17 -0
  68. package/lib/engine/features/tolltip/newTooltip/newTooltipService.js +26 -0
  69. package/lib/engine/features/tolltip/tooltip.d.ts +19 -0
  70. package/lib/engine/features/tolltip/tooltip.js +181 -0
  71. package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +17 -0
  72. package/lib/engine/features/tolltip/tooltipComponentsManager.js +125 -0
  73. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +30 -0
  74. package/lib/engine/features/tolltip/tooltipDomHelper.js +103 -0
  75. package/lib/engine/features/tolltip/tooltipHelper.d.ts +18 -0
  76. package/lib/engine/features/tolltip/tooltipHelper.js +93 -0
  77. package/lib/engine/filterManager/filterEventManager.d.ts +33 -0
  78. package/lib/engine/filterManager/filterEventManager.js +127 -0
  79. package/lib/engine/helpers/domHelper.d.ts +30 -0
  80. package/lib/engine/helpers/domHelper.js +68 -0
  81. package/lib/engine/helpers/helper.d.ts +30 -0
  82. package/lib/engine/helpers/helper.js +89 -0
  83. package/lib/engine/helpers/namesHelper.d.ts +5 -0
  84. package/lib/engine/helpers/namesHelper.js +9 -0
  85. package/lib/engine/intervalNotation/gantt.d.ts +10 -0
  86. package/lib/engine/intervalNotation/gantt.js +62 -0
  87. package/lib/engine/intervalNotation/intervalManager.d.ts +7 -0
  88. package/lib/engine/intervalNotation/intervalManager.js +30 -0
  89. package/lib/engine/polarNotation/donut/DonutHelper.d.ts +15 -0
  90. package/lib/engine/polarNotation/donut/DonutHelper.js +60 -0
  91. package/lib/engine/polarNotation/donut/donut.d.ts +32 -0
  92. package/lib/engine/polarNotation/donut/donut.js +125 -0
  93. package/lib/engine/polarNotation/polarManager.d.ts +10 -0
  94. package/lib/engine/polarNotation/polarManager.js +55 -0
  95. package/lib/engine/transitionManager.d.ts +19 -0
  96. package/lib/engine/transitionManager.js +64 -0
  97. package/lib/engine/twoDimensionalNotation/area/area.d.ts +17 -0
  98. package/lib/engine/twoDimensionalNotation/area/area.js +131 -0
  99. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +9 -0
  100. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +40 -0
  101. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +34 -0
  102. package/lib/engine/twoDimensionalNotation/bar/bar.js +216 -0
  103. package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +24 -0
  104. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +103 -0
  105. package/lib/engine/twoDimensionalNotation/line/line.d.ts +17 -0
  106. package/lib/engine/twoDimensionalNotation/line/line.js +132 -0
  107. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +8 -0
  108. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +28 -0
  109. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +11 -0
  110. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +101 -0
  111. package/lib/engine/valueFormatter.d.ts +6 -0
  112. package/lib/engine/valueFormatter.js +8 -0
  113. package/lib/main.d.ts +79 -0
  114. package/lib/main.js +88 -0
  115. package/lib/model/chartStyleModel.d.ts +16 -0
  116. package/lib/model/chartStyleModel.js +67 -0
  117. package/lib/model/configsValidator/configValidator.d.ts +5 -0
  118. package/lib/model/configsValidator/configValidator.js +7 -0
  119. package/lib/model/dataManagerModel.d.ts +22 -0
  120. package/lib/model/dataManagerModel.js +137 -0
  121. package/lib/model/featuresModel/axisModel.d.ts +18 -0
  122. package/lib/model/featuresModel/axisModel.js +111 -0
  123. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +7 -0
  124. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +86 -0
  125. package/lib/model/featuresModel/legendModel/legendModel.d.ts +13 -0
  126. package/lib/model/featuresModel/legendModel/legendModel.js +78 -0
  127. package/lib/model/featuresModel/otherComponents.d.ts +6 -0
  128. package/lib/model/featuresModel/otherComponents.js +12 -0
  129. package/lib/model/featuresModel/scaleModel.d.ts +17 -0
  130. package/lib/model/featuresModel/scaleModel.js +100 -0
  131. package/lib/model/featuresModel/titleModel.d.ts +4 -0
  132. package/lib/model/featuresModel/titleModel.js +14 -0
  133. package/lib/model/featuresModel/tooltipModel.d.ts +4 -0
  134. package/lib/model/featuresModel/tooltipModel.js +7 -0
  135. package/lib/model/marginModel.d.ts +19 -0
  136. package/lib/model/marginModel.js +126 -0
  137. package/lib/model/model.d.ts +221 -0
  138. package/lib/model/model.js +1 -0
  139. package/lib/model/modelBuilder.d.ts +16 -0
  140. package/lib/model/modelBuilder.js +128 -0
  141. package/lib/model/modelHelper.d.ts +7 -0
  142. package/lib/model/modelHelper.js +41 -0
  143. package/lib/model/notations/intervalModel.d.ts +8 -0
  144. package/lib/model/notations/intervalModel.js +93 -0
  145. package/lib/model/notations/polarModel.d.ts +7 -0
  146. package/lib/model/notations/polarModel.js +27 -0
  147. package/lib/model/notations/twoDimensionalModel.d.ts +19 -0
  148. package/lib/model/notations/twoDimensionalModel.js +85 -0
  149. package/lib/optionsServices/publicOptionsService.d.ts +6 -0
  150. package/lib/optionsServices/publicOptionsService.js +8 -0
  151. package/lib/optionsServices/validators/sizeValidator.d.ts +5 -0
  152. package/lib/optionsServices/validators/sizeValidator.js +13 -0
  153. package/lib/style/charts-main.css +243 -0
  154. package/lib/style/charts-main.less +243 -0
  155. package/package.json +1 -1
  156. package/dist/index.html +0 -363
  157. package/dist/listeners.89e1e272264c0e680de8.js +0 -278
  158. package/dist/main.f8b6bc6fee33cef1116c.js +0 -228
  159. package/dist/src_engine_engine_ts.ccee2a280374e0083541.js +0 -759
  160. package/dist/vendors-node_modules_chroma-js_chroma_js-node_modules_d3-array_src_max_js-node_modules_d3-arr-c3fc24.b32acc465b8557229277.js +0 -1869
@@ -0,0 +1,125 @@
1
+ import { interpolate } from 'd3-interpolate';
2
+ import { Aggregator } from "../../features/aggregator/aggregator";
3
+ import { DonutHelper } from './DonutHelper';
4
+ import { DomHelper } from '../../helpers/domHelper';
5
+ import { ColorReader } from '../../colorReader/colorReader';
6
+ export class Donut {
7
+ static render(block, data, margin, chart, blockSize, settings) {
8
+ const outerRadius = DonutHelper.getOuterRadius(margin, blockSize);
9
+ const thickness = DonutHelper.getThickness(settings, blockSize, margin);
10
+ const innerRadius = DonutHelper.getInnerRadius(outerRadius, thickness);
11
+ const arcGenerator = DonutHelper.getArcGenerator(outerRadius, innerRadius);
12
+ const pieGenerator = DonutHelper.getPieGenerator(chart.data.valueField.name, settings.padAngle);
13
+ const translateAttr = DonutHelper.getTranslate(margin, blockSize);
14
+ const donutBlock = block.getSvg()
15
+ .append('g')
16
+ .attr('class', this.donutBlockClass)
17
+ .attr('x', translateAttr.x)
18
+ .attr('y', translateAttr.y)
19
+ .attr('transform', `translate(${translateAttr.x}, ${translateAttr.y})`);
20
+ this.renderNewArcItems(arcGenerator, pieGenerator, donutBlock, data, chart);
21
+ this.renderClonesG(donutBlock);
22
+ Aggregator.render(block, data, chart.data.valueField, innerRadius, translateAttr, thickness, settings.aggregatorPad);
23
+ }
24
+ static update(block, data, margin, chart, blockSize, donutSettings, keyField) {
25
+ const outerRadius = DonutHelper.getOuterRadius(margin, blockSize);
26
+ const thickness = DonutHelper.getThickness(donutSettings, blockSize, margin);
27
+ const innerRadius = DonutHelper.getInnerRadius(outerRadius, thickness);
28
+ const arcGenerator = DonutHelper.getArcGenerator(outerRadius, innerRadius);
29
+ const pieGenerator = DonutHelper.getPieGenerator(chart.data.valueField.name, donutSettings.padAngle);
30
+ const oldData = block.getSvg()
31
+ .selectAll(`.${this.donutBlockClass}`)
32
+ .selectAll('path')
33
+ .data()
34
+ .map(d => d.data);
35
+ const dataNewZeroRows = DonutHelper.mergeDataWithZeros(data, oldData, keyField, ColorReader.getChartColorField(chart));
36
+ const dataExtraZeroRows = DonutHelper.mergeDataWithZeros(oldData, data, keyField, ColorReader.getChartColorField(chart));
37
+ const donutBlock = block.getSvg().select(`.${this.donutBlockClass}`);
38
+ this.renderNewArcItems(arcGenerator, pieGenerator, donutBlock, dataNewZeroRows, chart);
39
+ const path = this.getAllArcGroups(block)
40
+ .data(pieGenerator(dataExtraZeroRows))
41
+ .select('path');
42
+ const items = this.getAllArcGroups(block)
43
+ .data(pieGenerator(data));
44
+ this.setElementsColor(this.getAllArcGroups(block), chart);
45
+ return new Promise(resolve => {
46
+ this.raiseClonesG(block);
47
+ path
48
+ .interrupt()
49
+ .transition()
50
+ .duration(block.transitionManager.durations.chartUpdate)
51
+ .on('end', () => {
52
+ items.exit().remove();
53
+ resolve('updated');
54
+ })
55
+ .attrTween('d', function (d) {
56
+ const interpolateFunc = interpolate(this._currentData, d);
57
+ return t => {
58
+ this._currentData = interpolateFunc(t); // _current - старые данные до обновления, задаются во время рендера
59
+ return arcGenerator(this._currentData);
60
+ };
61
+ });
62
+ });
63
+ }
64
+ static updateColors(block, chart) {
65
+ this.setElementsColor(this.getAllArcGroups(block), chart);
66
+ }
67
+ static getAllArcGroups(block) {
68
+ return block.getSvg()
69
+ .selectAll(`.${this.arcItemClass}`);
70
+ }
71
+ static getAllArcClones(block) {
72
+ return block.getSvg()
73
+ .selectAll(`.${Donut.arcCloneClass}`);
74
+ }
75
+ static getAllArcShadows(block) {
76
+ return block.getSvg()
77
+ .selectAll(`.${this.arcShadowClass}`);
78
+ }
79
+ static renderNewArcItems(arcGenerator, pieGenerator, donutBlock, data, chart) {
80
+ const items = donutBlock
81
+ .selectAll(`.${this.arcItemClass}`)
82
+ .data(pieGenerator(data))
83
+ .enter()
84
+ .append('g')
85
+ .attr('class', this.arcItemClass);
86
+ const arcs = items
87
+ .append('path')
88
+ .attr('d', arcGenerator)
89
+ .attr('class', this.arcPathClass)
90
+ .each(function (d) { this._currentData = d; }); // _currentData используется для получения текущих данных внутри функции обновления.
91
+ DomHelper.setCssClasses(arcs, chart.cssClasses);
92
+ this.setElementsColor(items, chart);
93
+ }
94
+ static setElementsColor(arcItems, chart) {
95
+ arcItems
96
+ .select('path')
97
+ .style('fill', ({ data }, i) => ColorReader.getColorForArc(data, chart, i));
98
+ }
99
+ /**
100
+ * Рендер группы для клонов сегментов доната внутри donut-block. Объекдиняет в себе стили для клонов
101
+ */
102
+ static renderClonesG(donutBlock) {
103
+ const clonesShadowsG = donutBlock.append('g').attr('class', this.arcShadowsGroupClass).raise();
104
+ const clonesG = donutBlock.append('g').attr('class', this.arcClonesGroupClass).raise();
105
+ // ElementHighlighter.setShadowFilter(clonesG);
106
+ }
107
+ static raiseClonesG(block) {
108
+ block.getSvg()
109
+ .select(`.${this.donutBlockClass}`)
110
+ .select(`.${this.arcShadowsGroupClass}`)
111
+ .raise();
112
+ block.getSvg()
113
+ .select(`.${this.donutBlockClass}`)
114
+ .select(`.${this.arcClonesGroupClass}`)
115
+ .raise();
116
+ }
117
+ }
118
+ Donut.donutBlockClass = 'donut-block';
119
+ Donut.arcPathClass = 'arc-path';
120
+ Donut.arcItemClass = 'arc';
121
+ Donut.arcHighlightedClass = 'arc-highlighted';
122
+ Donut.arcClonesGroupClass = 'arc-clones';
123
+ Donut.arcShadowsGroupClass = 'arc-shadow-clones';
124
+ Donut.arcCloneClass = 'arc-clone';
125
+ Donut.arcShadowClass = 'arc-shadow-clone';
@@ -0,0 +1,10 @@
1
+ import { Model } from "../../model/model";
2
+ import { Block } from "../block/block";
3
+ import Engine from "../engine";
4
+ import { MdtChartsDataSource } from "../../config/config";
5
+ export declare class PolarManager {
6
+ static render(engine: Engine, model: Model): void;
7
+ static update(block: Block, model: Model, data: MdtChartsDataSource): void;
8
+ static updateColors(block: Block, model: Model): void;
9
+ private static renderCharts;
10
+ }
@@ -0,0 +1,55 @@
1
+ import { Legend } from "../features/legend/legend";
2
+ import { RecordOverflowAlert } from "../features/recordOverflowAlert/recordOverflowAlert";
3
+ import { Title } from "../features/title/title";
4
+ import { ElementHighlighter } from "../elementHighlighter/elementHighlighter";
5
+ import { Tooltip } from "../features/tolltip/tooltip";
6
+ import { Aggregator } from "../features/aggregator/aggregator";
7
+ import { Donut } from "./donut/donut";
8
+ export class PolarManager {
9
+ static render(engine, model) {
10
+ const options = model.options;
11
+ engine.block.renderSvg(model.blockCanvas.size);
12
+ this.renderCharts(engine.block, options.charts, engine.data, options.data.dataSource, model.chartBlock.margin, model.blockCanvas.size, model.chartSettings.donut);
13
+ Title.render(engine.block, options.title, model.otherComponents.titleBlock, model.blockCanvas.size);
14
+ Legend.render(engine.block, engine.data, options, model);
15
+ ``;
16
+ Tooltip.render(engine.block, model, engine.data, model.otherComponents.tooltipBlock);
17
+ engine.block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options, model.chartSettings.donut);
18
+ if (model.dataSettings.scope.hidedRecordsAmount !== 0 && model.options.legend.position !== 'off')
19
+ RecordOverflowAlert.render(engine.block, model.dataSettings.scope.hidedRecordsAmount, model.options.legend.position);
20
+ engine.block.getSvg()
21
+ .on('click', (e) => {
22
+ if (e.target === engine.block.getSvg().node())
23
+ engine.block.filterEventManager.clearKeysForPolar(model.chartBlock.margin, model.blockCanvas.size, options, model.chartSettings.donut);
24
+ });
25
+ }
26
+ static update(block, model, data) {
27
+ block.transitionManager.interruptTransitions();
28
+ block.removeMouseEvents();
29
+ block.filterEventManager.updateData(data[model.options.data.dataSource]);
30
+ ElementHighlighter.removeDonutArcClones(block);
31
+ ElementHighlighter.removeFilter(Donut.getAllArcGroups(block));
32
+ ElementHighlighter.toggleActivityStyle(Donut.getAllArcGroups(block), true);
33
+ Tooltip.hide(block);
34
+ const options = model.options;
35
+ Donut.update(block, data[options.data.dataSource], model.chartBlock.margin, options.charts[0], model.blockCanvas.size, model.chartSettings.donut, options.data.keyField.name)
36
+ .then(() => {
37
+ Tooltip.render(block, model, data, model.otherComponents.tooltipBlock);
38
+ block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options, model.chartSettings.donut);
39
+ });
40
+ Aggregator.update(block, data[options.data.dataSource], options.charts[0].data.valueField, model.chartSettings.donut.aggregatorPad);
41
+ Legend.update(block, data, model);
42
+ if (model.options.legend.position !== 'off')
43
+ RecordOverflowAlert.update(block, model.dataSettings.scope.hidedRecordsAmount, model.options.legend.position);
44
+ }
45
+ static updateColors(block, model) {
46
+ Legend.updateColors(block, model.options);
47
+ Donut.updateColors(block, model.options.charts[0]);
48
+ }
49
+ static renderCharts(block, charts, data, dataSource, margin, blockSize, donutSettings) {
50
+ charts.forEach((chart) => {
51
+ if (chart.type === 'donut')
52
+ Donut.render(block, data[dataSource], margin, chart, blockSize, donutSettings);
53
+ });
54
+ }
55
+ }
@@ -0,0 +1,19 @@
1
+ import { Transitions } from "../designer/designerConfig";
2
+ import { Block } from "./block/block";
3
+ interface Durations extends Transitions {
4
+ }
5
+ export declare class TransitionManager {
6
+ /**
7
+ * Анимации обновления в ms.
8
+ */
9
+ durations: Durations;
10
+ private block;
11
+ /**
12
+ * Классы "подвижных" элементов
13
+ */
14
+ private transitionableElemClasses;
15
+ constructor(block: Block, transitionsDurations?: Transitions);
16
+ interruptTransitions(): void;
17
+ private setDurations;
18
+ }
19
+ export {};
@@ -0,0 +1,64 @@
1
+ import { interrupt } from "d3-transition";
2
+ import { Axis } from "./features/axis/axis";
3
+ import { EmbeddedLabels } from "./features/embeddedLabels/embeddedLabels";
4
+ import { MarkDot } from "./features/markDots/markDot";
5
+ import { Tooltip } from "./features/tolltip/tooltip";
6
+ import { Aggregator } from "./features/aggregator/aggregator";
7
+ import { Donut } from "./polarNotation/donut/donut";
8
+ import { Area } from "./twoDimensionalNotation/area/area";
9
+ import { Bar } from "./twoDimensionalNotation/bar/bar";
10
+ import { Line } from "./twoDimensionalNotation/line/line";
11
+ export class TransitionManager {
12
+ constructor(block, transitionsDurations = null) {
13
+ /**
14
+ * Анимации обновления в ms.
15
+ */
16
+ this.durations = {
17
+ chartUpdate: 1000,
18
+ tooltipSlide: 75,
19
+ higlightedScale: 200,
20
+ markerHover: 50,
21
+ elementFadeOut: 400
22
+ };
23
+ /**
24
+ * Классы "подвижных" элементов
25
+ */
26
+ this.transitionableElemClasses = [
27
+ Tooltip.tooltipBlockClass,
28
+ Tooltip.tooltipLineClass,
29
+ Axis.axesClass,
30
+ Area.areaChartClass,
31
+ Bar.barItemClass,
32
+ Line.lineChartClass,
33
+ MarkDot.markerDotClass,
34
+ EmbeddedLabels.embeddedLabelClass,
35
+ Donut.arcPathClass,
36
+ Aggregator.aggregatorValueClass
37
+ ];
38
+ this.block = block;
39
+ if (transitionsDurations)
40
+ this.setDurations(transitionsDurations);
41
+ }
42
+ interruptTransitions() {
43
+ this.transitionableElemClasses.forEach(elemClass => {
44
+ const elementsSelection = this.block
45
+ .getSvg()
46
+ .selectAll(`.${elemClass}`)
47
+ .interrupt();
48
+ elementsSelection.nodes().forEach(node => interrupt(node));
49
+ });
50
+ this.block.getSvg().selectAll(`.${Axis.axesClass}`).selectAll('*').interrupt();
51
+ }
52
+ setDurations(durations) {
53
+ if (durations.chartUpdate !== undefined && durations.chartUpdate >= 0)
54
+ this.durations.chartUpdate = durations.chartUpdate;
55
+ if (durations.higlightedScale !== undefined && durations.higlightedScale >= 0)
56
+ this.durations.higlightedScale = durations.higlightedScale;
57
+ if (durations.elementFadeOut !== undefined && durations.elementFadeOut >= 0)
58
+ this.durations.elementFadeOut = durations.elementFadeOut;
59
+ if (durations.markerHover !== undefined && durations.markerHover >= 0)
60
+ this.durations.markerHover = durations.markerHover;
61
+ if (durations.tooltipSlide !== undefined && durations.tooltipSlide >= 0)
62
+ this.durations.tooltipSlide = durations.tooltipSlide;
63
+ }
64
+ }
@@ -0,0 +1,17 @@
1
+ import { BlockMargin, Field, Orient, TwoDimensionalChartModel } from "../../../model/model";
2
+ import { Scales } from "../../features/scale/scale";
3
+ import { Block } from "../../block/block";
4
+ import { MdtChartsDataRow, Size } from '../../../config/config';
5
+ export declare class Area {
6
+ static readonly areaChartClass = "area";
7
+ static render(block: Block, scales: Scales, data: MdtChartsDataRow[], keyField: Field, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size): void;
8
+ static update(block: Block, scales: Scales, newData: MdtChartsDataRow[], keyField: Field, margin: BlockMargin, chart: TwoDimensionalChartModel, keyAxisOrient: Orient, blockSize: Size): Promise<any>[];
9
+ static updateColors(block: Block, chart: TwoDimensionalChartModel): void;
10
+ private static renderGrouped;
11
+ private static renderSegmented;
12
+ private static updateGrouped;
13
+ private static updateSegmented;
14
+ private static updateGroupedPath;
15
+ private static updateSegmentedPath;
16
+ private static setSegmentColor;
17
+ }
@@ -0,0 +1,131 @@
1
+ import { stack } from 'd3-shape';
2
+ import { select } from 'd3-selection';
3
+ import { MarkDot } from "../../features/markDots/markDot";
4
+ import { AreaHelper } from './areaHelper';
5
+ import { DomHelper } from '../../helpers/domHelper';
6
+ import { Helper } from '../../helpers/helper';
7
+ export class Area {
8
+ static render(block, scales, data, keyField, margin, keyAxisOrient, chart, blockSize) {
9
+ if (chart.isSegmented)
10
+ this.renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart);
11
+ else
12
+ this.renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart, blockSize);
13
+ }
14
+ static update(block, scales, newData, keyField, margin, chart, keyAxisOrient, blockSize) {
15
+ let promises;
16
+ if (chart.isSegmented) {
17
+ promises = this.updateSegmented(block, scales, newData, keyField, margin, chart, keyAxisOrient);
18
+ }
19
+ else {
20
+ promises = this.updateGrouped(block, scales, newData, keyField, margin, chart, keyAxisOrient, blockSize);
21
+ }
22
+ return promises;
23
+ }
24
+ static updateColors(block, chart) {
25
+ chart.data.valueFields.forEach((_vf, valueIndex) => {
26
+ const path = block.getChartGroup(chart.index)
27
+ .select(`.${this.areaChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueIndex}`);
28
+ DomHelper.setChartStyle(path, chart.style, valueIndex, 'fill');
29
+ MarkDot.updateColors(block, chart, valueIndex);
30
+ });
31
+ }
32
+ static renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart, blockSize) {
33
+ chart.data.valueFields.forEach((field, valueIndex) => {
34
+ const area = AreaHelper.getGroupedAreaGenerator(keyAxisOrient, scales, margin, keyField.name, field.name, blockSize);
35
+ const path = block.getChartGroup(chart.index)
36
+ .append('path')
37
+ .attr('d', area(data))
38
+ .attr('class', this.areaChartClass)
39
+ .style('clip-path', `url(#${block.getClipPathId()})`)
40
+ .style('pointer-events', 'none');
41
+ DomHelper.setCssClasses(path, Helper.getCssClassesWithElementIndex(chart.cssClasses, valueIndex));
42
+ DomHelper.setChartStyle(path, chart.style, valueIndex, 'fill');
43
+ MarkDot.render(block, data, keyAxisOrient, scales, margin, keyField.name, valueIndex, field.name, chart);
44
+ });
45
+ }
46
+ static renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart) {
47
+ const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(data);
48
+ const areaGenerator = AreaHelper.getSegmentedAreaGenerator(keyAxisOrient, scales, margin, keyField.name);
49
+ const areas = block.getChartGroup(chart.index)
50
+ .selectAll(`.${this.areaChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
51
+ .data(stackedData)
52
+ .enter()
53
+ .append('path')
54
+ .attr('d', d => areaGenerator(d))
55
+ .attr('class', this.areaChartClass)
56
+ .style('clip-path', `url(#${block.getClipPathId()})`)
57
+ .style('pointer-events', 'none');
58
+ areas.each(function (d, i) {
59
+ DomHelper.setCssClasses(select(this), Helper.getCssClassesWithElementIndex(chart.cssClasses, i));
60
+ });
61
+ this.setSegmentColor(areas, chart.style.elementColors);
62
+ stackedData.forEach((dataset, index) => {
63
+ MarkDot.render(block, dataset, keyAxisOrient, scales, margin, keyField.name, index, '1', chart);
64
+ });
65
+ }
66
+ static updateGrouped(block, scales, newData, keyField, margin, chart, keyAxisOrient, blockSize) {
67
+ const promises = [];
68
+ chart.data.valueFields.forEach((field, valueIndex) => {
69
+ const areaGenerator = AreaHelper.getGroupedAreaGenerator(keyAxisOrient, scales, margin, keyField.name, field.name, blockSize);
70
+ const areaObject = block.getChartGroup(chart.index)
71
+ .select(`.${this.areaChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueIndex}`);
72
+ const prom = this.updateGroupedPath(block, areaObject, areaGenerator, newData);
73
+ promises.push(prom);
74
+ MarkDot.update(block, newData, keyAxisOrient, scales, margin, keyField.name, valueIndex, field.name, chart);
75
+ });
76
+ return promises;
77
+ }
78
+ static updateSegmented(block, scales, newData, keyField, margin, chart, keyAxisOrient) {
79
+ const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(newData);
80
+ const areaGenerator = AreaHelper.getSegmentedAreaGenerator(keyAxisOrient, scales, margin, keyField.name);
81
+ const areas = block.getChartGroup(chart.index)
82
+ .selectAll(`path.${this.areaChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
83
+ .data(stackedData);
84
+ const prom = this.updateSegmentedPath(block, areas, areaGenerator);
85
+ areas.each((dataset, index) => {
86
+ // '1' - атрибут, показывающий координаты согласно полю значения
87
+ MarkDot.update(block, dataset, keyAxisOrient, scales, margin, keyField.name, index, '1', chart);
88
+ });
89
+ return [prom];
90
+ }
91
+ static updateGroupedPath(block, areaObject, areaGenerator, newData) {
92
+ return new Promise(resolve => {
93
+ if (areaObject.size() === 0) {
94
+ resolve('');
95
+ return;
96
+ }
97
+ let areaHandler = areaObject;
98
+ if (block.transitionManager.durations.chartUpdate > 0)
99
+ areaHandler = areaHandler.interrupt()
100
+ .transition()
101
+ .duration(block.transitionManager.durations.chartUpdate)
102
+ .on('end', () => resolve(''));
103
+ areaHandler
104
+ .attr('d', areaGenerator(newData));
105
+ if (block.transitionManager.durations.chartUpdate <= 0)
106
+ resolve('');
107
+ });
108
+ }
109
+ static updateSegmentedPath(block, areasObjects, areaGenerator) {
110
+ return new Promise(resolve => {
111
+ if (areasObjects.size() === 0) {
112
+ resolve('');
113
+ return;
114
+ }
115
+ let areaHandler = areasObjects;
116
+ if (block.transitionManager.durations.chartUpdate > 0)
117
+ areaHandler = areaHandler.interrupt()
118
+ .transition()
119
+ .duration(block.transitionManager.durations.chartUpdate)
120
+ .on('end', () => resolve(''));
121
+ areaHandler
122
+ .attr('d', d => areaGenerator(d));
123
+ if (block.transitionManager.durations.chartUpdate <= 0)
124
+ resolve('');
125
+ });
126
+ }
127
+ static setSegmentColor(segments, colorPalette) {
128
+ segments.style('fill', (d, i) => colorPalette[i % colorPalette.length]);
129
+ }
130
+ }
131
+ Area.areaChartClass = 'area';
@@ -0,0 +1,9 @@
1
+ import { Area as IArea } from 'd3-shape';
2
+ import { MdtChartsDataRow, Size } from '../../../config/config';
3
+ import { BlockMargin, Orient } from "../../../model/model";
4
+ import { Scales } from "../../features/scale/scale";
5
+ export declare class AreaHelper {
6
+ static getGroupedAreaGenerator(keyAxisOrient: Orient, scales: Scales, margin: BlockMargin, keyFieldName: string, valueFieldName: string, blockSize: Size): IArea<MdtChartsDataRow>;
7
+ static getSegmentedAreaGenerator(keyAxisOrient: Orient, scales: Scales, margin: BlockMargin, keyFieldName: string): IArea<MdtChartsDataRow>;
8
+ static getZeroCoordinate(axisOrient: Orient, margin: BlockMargin, blockSize: Size): number;
9
+ }
@@ -0,0 +1,40 @@
1
+ import { area } from 'd3-shape';
2
+ import { Scale } from "../../features/scale/scale";
3
+ export class AreaHelper {
4
+ static getGroupedAreaGenerator(keyAxisOrient, scales, margin, keyFieldName, valueFieldName, blockSize) {
5
+ if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top')
6
+ return area()
7
+ .x(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.left)
8
+ .y0(d => this.getZeroCoordinate(keyAxisOrient, margin, blockSize))
9
+ .y1(d => scales.value(d[valueFieldName]) + margin.top);
10
+ if (keyAxisOrient === 'left' || keyAxisOrient === 'right')
11
+ return area()
12
+ .x0(d => this.getZeroCoordinate(keyAxisOrient, margin, blockSize))
13
+ .x1(d => scales.value(d[valueFieldName]) + margin.left)
14
+ .y(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.top);
15
+ }
16
+ static getSegmentedAreaGenerator(keyAxisOrient, scales, margin, keyFieldName) {
17
+ if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top') {
18
+ return area()
19
+ .x(d => Scale.getScaledValue(scales.key, d.data[keyFieldName]) + margin.left)
20
+ .y0(d => scales.value(d[0]) + margin.top)
21
+ .y1(d => scales.value(d[1]) + margin.top);
22
+ }
23
+ if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
24
+ return area()
25
+ .x0(d => scales.value(d[0]) + margin.left)
26
+ .x1(d => scales.value(d[1]) + margin.left)
27
+ .y(d => Scale.getScaledValue(scales.key, d.data[keyFieldName]) + margin.top);
28
+ }
29
+ }
30
+ static getZeroCoordinate(axisOrient, margin, blockSize) {
31
+ if (axisOrient === 'bottom')
32
+ return blockSize.height - margin.bottom;
33
+ if (axisOrient === 'top')
34
+ return margin.top;
35
+ if (axisOrient === 'left')
36
+ return margin.left;
37
+ if (axisOrient === 'right')
38
+ return blockSize.width - margin.right;
39
+ }
40
+ }
@@ -0,0 +1,34 @@
1
+ import { Selection, BaseType } from 'd3-selection';
2
+ import { BarChartSettings, BlockMargin, Field, Orient, TwoDimensionalChartModel } from "../../../model/model";
3
+ import { Scales } from "../../features/scale/scale";
4
+ import { Block } from "../../block/block";
5
+ import { MdtChartsDataRow, Size } from "../../../config/config";
6
+ export interface RectElemWithAttrs extends SVGElement {
7
+ attrs?: {
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ orient: 'vertical' | 'horizontal';
13
+ scaleSize: number;
14
+ };
15
+ }
16
+ export declare class Bar {
17
+ static readonly barItemClass = "bar-item";
18
+ static readonly barItemCloneClass = "bar-item-clone";
19
+ private static readonly barSegmentGroupClass;
20
+ static render(block: Block, scales: Scales, data: MdtChartsDataRow[], keyField: Field, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barSettings: BarChartSettings, barsAmounts: number[], isSegmented: boolean, firstBarIndex: number): void;
21
+ static update(block: Block, newData: MdtChartsDataRow[], scales: Scales, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barsAmounts: number[], keyField: Field, firstBarIndex: number, barSettings: BarChartSettings, isSegmented: boolean): Promise<any>[];
22
+ static updateColors(block: Block, chart: TwoDimensionalChartModel): void;
23
+ static getAllBarsForChart(block: Block, chartCssClasses: string[]): Selection<BaseType, MdtChartsDataRow, BaseType, unknown>;
24
+ private static renderGrouped;
25
+ private static renderSegmented;
26
+ private static updateGrouped;
27
+ private static updateSegmented;
28
+ private static fillBarAttrs;
29
+ private static setSegmentColor;
30
+ /**
31
+ * Устнановка координат для удобного обновления.
32
+ */
33
+ private static setInitialAttrsInfo;
34
+ }