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,97 +0,0 @@
1
- import { DomHelper } from '../../helpers/domHelper';
2
- import { Legend } from '../legend/legend';
3
- export class RecordOverflowAlert {
4
- static render(block, hidedRecordsAmount, position, chartOrientation = null) {
5
- const alertBlock = block.getWrapper()
6
- .append('div')
7
- .attr('class', this.blockClass)
8
- .text(this.getAlertText(hidedRecordsAmount, chartOrientation));
9
- const attrs = this.getBlockPositionAttrs(position, block);
10
- this.setAlertPosition(alertBlock, attrs);
11
- }
12
- static update(block, hidedRecordsAmount, position, chartOrientation = null) {
13
- let alertBlock = block.getWrapper()
14
- .select(`div.${this.blockClass}`);
15
- if (alertBlock.empty()) {
16
- if (hidedRecordsAmount === 0)
17
- return;
18
- else
19
- this.render(block, hidedRecordsAmount, position, chartOrientation);
20
- }
21
- else {
22
- if (hidedRecordsAmount === 0)
23
- alertBlock.remove();
24
- else
25
- alertBlock.text(this.getAlertText(hidedRecordsAmount, chartOrientation));
26
- }
27
- }
28
- static setAlertPosition(alertBlock, attrs) {
29
- alertBlock
30
- .style('position', 'absolute')
31
- .style('left', attrs.left)
32
- .style('right', attrs.right)
33
- .style('top', attrs.top)
34
- .style('bottom', attrs.bottom);
35
- }
36
- static getAlertText(hidedRecordsAmount, chartOrientation) {
37
- return `+ ${hidedRecordsAmount} ${this.getWordTextEndingByAmount(hidedRecordsAmount, chartOrientation)}`;
38
- }
39
- static getWordTextEndingByAmount(hidedRecordsAmount, chartOrientation) {
40
- const lastDigit = hidedRecordsAmount % 10;
41
- if (chartOrientation === 'vertical') {
42
- if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
43
- return 'столбцов';
44
- if (lastDigit === 1)
45
- return 'столбец';
46
- if (lastDigit >= 2 && lastDigit <= 4)
47
- return 'столбца';
48
- return 'столбцов';
49
- }
50
- else if (chartOrientation === 'horizontal') {
51
- if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
52
- return 'строк';
53
- if (lastDigit === 1)
54
- return 'строка';
55
- if (lastDigit >= 2 && lastDigit <= 4)
56
- return 'строки';
57
- return 'строк';
58
- }
59
- else {
60
- if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
61
- return 'категорий';
62
- if (lastDigit === 1)
63
- return 'категория';
64
- if (lastDigit >= 2 && lastDigit <= 4)
65
- return 'категории';
66
- return 'категорий';
67
- }
68
- }
69
- static getBlockPositionAttrs(position, block) {
70
- const attrs = {
71
- bottom: null,
72
- top: null,
73
- right: null,
74
- left: null
75
- };
76
- if (position === 'top') {
77
- attrs.right = '17px';
78
- attrs.top = '1rem';
79
- }
80
- if (position === 'right') {
81
- attrs.bottom = '20px';
82
- attrs.left = this.getLeftAttrForRightBlock(block) + 'px';
83
- }
84
- if (position === 'bottom') {
85
- attrs.left = '20px';
86
- attrs.bottom = '20px';
87
- }
88
- return attrs;
89
- }
90
- static getLeftAttrForRightBlock(block) {
91
- const legendBlock = block.getSvg().select(`.${Legend.objectClass}`);
92
- if (legendBlock.empty())
93
- return null;
94
- return DomHelper.getSelectionNumericAttr(legendBlock, 'x');
95
- }
96
- }
97
- RecordOverflowAlert.blockClass = 'record-overflow-alert';
@@ -1,16 +0,0 @@
1
- import { AxisScale } from 'd3-axis';
2
- import { BarChartSettings, ScaleKeyModel, ScaleValueModel } from '../../../model/model';
3
- export interface Scales {
4
- key: AxisScale<any>;
5
- value: AxisScale<any>;
6
- }
7
- export declare class Scale {
8
- static getScales(scaleKey: ScaleKeyModel, scaleValue: ScaleValueModel, bandSettings: BarChartSettings): Scales;
9
- static getScaleBandWidth(scale: AxisScale<any>): number;
10
- static getScaleStep(scale: AxisScale<any>): number;
11
- static getScaledValue(scale: AxisScale<any>, value: any): number;
12
- private static getScaleBand;
13
- private static getScaleLinear;
14
- private static getScalePoint;
15
- private static getScaleTime;
16
- }
@@ -1,74 +0,0 @@
1
- import { scaleBand, scaleLinear, scalePoint, scaleTime } from 'd3-scale';
2
- export class Scale {
3
- static getScales(scaleKey, scaleValue, bandSettings) {
4
- const scales = {
5
- key: null,
6
- value: null
7
- };
8
- if (scaleKey.type === 'band')
9
- scales.key = this.getScaleBand(scaleKey.domain, scaleKey.range, bandSettings, scaleKey.elementsAmount);
10
- else if (scaleKey.type === 'point')
11
- scales.key = this.getScalePoint(scaleKey.domain, scaleKey.range);
12
- if (scaleValue.type === 'linear')
13
- scales.value = this.getScaleLinear(scaleValue.domain, scaleValue.range);
14
- else if (scaleValue.type === 'datetime')
15
- scales.value = this.getScaleTime(scaleValue.domain, scaleValue.range);
16
- return scales;
17
- }
18
- static getScaleBandWidth(scale) {
19
- if (scale.bandwidth && scale.bandwidth() !== 0) {
20
- return scale.bandwidth();
21
- }
22
- else if (scale.step) {
23
- return scale.step();
24
- }
25
- }
26
- static getScaleStep(scale) {
27
- if (scale.step) {
28
- return scale.step();
29
- }
30
- }
31
- static getScaledValue(scale, value) {
32
- if (scale.bandwidth && scale.bandwidth() !== 0) {
33
- return scale(value) + this.getScaleBandWidth(scale) / 2;
34
- }
35
- return scale(value);
36
- }
37
- static getScaleBand(domain, range, bandSettings, elementsInGroupAmount) {
38
- const scale = scaleBand()
39
- .domain(domain)
40
- .range([range.start, range.end]);
41
- const bandSize = scale.bandwidth();
42
- if (bandSettings.groupMinDistance < bandSize) {
43
- scale.paddingInner(bandSettings.groupMinDistance / bandSize);
44
- scale.paddingOuter(bandSettings.groupMinDistance / bandSize / 2);
45
- }
46
- // Padding inner = 10. If bandwidth more than needed, paddingInner is increased to number less than 35
47
- let paddingInner = bandSettings.groupMinDistance;
48
- while (scale.bandwidth() > bandSettings.maxBarWidth * elementsInGroupAmount + bandSettings.barDistance * (elementsInGroupAmount - 1) && paddingInner < bandSettings.groupMaxDistance) {
49
- scale.paddingInner(++paddingInner / bandSize);
50
- }
51
- // if bandwidth more than all bars widths in group + distance between it + distance between groups
52
- let paddingOuter = 1;
53
- while (scale.step() > bandSettings.maxBarWidth * elementsInGroupAmount + bandSettings.groupMaxDistance + bandSettings.barDistance * (elementsInGroupAmount - 1)) {
54
- scale.paddingOuter(++paddingOuter / bandSize);
55
- }
56
- return scale;
57
- }
58
- static getScaleLinear(domain, range) {
59
- return scaleLinear()
60
- .domain(domain)
61
- .range([range.start, range.end]);
62
- }
63
- static getScalePoint(domain, range) {
64
- return scalePoint()
65
- .domain(domain)
66
- .range([range.start, range.end]);
67
- }
68
- static getScaleTime(domain, range) {
69
- return scaleTime()
70
- .domain(domain)
71
- .range([range.start, range.end])
72
- .nice();
73
- }
74
- }
@@ -1,11 +0,0 @@
1
- import { Selection } from 'd3-selection';
2
- import { Block } from "../../block/block";
3
- import { BlockMargin } from '../../../model/model';
4
- import { Size } from "../../../config/config";
5
- export declare class TipBox {
6
- static readonly tipBoxClass = "tipbox";
7
- static renderOrGet(block: Block, margin: BlockMargin, blockSize: Size): Selection<SVGRectElement, unknown, HTMLElement, any>;
8
- static get(block: Block): Selection<SVGRectElement, unknown, HTMLElement, any>;
9
- static clearEvents(block: Block): void;
10
- private static renderBlock;
11
- }
@@ -1,32 +0,0 @@
1
- import { TipBoxHelper } from './tipBoxHelper';
2
- export class TipBox {
3
- static renderOrGet(block, margin, blockSize) {
4
- const attributes = TipBoxHelper.getAttributes(margin, blockSize);
5
- return this.renderBlock(block, attributes);
6
- }
7
- static get(block) {
8
- return block.getSvg().select(`.${this.tipBoxClass}`);
9
- }
10
- static clearEvents(block) {
11
- block.getSvg()
12
- .select(`.${this.tipBoxClass}`)
13
- .on('mousemove', null)
14
- .on('mouseleave', null)
15
- .on('click', null);
16
- }
17
- static renderBlock(block, attributes) {
18
- let tipBox = block.getSvg()
19
- .select(`rect.${this.tipBoxClass}`);
20
- if (tipBox.empty())
21
- tipBox = block.getSvg()
22
- .append('rect')
23
- .attr('class', this.tipBoxClass)
24
- .attr('x', attributes.x)
25
- .attr('y', attributes.y)
26
- .attr('width', attributes.width)
27
- .attr('height', attributes.height)
28
- .style('opacity', 0);
29
- return tipBox;
30
- }
31
- }
32
- TipBox.tipBoxClass = 'tipbox';
@@ -1,16 +0,0 @@
1
- import { AxisScale } from "d3-axis";
2
- import { ChartOrientation, Size } from "../../../config/config";
3
- import { BlockMargin, ScaleKeyType } from "../../../model/model";
4
- export interface TipBoxAttributes {
5
- x: number;
6
- y: number;
7
- width: number;
8
- height: number;
9
- }
10
- export declare class TipBoxHelper {
11
- static getKeyValueByPointer(pointer: [number, number], chartOrient: ChartOrientation, margin: BlockMargin, blockSize: Size, scaleKey: AxisScale<any>, scaleKeyType: ScaleKeyType): string;
12
- static getAttributes(margin: BlockMargin, blockSize: Size): TipBoxAttributes;
13
- private static getKeyIndex;
14
- private static getKeyIndexOfPoint;
15
- private static getKeyIndexOfBand;
16
- }
@@ -1,48 +0,0 @@
1
- import { Scale } from "../scale/scale";
2
- export class TipBoxHelper {
3
- static getKeyValueByPointer(pointer, chartOrient, margin, blockSize, scaleKey, scaleKeyType) {
4
- const index = TipBoxHelper.getKeyIndex(pointer, chartOrient, margin, blockSize, scaleKey, scaleKeyType);
5
- let keyValue = scaleKey.domain()[index];
6
- if (index >= scaleKey.domain().length)
7
- keyValue = scaleKey.domain()[scaleKey.domain().length - 1];
8
- return keyValue;
9
- }
10
- static getAttributes(margin, blockSize) {
11
- const pad = 5;
12
- return {
13
- x: margin.left - pad,
14
- y: margin.top - pad,
15
- width: blockSize.width - margin.left - margin.right + pad * 2,
16
- height: blockSize.height - margin.top - margin.bottom + pad * 2,
17
- };
18
- }
19
- static getKeyIndex(pointer, chartOrient, margin, blockSize, scaleKey, scaleKeyType) {
20
- const pointerAxisType = chartOrient === 'vertical' ? 0 : 1; // 0 - координата поинтера по оси x, 1 - по оси y
21
- const marginByOrient = chartOrient === 'vertical' ? margin.left : margin.top;
22
- const scaleStep = Scale.getScaleStep(scaleKey);
23
- if (scaleKeyType === 'point') {
24
- return this.getKeyIndexOfPoint(pointer, scaleStep, marginByOrient, pointerAxisType);
25
- }
26
- else {
27
- return this.getKeyIndexOfBand(pointer, scaleStep, marginByOrient, pointerAxisType, blockSize, margin, chartOrient, scaleKey);
28
- }
29
- }
30
- static getKeyIndexOfPoint(pointer, scaleStep, marginByOrient, pointerAxisType) {
31
- const point = pointer[pointerAxisType] - marginByOrient + scaleStep / 2;
32
- if (point < 0)
33
- return 0;
34
- return Math.floor(point / scaleStep);
35
- }
36
- static getKeyIndexOfBand(pointer, scaleStep, marginByOrient, pointerAxisType, blockSize, margin, chartOrient, scaleKey) {
37
- const chartBlockSizeByDir = chartOrient === 'vertical'
38
- ? blockSize.width - margin.left - margin.right
39
- : blockSize.height - margin.top - margin.bottom;
40
- const outerPadding = chartBlockSizeByDir - scaleStep * scaleKey.domain().length;
41
- if (pointer[pointerAxisType] - marginByOrient - 1 < outerPadding / 2)
42
- return 0; // Самый первый элемент
43
- if (pointer[pointerAxisType] - marginByOrient - 1 + outerPadding / 2 > chartBlockSizeByDir)
44
- return scaleKey.domain().length - 1; // последний индекс
45
- const point = pointer[pointerAxisType] - outerPadding / 2 - marginByOrient - 1;
46
- return Math.floor(point / scaleStep);
47
- }
48
- }
@@ -1,9 +0,0 @@
1
- import { Size } from '../../../config/config';
2
- import { TitleBlockModel } from "../../../model/model";
3
- import { Block } from "../../block/block";
4
- export declare class Title {
5
- static render(block: Block, text: string, titleBlockModel: TitleBlockModel, blockSize: Size): void;
6
- private static fillTitleBlockAttributes;
7
- private static getTitleAttributes;
8
- private static setTitleTooltip;
9
- }
@@ -1,35 +0,0 @@
1
- import { DomHelper } from '../../helpers/domHelper';
2
- export class Title {
3
- static render(block, text, titleBlockModel, blockSize) {
4
- const titleBlock = block.getSvg()
5
- .append('text')
6
- .attr('class', 'chart-title');
7
- const titleCoordinate = this.getTitleAttributes(blockSize, titleBlockModel);
8
- this.fillTitleBlockAttributes(titleBlock, titleCoordinate, text);
9
- this.setTitleTooltip(titleBlock, text);
10
- }
11
- static fillTitleBlockAttributes(titleBlock, attributes, text) {
12
- titleBlock
13
- .attr('x', attributes.x)
14
- .attr('y', attributes.y)
15
- .attr('dominant-baseline', attributes.dominantBaseline)
16
- .text(text);
17
- DomHelper.cropSvgLabels(titleBlock, attributes.maxWidth);
18
- }
19
- static getTitleAttributes(blockSize, titleBlockModel) {
20
- const coordinate = {
21
- x: 0,
22
- y: 0,
23
- maxWidth: 0,
24
- dominantBaseline: "hanging"
25
- };
26
- coordinate.x = titleBlockModel.margin.left;
27
- coordinate.y = titleBlockModel.margin.top;
28
- coordinate.maxWidth = blockSize.width - titleBlockModel.margin.left - titleBlockModel.margin.right;
29
- return coordinate;
30
- }
31
- static setTitleTooltip(titleBlock, text) {
32
- titleBlock.append('title')
33
- .text(text);
34
- }
35
- }
@@ -1,19 +0,0 @@
1
- import { Model } from "../../../model/model";
2
- import { Block } from "../../block/block";
3
- import { MdtChartsDataSource } from "../../../config/config";
4
- import { Scales } from '../scale/scale';
5
- import { TooltipSettings } from '../../../designer/designerConfig';
6
- export declare class Tooltip {
7
- static readonly tooltipBlockClass = "tooltip-block";
8
- static readonly tooltipLineClass = "tooltip-line";
9
- static readonly tooltipWrapperClass = "tooltip-wrapper";
10
- static readonly tooltipContentClass = "tooltip-content";
11
- static readonly tooltipArrowClass = "tooltip-arrow";
12
- static render(block: Block, model: Model, data: MdtChartsDataSource, tooltipOptions: TooltipSettings, scales?: Scales): void;
13
- static hide(block: Block): void;
14
- private static renderTooltipFor2DCharts;
15
- private static renderTooltipForIntervalCharts;
16
- private static renderTooltipForPolar;
17
- private static renderLineTooltip;
18
- private static renderTooltipForDonut;
19
- }
@@ -1,180 +0,0 @@
1
- import { select, pointer, } from 'd3-selection';
2
- import { TooltipDomHelper } from "./tooltipDomHelper";
3
- import { Donut } from "../../polarNotation/donut/donut";
4
- import { TooltipComponentsManager } from './tooltipComponentsManager';
5
- import { ElementHighlighter } from '../../elementHighlighter/elementHighlighter';
6
- import { DonutHelper } from '../../polarNotation/donut/DonutHelper';
7
- import { TipBox } from '../tipBox/tipBox';
8
- import { TipBoxHelper } from '../tipBox/tipBoxHelper';
9
- import { Helper } from '../../helpers/helper';
10
- import { TooltipHelper } from './tooltipHelper';
11
- import { DomHelper } from '../../helpers/domHelper';
12
- export class Tooltip {
13
- static render(block, model, data, tooltipOptions, scales) {
14
- TooltipComponentsManager.renderTooltipWrapper(block);
15
- const withTooltipIndex = model.options.charts.findIndex((chart) => chart.tooltip.show);
16
- if (withTooltipIndex !== -1) {
17
- if (model.options.type === '2d') {
18
- this.renderTooltipFor2DCharts(block, data, model.blockCanvas.size, model.chartBlock.margin, scales, model.options, tooltipOptions);
19
- }
20
- else if (model.options.type === 'polar') {
21
- this.renderTooltipForPolar(block, model.options, data, model.blockCanvas.size, model.chartBlock.margin, DonutHelper.getThickness(model.chartSettings.donut, model.blockCanvas.size, model.chartBlock.margin), model.otherComponents.tooltipBlock);
22
- }
23
- else if (model.options.type === 'interval') {
24
- this.renderTooltipForIntervalCharts(block, data, model.blockCanvas.size, model.chartBlock.margin, scales, model.options, tooltipOptions);
25
- }
26
- }
27
- }
28
- static hide(block) {
29
- TooltipComponentsManager.hideComponent(block.getWrapper().select(`.${this.tooltipBlockClass}`));
30
- TooltipComponentsManager.hideComponent(block.getSvg().select(`.${this.tooltipLineClass}`));
31
- }
32
- static renderTooltipFor2DCharts(block, data, blockSize, margin, scales, options, tooltipOptions) {
33
- if (scales.key.domain().length === 0)
34
- return;
35
- const tooltipParams = {
36
- type: '2d',
37
- scales,
38
- margin,
39
- blockSize,
40
- charts: options.charts,
41
- chartOrientation: options.orient,
42
- keyAxisOrient: options.axis.key.orient,
43
- dataOptions: options.data,
44
- scaleKeyModel: options.scale.key,
45
- tooltipSettings: tooltipOptions,
46
- tooltipOptions: options.tooltip
47
- };
48
- this.renderLineTooltip(block, data, tooltipParams);
49
- }
50
- static renderTooltipForIntervalCharts(block, data, blockSize, margin, scales, options, tooltipOptions) {
51
- if (scales.key.domain().length === 0)
52
- return;
53
- const tooltipParams = {
54
- type: 'interval',
55
- scales,
56
- margin,
57
- blockSize,
58
- charts: options.charts,
59
- chartOrientation: options.orient,
60
- keyAxisOrient: options.axis.key.orient,
61
- dataOptions: options.data,
62
- scaleKeyModel: options.scale.key,
63
- tooltipSettings: tooltipOptions,
64
- tooltipOptions: options.tooltip
65
- };
66
- this.renderLineTooltip(block, data, tooltipParams);
67
- }
68
- static renderTooltipForPolar(block, options, data, blockSize, margin, chartThickness, tooltipOptions) {
69
- const attrTransform = block.getSvg().select(`.${Donut.donutBlockClass}`).attr('transform');
70
- const translateNums = Helper.getTranslateNumbers(attrTransform);
71
- const arcItems = Donut.getAllArcGroups(block);
72
- this.renderTooltipForDonut(block, arcItems, data, options.data, options.charts[0], blockSize, margin, chartThickness, tooltipOptions, options.tooltip, { x: translateNums[0], y: translateNums[1] });
73
- }
74
- static renderLineTooltip(block, data, args) {
75
- const tooltipBlock = TooltipComponentsManager.renderTooltipBlock(block);
76
- const tooltipContent = TooltipComponentsManager.renderTooltipContentBlock(tooltipBlock);
77
- const tooltipLine = TooltipComponentsManager.renderTooltipLine(block);
78
- const tipBox = TipBox.renderOrGet(block, args.margin, args.blockSize);
79
- let currentKey = null;
80
- tipBox.on('mousemove', function (e) {
81
- var _a, _b;
82
- const keyValue = e.detail.keyValue || TipBoxHelper.getKeyValueByPointer(pointer(e, this), args.chartOrientation, args.margin, args.blockSize, args.scales.key, args.scaleKeyModel.type);
83
- if (args.tooltipSettings.position === 'followCursor') {
84
- const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(e.detail.pointer || pointer(e, this), block.getSvg().node().getBoundingClientRect(), tooltipContent.node().getBoundingClientRect(), window.innerWidth, window.innerHeight);
85
- TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, 0);
86
- }
87
- if (!currentKey || currentKey !== keyValue) {
88
- TooltipComponentsManager.showComponent(tooltipBlock);
89
- if (args.type === '2d')
90
- TooltipDomHelper.fillForMulty2DCharts(tooltipContent, args.charts.filter(ch => ch.tooltip.show), data, args.dataOptions, keyValue, (_a = args.tooltipOptions) === null || _a === void 0 ? void 0 : _a.html);
91
- else
92
- TooltipDomHelper.fillForIntervalChart(tooltipContent, args.charts.filter(ch => ch.tooltip.show), data, args.dataOptions, keyValue, (_b = args.tooltipOptions) === null || _b === void 0 ? void 0 : _b.html);
93
- if (args.tooltipSettings.position === 'fixed') {
94
- const tooltipCoordinate = TooltipHelper.getTooltipFixedCoordinate(args.scales.key, args.margin, keyValue, block.getSvg().node().getBoundingClientRect(), tooltipContent.node().getBoundingClientRect(), args.keyAxisOrient, window.innerWidth, window.innerHeight);
95
- TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, block.transitionManager.durations.tooltipSlide);
96
- }
97
- const tooltipLineAttributes = TooltipHelper.getTooltipLineAttributes(args.scales.key, args.margin, keyValue, args.chartOrientation, args.blockSize);
98
- TooltipComponentsManager.setTooltipLineAttributes(tooltipLine, tooltipLineAttributes, block.transitionManager.durations.tooltipSlide);
99
- TooltipComponentsManager.showComponent(tooltipLine);
100
- //TODO: append highlight for interval / Extract this highlighting in method
101
- if (args.type === '2d') {
102
- args.charts.forEach(chart => {
103
- const elements = DomHelper.get2DChartElements(block, chart);
104
- if (!block.filterEventManager.isSelected(currentKey)) {
105
- const oldElements = DomHelper.getChartElementsByKeys(elements, chart.isSegmented, args.dataOptions.keyField.name, [currentKey]);
106
- if (chart.type !== 'bar' && !chart.markersOptions.show)
107
- ElementHighlighter.toggleMarkDotVisible(oldElements, false);
108
- ElementHighlighter.toggle2DElements(oldElements, false, chart.type, block.transitionManager.durations.markerHover);
109
- if (block.filterEventManager.getSelectedKeys().length > 0) {
110
- ElementHighlighter.toggleActivityStyle(oldElements, false);
111
- }
112
- }
113
- const selectedElements = DomHelper.getChartElementsByKeys(elements, chart.isSegmented, args.dataOptions.keyField.name, [keyValue]);
114
- if (chart.type !== 'bar' && !chart.markersOptions.show)
115
- ElementHighlighter.toggleMarkDotVisible(selectedElements, true);
116
- ElementHighlighter.toggleActivityStyle(selectedElements, true);
117
- if (block.filterEventManager.getSelectedKeys().length === 0 || block.filterEventManager.isSelected(keyValue)) {
118
- ElementHighlighter.toggle2DElements(selectedElements, true, chart.type, block.transitionManager.durations.markerHover);
119
- }
120
- });
121
- }
122
- currentKey = keyValue;
123
- }
124
- });
125
- tipBox.on('mouseleave', function () {
126
- TooltipComponentsManager.hideComponent(tooltipBlock);
127
- TooltipComponentsManager.hideComponent(tooltipLine);
128
- if (args.type === '2d')
129
- ElementHighlighter.removeUnselected2DHighlight(block, args.dataOptions.keyField.name, args.charts, block.transitionManager.durations.markerHover);
130
- currentKey = null;
131
- });
132
- }
133
- static renderTooltipForDonut(block, elements, data, dataOptions, chart, blockSize, margin, donutThickness, tooltipSettings, tooltipOptions, translate) {
134
- const tooltipBlock = TooltipComponentsManager.renderTooltipBlock(block);
135
- const tooltipContent = TooltipComponentsManager.renderTooltipContentBlock(tooltipBlock);
136
- let tooltipArrow;
137
- if (tooltipSettings.position === 'fixed')
138
- tooltipArrow = TooltipComponentsManager.renderTooltipArrow(tooltipBlock);
139
- if (tooltipSettings.position === 'followCursor') {
140
- elements.on('mousemove', function (e) {
141
- const pointerCoordinate = !pointer(e, block.getSvg().node())[0] ? e.detail.pointer : pointer(e, block.getSvg().node());
142
- const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(pointerCoordinate, block.getSvg().node().getBoundingClientRect(), tooltipContent.node().getBoundingClientRect(), window.innerWidth, window.innerHeight);
143
- TooltipComponentsManager.setBlockCoordinate(tooltipBlock, tooltipCoordinate);
144
- });
145
- }
146
- elements.on('mouseover', function (e, dataRow) {
147
- TooltipComponentsManager.showComponent(tooltipBlock);
148
- TooltipDomHelper.fillForPolarChart(tooltipContent, chart, data, dataOptions, dataRow.data[dataOptions.keyField.name], select(this).select('path').style('fill'), tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.html);
149
- if (tooltipSettings.position === 'fixed') {
150
- const coordinatePointer = TooltipDomHelper.getRecalcedCoordinateByArrow(DonutHelper.getArcCentroid(blockSize, margin, dataRow, donutThickness), tooltipBlock, blockSize, tooltipArrow, translate.x, translate.y);
151
- coordinatePointer[0] = coordinatePointer[0] + translate.x;
152
- coordinatePointer[1] = coordinatePointer[1] + translate.y;
153
- const tooltipCoordinate = TooltipHelper.getCoordinateByPointer(coordinatePointer);
154
- TooltipComponentsManager.setBlockCoordinate(tooltipBlock, tooltipCoordinate);
155
- }
156
- ElementHighlighter.toggleActivityStyle(select(this), true);
157
- const clones = Donut.getAllArcClones(block)
158
- .filter((d) => d.data[dataOptions.keyField.name] === dataRow.data[dataOptions.keyField.name]);
159
- if (clones.nodes().length === 0 && (block.filterEventManager.getSelectedKeys().length === 0 || block.filterEventManager.isSelected(dataRow.data[dataOptions.keyField.name]))) {
160
- ElementHighlighter.renderArcCloneAndHighlight(block, margin, select(this), blockSize, donutThickness);
161
- }
162
- });
163
- elements.on('mouseleave', function (e, dataRow) {
164
- TooltipComponentsManager.hideComponent(tooltipBlock);
165
- if (!block.filterEventManager.isSelected(dataRow.data[dataOptions.keyField.name])) {
166
- ElementHighlighter.removeCloneForElem(block, dataOptions.keyField.name, select(this));
167
- ElementHighlighter.removeShadowClone(block, dataOptions.keyField.name, select(this), margin, blockSize, donutThickness);
168
- ElementHighlighter.toggleDonutHighlightState(select(this), margin, blockSize, donutThickness, block.transitionManager.durations.higlightedScale, false);
169
- if (block.filterEventManager.getSelectedKeys().length > 0) {
170
- ElementHighlighter.toggleActivityStyle(select(this), false);
171
- }
172
- }
173
- });
174
- }
175
- }
176
- Tooltip.tooltipBlockClass = 'tooltip-block';
177
- Tooltip.tooltipLineClass = 'tooltip-line';
178
- Tooltip.tooltipWrapperClass = 'tooltip-wrapper';
179
- Tooltip.tooltipContentClass = 'tooltip-content';
180
- Tooltip.tooltipArrowClass = 'tooltip-arrow';
@@ -1,17 +0,0 @@
1
- import { Selection, BaseType } from 'd3-selection';
2
- import { Block } from "../../block/block";
3
- import { TooltipCoordinate, TooltipLineAttributes } from "./tooltipDomHelper";
4
- import { ChartOrientation } from "../../../config/config";
5
- export declare class TooltipComponentsManager {
6
- static showComponent(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): void;
7
- static hideComponent(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): void;
8
- static renderTooltipWrapper(block: Block): void;
9
- static renderTooltipBlock(block: Block, translateX?: number, translateY?: number): Selection<HTMLElement, unknown, HTMLElement, any>;
10
- static renderTooltipContentBlock(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): Selection<HTMLDivElement, unknown, HTMLElement, any>;
11
- static renderTooltipLine(block: Block): Selection<SVGLineElement, unknown, HTMLElement, any>;
12
- static setTooltipLineAttributes(tooltipLine: Selection<SVGLineElement, unknown, HTMLElement, any>, attributes: TooltipLineAttributes, transition: number): void;
13
- static getLineWidth(tooltipLine: Selection<BaseType, any, BaseType, any>): number;
14
- static renderTooltipArrow(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): Selection<BaseType, unknown, HTMLElement, any>;
15
- static setBlockCoordinate(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>, tooltipCoordinate: TooltipCoordinate): void;
16
- static setLineTooltipCoordinate(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>, tooltipCoordinate: TooltipCoordinate, chartOrientation: ChartOrientation, transition?: number): void;
17
- }