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,24 +0,0 @@
1
- export class AxisDomHelper {
2
- static updateAxisElement(axisGenerator, axisElement, translate, transitionDuration = 0) {
3
- return new Promise(resolve => {
4
- let axisHandler = axisElement;
5
- if (transitionDuration > 0) {
6
- axisHandler = axisHandler
7
- .interrupt()
8
- .transition()
9
- .duration(transitionDuration)
10
- .on('end', () => resolve('updated'));
11
- }
12
- axisHandler.attr('transform', `translate(${translate.translateX}, ${translate.translateY})`)
13
- .call(axisGenerator.bind(this));
14
- if (transitionDuration <= 0)
15
- resolve('updated');
16
- });
17
- }
18
- static rotateElementsBack(axisElement) {
19
- axisElement.selectAll('.tick text')
20
- .attr('transform', null)
21
- .attr('text-anchor', 'middle')
22
- .attr('x', null);
23
- }
24
- }
@@ -1,9 +0,0 @@
1
- import { AxisScale, Axis as IAxis } from 'd3-axis';
2
- import { AxisModelOptions, Orient, ScaleKeyModel, ScaleValueModel } from "../../../model/model";
3
- export declare class AxisHelper {
4
- static getAxisByOrient(orient: Orient, scale: AxisScale<any>): IAxis<any>;
5
- static setLabelsSettings(axisGenerator: IAxis<any>, range: number[], scaleOptions: ScaleValueModel): void;
6
- static getBaseAxisGenerator(axisOptions: AxisModelOptions, scale: AxisScale<any>, scaleOptions: ScaleKeyModel | ScaleValueModel): IAxis<any>;
7
- private static removeTicks;
8
- private static setNumTickFormat;
9
- }
@@ -1,53 +0,0 @@
1
- import { axisTop, axisBottom, axisLeft, axisRight } from 'd3-axis';
2
- import { max, min } from 'd3-array';
3
- import { format } from 'd3-format';
4
- import { AxisLabelHelper } from './axisLabelDomHelper';
5
- const MINIMAL_STEP_SIZE = 40;
6
- export class AxisHelper {
7
- static getAxisByOrient(orient, scale) {
8
- if (orient === 'top')
9
- return axisTop(scale);
10
- if (orient === 'bottom')
11
- return axisBottom(scale);
12
- if (orient === 'left')
13
- return axisLeft(scale);
14
- if (orient === 'right')
15
- return axisRight(scale);
16
- }
17
- static setLabelsSettings(axisGenerator, range, scaleOptions) {
18
- const axisLength = range[1] - range[0];
19
- let ticksAmount;
20
- if (axisLength / 10 < MINIMAL_STEP_SIZE) {
21
- if (Math.floor(axisLength / MINIMAL_STEP_SIZE) > 2) {
22
- ticksAmount = Math.floor(axisLength / MINIMAL_STEP_SIZE);
23
- axisGenerator.ticks(Math.floor(axisLength / MINIMAL_STEP_SIZE));
24
- }
25
- else {
26
- ticksAmount = 2;
27
- axisGenerator.tickValues([min(scaleOptions.domain), max(scaleOptions.domain)]);
28
- }
29
- }
30
- if (scaleOptions.type === 'linear') {
31
- axisGenerator.scale().ticks(ticksAmount).forEach((value) => {
32
- if (format('~s')(value).indexOf('.') !== -1) {
33
- this.setNumTickFormat(axisGenerator, '.2s');
34
- }
35
- });
36
- }
37
- }
38
- static getBaseAxisGenerator(axisOptions, scale, scaleOptions) {
39
- const axisGenerator = AxisHelper.getAxisByOrient(axisOptions.orient, scale);
40
- if (!axisOptions.ticks.flag)
41
- this.removeTicks(axisGenerator);
42
- AxisLabelHelper.setAxisLabelPaddingByOrient(axisGenerator, axisOptions);
43
- if (scaleOptions.type === 'linear')
44
- this.setNumTickFormat(axisGenerator);
45
- return axisGenerator;
46
- }
47
- static removeTicks(axis) {
48
- axis.tickSize(0);
49
- }
50
- static setNumTickFormat(axis, formatName = '~s') {
51
- axis.tickFormat(format(formatName));
52
- }
53
- }
@@ -1,17 +0,0 @@
1
- import { Selection, BaseType } from 'd3-selection';
2
- import { AxisScale, Axis as IAxis } from 'd3-axis';
3
- import { AxisModelOptions, Orient, ScaleKeyModel, ScaleValueModel } from "../../../model/model";
4
- import { Block } from "../../block/block";
5
- import { Size } from '../../../config/config';
6
- export declare class AxisLabelHelper {
7
- static setTitles(axisElement: Selection<SVGGElement, unknown, BaseType, any>): void;
8
- static setAxisLabelPaddingByOrient(axis: IAxis<any>, axisOptions: AxisModelOptions): void;
9
- static rotateLabels(axisElement: Selection<SVGGElement, unknown, HTMLElement, any>, keyAxisOrient: Orient): void;
10
- static cropLabels(block: Block, scale: AxisScale<any>, scaleOptions: ScaleKeyModel | ScaleValueModel, axisOptions: AxisModelOptions, blockSize: Size): void;
11
- static hideLabels(axisElement: Selection<SVGGElement, unknown, BaseType, unknown>): void;
12
- static alignLabelsInKeyAxis(axisOptions: AxisModelOptions, axisElement: Selection<SVGGElement, unknown, HTMLElement, any>): void;
13
- private static alignLabelsInVerticalAxis;
14
- private static cropAndAlignExtremeLabels;
15
- private static getTranslateNumber;
16
- static wrapHandler(textBlocks: Selection<SVGGElement, unknown, BaseType, any>, maxWidth: number): void;
17
- }
@@ -1,143 +0,0 @@
1
- import { select } from 'd3-selection';
2
- import { AXIS_HORIZONTAL_LABEL_PADDING, AXIS_VERTICAL_LABEL_PADDING } from "../../../model/marginModel";
3
- import { DomHelper } from '../../helpers/domHelper';
4
- import { Helper } from '../../helpers/helper';
5
- export class AxisLabelHelper {
6
- static setTitles(axisElement) {
7
- axisElement.selectAll('.tick text')
8
- .each(function (d, i) {
9
- const tickTitle = select(this).select('title');
10
- if (tickTitle.empty())
11
- select(this)
12
- .append('title')
13
- .text(d);
14
- else
15
- tickTitle.text(d);
16
- });
17
- }
18
- static setAxisLabelPaddingByOrient(axis, axisOptions) {
19
- let axisLabelPadding = AXIS_HORIZONTAL_LABEL_PADDING;
20
- if (axisOptions.orient === 'left' || axisOptions.orient === 'right')
21
- axisLabelPadding = AXIS_VERTICAL_LABEL_PADDING;
22
- axis.tickPadding(axisLabelPadding);
23
- }
24
- static rotateLabels(axisElement, keyAxisOrient) {
25
- const labelBlocks = axisElement.selectAll('text');
26
- labelBlocks.attr('transform', 'rotate(-90)');
27
- if (keyAxisOrient === 'bottom') {
28
- labelBlocks
29
- .attr('text-anchor', 'end')
30
- .attr('x', -AXIS_HORIZONTAL_LABEL_PADDING)
31
- .attr('y', -4);
32
- }
33
- else if (keyAxisOrient === 'top') {
34
- labelBlocks
35
- .attr('text-anchor', 'start')
36
- .attr('x', AXIS_HORIZONTAL_LABEL_PADDING)
37
- .attr('y', 6);
38
- }
39
- }
40
- static cropLabels(block, scale, scaleOptions, axisOptions, blockSize) {
41
- if (scaleOptions.type === 'point' || scaleOptions.type === 'band') {
42
- const axisTextBlocks = block.getSvg().select(`.${axisOptions.cssClass}`).selectAll('text');
43
- let maxLabelSize;
44
- if ((axisOptions.orient === 'left' || axisOptions.orient === 'right') || (axisOptions.type === 'key' && axisOptions.labels.position === 'rotated'))
45
- maxLabelSize = axisOptions.labels.maxSize;
46
- else
47
- maxLabelSize = scale.step() - 4;
48
- DomHelper.cropSvgLabels(axisTextBlocks, maxLabelSize);
49
- if (scaleOptions.type === 'point' && axisOptions.labels.position === 'straight' && (axisOptions.orient === 'top' || axisOptions.orient === 'bottom')) {
50
- this.cropAndAlignExtremeLabels(block, maxLabelSize, axisOptions, blockSize);
51
- }
52
- }
53
- }
54
- static hideLabels(axisElement) {
55
- axisElement.selectAll('.tick text').style('display', 'none');
56
- }
57
- static alignLabelsInKeyAxis(axisOptions, axisElement) {
58
- if (axisOptions.orient === 'left')
59
- this.alignLabelsInVerticalAxis(axisElement, 'start', axisOptions.labels.maxSize, true);
60
- else if (axisOptions.orient === 'right')
61
- this.alignLabelsInVerticalAxis(axisElement, 'start', axisOptions.labels.maxSize, false);
62
- }
63
- static alignLabelsInVerticalAxis(axisElement, anchor, maxLabelSize, changeCoordinate) {
64
- const axisTextBlocks = axisElement.selectAll('text');
65
- const spans = axisElement.selectAll('tspan');
66
- axisTextBlocks.attr('text-anchor', anchor);
67
- spans.attr('text-anchor', anchor);
68
- if (changeCoordinate) {
69
- axisTextBlocks.attr('x', -(maxLabelSize + AXIS_VERTICAL_LABEL_PADDING));
70
- spans.attr('x', -(maxLabelSize + AXIS_VERTICAL_LABEL_PADDING));
71
- }
72
- else {
73
- spans.attr('x', AXIS_VERTICAL_LABEL_PADDING);
74
- }
75
- }
76
- static cropAndAlignExtremeLabels(block, maxLabelSize, axisOptions, blockSize) {
77
- const lastTick = block.getSvg().select(`.${axisOptions.cssClass}`).select('.tick:last-of-type');
78
- const lastLabel = lastTick.select('text');
79
- if (lastTick.size() === 0 || lastLabel.size() === 0)
80
- return;
81
- const tickTranslateX = Helper.getTranslateNumbers(lastTick.attr('transform'))[0];
82
- const marginRight = blockSize.width - axisOptions.translate.translateX - tickTranslateX;
83
- if (tickTranslateX + lastLabel.node().getBBox().width + axisOptions.translate.translateX > blockSize.width) {
84
- lastLabel.attr('text-anchor', 'start');
85
- lastLabel.attr('transform', `translate(${this.getTranslateNumber(maxLabelSize, lastLabel, marginRight)}, 0)`);
86
- DomHelper.cropSvgLabels(lastLabel, maxLabelSize / 2 + marginRight);
87
- }
88
- const firstLabel = block.getSvg()
89
- .select(`.${axisOptions.cssClass}`)
90
- .select('.tick:first-of-type')
91
- .select('text');
92
- const axisElementTranslate = Helper.getTranslateNumbers(block.getSvg().select(`.${axisOptions.cssClass}`).attr('transform'))[0];
93
- if (axisOptions.translate.translateX - firstLabel.node().getBBox().width / 2 < 0) {
94
- firstLabel.attr('text-anchor', 'start');
95
- firstLabel.attr('transform', `translate(${-axisOptions.translate.translateX}, 0)`);
96
- DomHelper.cropSvgLabels(firstLabel, maxLabelSize / 2 + axisElementTranslate);
97
- }
98
- }
99
- static getTranslateNumber(maxLabelSize, lastLabel, marginRight) {
100
- if (maxLabelSize / 2 > lastLabel.node().getBBox().width)
101
- return -(lastLabel.node().getBBox().width - marginRight);
102
- return -maxLabelSize / 2;
103
- // return -Math.min(maxLabelSize / 2, lastLabel.node().getBBox().width - marginRight)
104
- }
105
- static wrapHandler(textBlocks, maxWidth) {
106
- textBlocks.each(function () {
107
- let textBlock = select(this);
108
- if (!textBlock.selectAll('tspan').empty())
109
- return;
110
- textBlock.select('title').remove();
111
- let textContent = textBlock.text();
112
- if (textBlock.node().getBBox().width > maxWidth) {
113
- let letters = textBlock.text().split('').reverse(), // split text to letters.
114
- letter, line = [], // one line. letters from this var into tpsans.
115
- lineNumber = 0, dy = 1.4, tspan = textBlock.text(null).append("tspan").attr("dy", dy + "em");
116
- while (letter = letters.pop()) {
117
- line.push(letter);
118
- tspan.text(line.join(''));
119
- if (tspan.node().getComputedTextLength() > maxWidth && line.length > 1 && letters.length > 0) {
120
- line.pop();
121
- tspan.text(line.join(''));
122
- if (lineNumber === 0 && line[line.length - 1] !== ' ')
123
- tspan.text(tspan.text() + '-');
124
- line = [letter];
125
- if (lineNumber >= 1) { // If text block has 2 lines, text cropped.
126
- if (letters.length > 0)
127
- tspan.text(tspan.text().substr(0, tspan.text().length - 1) + '...');
128
- break;
129
- }
130
- tspan = textBlock.append("tspan").attr("dy", dy * lineNumber + 1 + "em").text(letter);
131
- lineNumber++;
132
- }
133
- }
134
- if (textBlock.selectAll('tspan').size() === 1) {
135
- textBlock.text(textContent).attr('y', null);
136
- }
137
- if (!textBlock.selectAll('tspan').empty()) {
138
- textBlock.attr('y', -(textBlock.node().getBBox().height / 2 + 4.8));
139
- }
140
- }
141
- });
142
- }
143
- }
@@ -1,6 +0,0 @@
1
- import { Selection } from "d3-selection";
2
- import { Block } from "../../block/block";
3
- export declare class AxisLabelsEventManager {
4
- static setHoverEvents(block: Block, axisElement: Selection<SVGGElement, unknown, HTMLElement, any>): void;
5
- static removeEvents(axisElement: Selection<SVGGElement, unknown, HTMLElement, any>): void;
6
- }
@@ -1,36 +0,0 @@
1
- import { pointer } from "d3-selection";
2
- import { TipBox } from "../tipBox/tipBox";
3
- export class AxisLabelsEventManager {
4
- static setHoverEvents(block, axisElement) {
5
- const labels = axisElement.selectAll('.tick text');
6
- labels.on('mousemove', function (e, d) {
7
- TipBox.get(block).dispatch('mousemove', {
8
- bubbles: false,
9
- cancelable: true,
10
- detail: {
11
- keyValue: d,
12
- pointer: pointer(e, block.getWrapper().node())
13
- }
14
- });
15
- });
16
- labels.on('mouseleave', function (e, d) {
17
- TipBox.get(block).dispatch('mouseleave');
18
- });
19
- labels.on('click', function (e, d) {
20
- TipBox.get(block).dispatch('click', {
21
- bubbles: false,
22
- cancelable: true,
23
- detail: {
24
- multySelect: e.ctrlKey || e.metaKey,
25
- keyValue: d
26
- }
27
- });
28
- });
29
- }
30
- static removeEvents(axisElement) {
31
- const labels = axisElement.selectAll('.tick text');
32
- labels.on('mousemove', null);
33
- labels.on('mouseleave', null);
34
- labels.on('click', null);
35
- }
36
- }
@@ -1,23 +0,0 @@
1
- import { Selection } from 'd3-selection';
2
- import { MdtChartsDataRow, Size } from '../../../config/config';
3
- import { BlockMargin, EmbeddedLabelTypeModel, Field, Orient } from "../../../model/model";
4
- import { Block } from "../../block/block";
5
- import { BarAttrsHelper } from '../../twoDimensionalNotation/bar/barHelper';
6
- export declare class EmbeddedLabels {
7
- static embeddedLabelsGroupClass: string;
8
- static embeddedLabelClass: string;
9
- private static embeddedLabelBgClass;
10
- private static innerLabelColor;
11
- private static outerLabelColor;
12
- static render(block: Block, bars: Selection<SVGRectElement, MdtChartsDataRow, SVGGElement, any>, barAttrsHelper: BarAttrsHelper, field: Field, type: EmbeddedLabelTypeModel, keyAxisOrient: Orient, blockSize: Size, margin: BlockMargin, index: number, cssClasses: string[]): void;
13
- static restoreRemoved(block: Block, bars: Selection<SVGRectElement, MdtChartsDataRow, SVGGElement, any>, barAttrsHelper: BarAttrsHelper, field: Field, type: EmbeddedLabelTypeModel, keyAxisOrient: Orient, blockSize: Size, margin: BlockMargin, index: number, cssClasses: string[], keyFieldName: string): void;
14
- static removeUnused(block: Block, chartCssClasses: string[], fieldIndex: number, indexes: number[]): void;
15
- static update(block: Block, bars: Selection<SVGRectElement, MdtChartsDataRow, SVGGElement, unknown>, keyAxisOrient: Orient, barAttrsHelper: BarAttrsHelper, margin: BlockMargin, valueField: Field, type: EmbeddedLabelTypeModel, blockSize: Size, newData: MdtChartsDataRow[], index: number, cssClasses: string[]): void;
16
- static raiseGroups(block: Block): void;
17
- private static renderLabel;
18
- private static updateLabel;
19
- private static checkLabelToResetTextAnchor;
20
- private static renderGroup;
21
- private static renderBackground;
22
- private static getLabelByIndex;
23
- }
@@ -1,147 +0,0 @@
1
- import { select } from 'd3-selection';
2
- import { DomHelper } from '../../helpers/domHelper';
3
- import { Helper } from '../../helpers/helper';
4
- import { ValueFormatter } from "../../valueFormatter";
5
- import { EmbeddedLabelsDomHelper } from './embeddedLabelsDomHelper';
6
- import { EmbeddedLabelsHelper } from "./embeddedLabelsHelper";
7
- export class EmbeddedLabels {
8
- static render(block, bars, barAttrsHelper, field, type, keyAxisOrient, blockSize, margin, index, cssClasses) {
9
- const labelsGroup = this.renderGroup(block, Helper.getCssClassesWithElementIndex(cssClasses, index));
10
- DomHelper.setCssClasses(labelsGroup, Helper.getCssClassesWithElementIndex(cssClasses, index));
11
- bars.each(dataRow => {
12
- this.renderLabel(labelsGroup, barAttrsHelper, dataRow, field, type, keyAxisOrient, blockSize, margin);
13
- });
14
- }
15
- static restoreRemoved(block, bars, barAttrsHelper, field, type, keyAxisOrient, blockSize, margin, index, cssClasses, keyFieldName) {
16
- const untaggedBars = bars.filter(d => {
17
- return block.getChartBlock()
18
- .selectAll(`.${EmbeddedLabels.embeddedLabelsGroupClass}${Helper.getCssClassesLine(cssClasses)}.chart-element-${index}`)
19
- .selectAll(`.${this.embeddedLabelClass}`)
20
- .filter(row => row[keyFieldName] === d[keyFieldName])
21
- .empty();
22
- });
23
- if (!untaggedBars.empty()) {
24
- this.render(block, untaggedBars, barAttrsHelper, field, type, keyAxisOrient, blockSize, margin, index, cssClasses);
25
- }
26
- }
27
- static removeUnused(block, chartCssClasses, fieldIndex, indexes) {
28
- block.getChartBlock()
29
- .selectAll(`.${EmbeddedLabels.embeddedLabelsGroupClass}${Helper.getCssClassesLine(chartCssClasses)}.chart-element-${fieldIndex}`)
30
- .selectAll(`.${this.embeddedLabelClass}`)
31
- .filter((d, i) => indexes.findIndex(ind => ind === i) !== -1)
32
- .remove();
33
- }
34
- static update(block, bars, keyAxisOrient, barAttrsHelper, margin, valueField, type, blockSize, newData, index, cssClasses) {
35
- const labelsGroup = block.getChartBlock()
36
- .selectAll(`.${EmbeddedLabels.embeddedLabelsGroupClass}${Helper.getCssClassesLine(cssClasses)}.chart-element-${index}`);
37
- labelsGroup.selectAll(`.${this.embeddedLabelBgClass}`)
38
- .remove();
39
- const labelsSelection = labelsGroup
40
- .selectAll(`.${this.embeddedLabelClass}`)
41
- .data(newData);
42
- bars.each((dataRow, barIndex) => {
43
- const labelBlock = this.getLabelByIndex(labelsSelection, barIndex, valueField, dataRow);
44
- if (labelBlock)
45
- this.updateLabel(block, dataRow, keyAxisOrient, barAttrsHelper, margin, type, blockSize, labelBlock, labelsGroup);
46
- });
47
- }
48
- static raiseGroups(block) {
49
- block.getChartBlock().selectAll(`.${this.embeddedLabelsGroupClass}`).raise();
50
- }
51
- static renderLabel(labelsGroup, barAttrsHelper, dataRow, field, type, keyAxisOrient, blockSize, margin) {
52
- const labelBlock = labelsGroup.append('text').datum(dataRow);
53
- labelBlock
54
- .classed(EmbeddedLabels.embeddedLabelClass, true)
55
- .style('pointer-events', 'none')
56
- .text(ValueFormatter.formatField(field.format, dataRow[field.name]));
57
- const barAttrs = {
58
- x: barAttrsHelper.x(dataRow),
59
- width: barAttrsHelper.width(dataRow),
60
- y: barAttrsHelper.y(dataRow),
61
- height: barAttrsHelper.height(dataRow)
62
- };
63
- const labelUnserveFlag = EmbeddedLabelsHelper.getLabelUnserveFlag(barAttrs.height); // if bar is too small to serve label inside. This flag is needed for set outside postion and change text anchor if bar wide as whole chart block
64
- const position = EmbeddedLabelsHelper.getLabelPosition(barAttrs, labelBlock.node().getBBox().width, margin, blockSize, labelUnserveFlag);
65
- const attrs = EmbeddedLabelsHelper.getLabelAttrs(barAttrs, type, position, keyAxisOrient, labelBlock.node().getBBox().width);
66
- if (position === 'outside') {
67
- attrs.x = this.checkLabelToResetTextAnchor(attrs.x, labelBlock.node().getBBox().width, margin, blockSize, keyAxisOrient);
68
- this.renderBackground(labelsGroup, labelBlock, attrs);
69
- }
70
- EmbeddedLabelsDomHelper.setLabelBlockAttrs(attrs, labelBlock);
71
- if (position === 'inside')
72
- labelBlock.style('fill', this.innerLabelColor);
73
- EmbeddedLabelsDomHelper.cropText(labelBlock, barAttrs, position, labelUnserveFlag, margin, blockSize);
74
- }
75
- static updateLabel(block, dataRow, keyAxisOrient, barAttrsHelper, margin, type, blockSize, labelBlock, labelsGroup) {
76
- const barAttrs = {
77
- x: barAttrsHelper.x(dataRow),
78
- width: barAttrsHelper.width(dataRow),
79
- y: barAttrsHelper.y(dataRow),
80
- height: barAttrsHelper.height(dataRow)
81
- };
82
- const labelUnserveFlag = EmbeddedLabelsHelper.getLabelUnserveFlag(barAttrs.height); // if bar is too small to serve label inside. This flag is needed for set outside postion and change text anchor if bar wide as whole chart block
83
- const position = EmbeddedLabelsHelper.getLabelPosition(barAttrs, labelBlock.node().getBBox().width, margin, blockSize, labelUnserveFlag);
84
- const attrs = EmbeddedLabelsHelper.getLabelAttrs(barAttrs, type, position, keyAxisOrient, labelBlock.node().getBBox().width);
85
- EmbeddedLabelsDomHelper.cropText(labelBlock, barAttrs, position, labelUnserveFlag, margin, blockSize);
86
- if (position === 'outside') {
87
- attrs.x = this.checkLabelToResetTextAnchor(attrs.x, labelBlock.node().getBBox().width, margin, blockSize, keyAxisOrient);
88
- labelBlock.style('fill', this.outerLabelColor);
89
- }
90
- EmbeddedLabelsDomHelper.setLabelBlockAttrs(attrs, labelBlock, block.transitionManager.durations.chartUpdate)
91
- .then(() => {
92
- if (position === 'outside')
93
- this.renderBackground(labelsGroup, labelBlock, attrs);
94
- if (position === 'inside')
95
- labelBlock.style('fill', this.innerLabelColor);
96
- });
97
- }
98
- static checkLabelToResetTextAnchor(x, width, margin, blockSize, keyAxisOrient) {
99
- if (keyAxisOrient === 'left') {
100
- if (x + width > blockSize.width - margin.right)
101
- return blockSize.width - margin.right - width;
102
- return x;
103
- }
104
- if (keyAxisOrient === 'right') {
105
- if (x < margin.left)
106
- return margin.left;
107
- return x;
108
- }
109
- }
110
- static renderGroup(block, cssClasses) {
111
- let group = block.getChartBlock()
112
- .select(`.${this.embeddedLabelsGroupClass}${Helper.getCssClassesLine(cssClasses)}`)
113
- .raise();
114
- if (group.empty())
115
- group = block.getChartBlock()
116
- .append('g')
117
- .attr('class', this.embeddedLabelsGroupClass)
118
- .raise();
119
- return group;
120
- }
121
- static renderBackground(labelsGroup, labelBlock, attrs) {
122
- labelsGroup.append('rect')
123
- .attr('class', this.embeddedLabelBgClass)
124
- .attr('x', attrs.x)
125
- .attr('y', attrs.y - labelBlock.node().getBBox().height / 2)
126
- .attr('width', labelBlock.node().getBBox().width)
127
- .attr('height', labelBlock.node().getBBox().height)
128
- .style('fill', 'rgba(255, 255, 255, 0.8)')
129
- .lower();
130
- }
131
- static getLabelByIndex(labelsSelection, barIndex, valueField, dataRow) {
132
- let labelBlock;
133
- labelsSelection.each(function (d, indexLabel) {
134
- if (barIndex === indexLabel) {
135
- labelBlock = select(this)
136
- .datum(dataRow)
137
- .text(ValueFormatter.formatField(valueField.format, d[valueField.name]));
138
- }
139
- });
140
- return labelBlock;
141
- }
142
- }
143
- EmbeddedLabels.embeddedLabelsGroupClass = 'embedded-labels-group';
144
- EmbeddedLabels.embeddedLabelClass = 'embedded-label';
145
- EmbeddedLabels.embeddedLabelBgClass = 'embedded-label-bg';
146
- EmbeddedLabels.innerLabelColor = '#FFFFFF';
147
- EmbeddedLabels.outerLabelColor = '#000000';
@@ -1,8 +0,0 @@
1
- import { BarAttrs, EmbeddedLabelPosition, LabelAttrs } from "./embeddedLabelsHelper";
2
- import { BaseType, Selection } from 'd3-selection';
3
- import { BlockMargin } from "../../../model/model";
4
- import { MdtChartsDataRow, Size } from "../../../config/config";
5
- export declare class EmbeddedLabelsDomHelper {
6
- static setLabelBlockAttrs(attrs: LabelAttrs, labelBlock: Selection<SVGTextElement, MdtChartsDataRow, HTMLElement, unknown>, transitionDuration?: number): Promise<any>;
7
- static cropText(labelBlock: Selection<SVGGraphicsElement, unknown, BaseType, unknown>, barAttrs: BarAttrs, position: EmbeddedLabelPosition, labelUnserveFlag: boolean, margin: BlockMargin, blockSize: Size): void;
8
- }
@@ -1,30 +0,0 @@
1
- import { EmbeddedLabelsHelper } from "./embeddedLabelsHelper";
2
- import { DomHelper } from "../../helpers/domHelper";
3
- export class EmbeddedLabelsDomHelper {
4
- static setLabelBlockAttrs(attrs, labelBlock, transitionDuration = 0) {
5
- return new Promise((resolve) => {
6
- let labelBlockHandler = labelBlock;
7
- if (transitionDuration > 0) {
8
- labelBlockHandler = labelBlockHandler
9
- .interrupt()
10
- .transition()
11
- .duration(transitionDuration)
12
- .on('end', () => resolve('updated'));
13
- }
14
- labelBlockHandler
15
- .attr('x', attrs.x)
16
- .attr('y', attrs.y)
17
- .attr('dominant-baseline', 'middle');
18
- if (transitionDuration <= 0)
19
- resolve('updated');
20
- });
21
- }
22
- static cropText(labelBlock, barAttrs, position, labelUnserveFlag, margin, blockSize) {
23
- let labelTextSpace;
24
- if (labelUnserveFlag)
25
- labelTextSpace = blockSize.width - margin.left - margin.right;
26
- else
27
- labelTextSpace = EmbeddedLabelsHelper.getSpaceSizeForType(position, barAttrs.width, margin, blockSize);
28
- DomHelper.cropSvgLabels(labelBlock, labelTextSpace);
29
- }
30
- }
@@ -1,27 +0,0 @@
1
- import { BlockMargin, EmbeddedLabelTypeModel, Field, Orient } from "../../../model/model";
2
- import { Size } from "../../../config/config";
3
- export declare type EmbeddedLabelPosition = 'inside' | 'outside';
4
- export declare type TextAnchor = 'start' | 'end' | 'center';
5
- export interface LabelAttrs {
6
- x: number;
7
- y: number;
8
- textAnchor: TextAnchor;
9
- }
10
- export interface BarAttrs {
11
- x: number;
12
- y: number;
13
- width: number;
14
- height: number;
15
- }
16
- export declare const LABEL_BAR_PADDING = 6;
17
- export declare const MIN_BAR_HEIGHT_FOR_LABEL_SERVE = 12;
18
- export declare class EmbeddedLabelsHelper {
19
- static getLabelPosition(barAttrs: BarAttrs, labelBlockWidth: number, margin: BlockMargin, blockSize: Size, labelUnserveFlag: boolean): EmbeddedLabelPosition;
20
- static getSpaceSizeForType(position: EmbeddedLabelPosition, barWidth: number, margin: BlockMargin, blockSize: Size): number;
21
- static getLabelAttrs(barAttrs: BarAttrs, type: EmbeddedLabelTypeModel, position: EmbeddedLabelPosition, keyAxisOrient: Orient, labelWidth: number): LabelAttrs;
22
- static getLabelField(type: EmbeddedLabelTypeModel, valueFields: Field[], keyField: Field, index: number): Field;
23
- static getLabelUnserveFlag(barHeight: number): boolean;
24
- private static getLabelAttrX;
25
- private static getLabelAttrY;
26
- private static getTextAnchor;
27
- }
@@ -1,65 +0,0 @@
1
- export const LABEL_BAR_PADDING = 6;
2
- export const MIN_BAR_HEIGHT_FOR_LABEL_SERVE = 12;
3
- export class EmbeddedLabelsHelper {
4
- static getLabelPosition(barAttrs, labelBlockWidth, margin, blockSize, labelUnserveFlag) {
5
- if (labelUnserveFlag || this.getSpaceSizeForType('inside', barAttrs.width, margin, blockSize) < labelBlockWidth
6
- && this.getSpaceSizeForType('inside', barAttrs.width, margin, blockSize) < this.getSpaceSizeForType('outside', barAttrs.width, margin, blockSize))
7
- return 'outside';
8
- return 'inside';
9
- }
10
- static getSpaceSizeForType(position, barWidth, margin, blockSize) {
11
- if (position === 'outside')
12
- return blockSize.width - margin.left - margin.right - barWidth - LABEL_BAR_PADDING;
13
- return barWidth - LABEL_BAR_PADDING * 2;
14
- }
15
- static getLabelAttrs(barAttrs, type, position, keyAxisOrient, labelWidth) {
16
- const textAnchor = this.getTextAnchor(type, position, keyAxisOrient);
17
- const y = this.getLabelAttrY(barAttrs.y, barAttrs.height);
18
- let x = this.getLabelAttrX(barAttrs, type, position, keyAxisOrient);
19
- if (textAnchor === 'end') {
20
- x = x - labelWidth;
21
- }
22
- return {
23
- x,
24
- y,
25
- textAnchor
26
- };
27
- }
28
- static getLabelField(type, valueFields, keyField, index) {
29
- if (type === 'key')
30
- return keyField;
31
- if (type === 'value')
32
- return valueFields[index];
33
- return null;
34
- }
35
- static getLabelUnserveFlag(barHeight) {
36
- return barHeight < MIN_BAR_HEIGHT_FOR_LABEL_SERVE;
37
- }
38
- static getLabelAttrX(barAttrs, type, position, keyAxisOrient) {
39
- if (keyAxisOrient === 'left') {
40
- if (position === 'outside')
41
- return barAttrs.x + barAttrs.width + LABEL_BAR_PADDING;
42
- if (type === 'key')
43
- return barAttrs.x + LABEL_BAR_PADDING;
44
- return barAttrs.x + barAttrs.width - LABEL_BAR_PADDING;
45
- }
46
- if (position === 'outside')
47
- return barAttrs.x - LABEL_BAR_PADDING;
48
- if (type === 'key')
49
- return barAttrs.x + barAttrs.width - LABEL_BAR_PADDING;
50
- return barAttrs.x + LABEL_BAR_PADDING;
51
- }
52
- static getLabelAttrY(barY, barHeight) {
53
- return barY + barHeight / 2 + 1;
54
- }
55
- static getTextAnchor(type, position, keyAxisOrient) {
56
- if (keyAxisOrient === 'left') {
57
- if (position === 'outside' || type === 'key')
58
- return 'start';
59
- return 'end';
60
- }
61
- if (position === 'outside' || type === 'key')
62
- return 'end';
63
- return 'start';
64
- }
65
- }
@@ -1,13 +0,0 @@
1
- import { Size } from "../../../config/config";
2
- import { AxisModelOptions, BlockMargin } from "../../../model/model";
3
- export declare type GridLineType = 'key' | 'value';
4
- export interface GridLineAttributes {
5
- x1: number;
6
- y1: number;
7
- x2: number;
8
- y2: number;
9
- }
10
- export declare class GridLineHelper {
11
- static getGridLineLength(gridLineType: GridLineType, keyAxis: AxisModelOptions, valueAxis: AxisModelOptions, blockSize: Size, margin: BlockMargin): number;
12
- static getLineAttributes(axis: AxisModelOptions, lineLength: number): GridLineAttributes;
13
- }
@@ -1,30 +0,0 @@
1
- export class GridLineHelper {
2
- static getGridLineLength(gridLineType, keyAxis, valueAxis, blockSize, margin) {
3
- let axis;
4
- let axisLength;
5
- if (gridLineType === 'key')
6
- axis = keyAxis;
7
- else
8
- axis = valueAxis;
9
- if (axis.orient === 'left' || axis.orient === 'right')
10
- axisLength = blockSize.width - margin.left - margin.right;
11
- else
12
- axisLength = blockSize.height - margin.top - margin.bottom;
13
- if (axis.orient === 'right' || axis.orient === 'bottom')
14
- axisLength = -axisLength;
15
- return axisLength;
16
- }
17
- static getLineAttributes(axis, lineLength) {
18
- const attributes = {
19
- x1: 0,
20
- y1: 0,
21
- x2: 0,
22
- y2: 0
23
- };
24
- if (axis.orient === 'left' || axis.orient === 'right')
25
- attributes.x2 = lineLength;
26
- else
27
- attributes.y2 = lineLength;
28
- return attributes;
29
- }
30
- }