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,127 +0,0 @@
1
- import { ARROW_DEFAULT_POSITION, ARROW_SIZE } from "./tooltipDomHelper";
2
- import { easeLinear } from 'd3-ease';
3
- import { interrupt } from 'd3-transition';
4
- import { Tooltip } from './tooltip';
5
- export class TooltipComponentsManager {
6
- static showComponent(tooltipBlock) {
7
- tooltipBlock.style('display', 'block');
8
- }
9
- static hideComponent(tooltipBlock) {
10
- tooltipBlock.style('display', 'none');
11
- }
12
- static renderTooltipWrapper(block) {
13
- let tooltipWrapper = block.getWrapper()
14
- .select(`.${Tooltip.tooltipWrapperClass}`);
15
- if (tooltipWrapper.empty())
16
- block.getWrapper()
17
- .append('div')
18
- .attr('class', Tooltip.tooltipWrapperClass);
19
- }
20
- static renderTooltipBlock(block, translateX = 0, translateY = 0) {
21
- const wrapper = block.getWrapper().select(`.${Tooltip.tooltipWrapperClass}`);
22
- let tooltipBlock = wrapper.select(`.${Tooltip.tooltipBlockClass}`);
23
- if (tooltipBlock.empty()) {
24
- tooltipBlock = wrapper
25
- .append('div')
26
- .attr('class', Tooltip.tooltipBlockClass)
27
- .style('position', 'absolute')
28
- .style('display', 'none');
29
- }
30
- if (translateX !== 0 || translateY !== 0)
31
- tooltipBlock.style('transform', `translate(${translateX}px, ${translateY}px)`);
32
- return tooltipBlock;
33
- }
34
- static renderTooltipContentBlock(tooltipBlock) {
35
- let tooltipContentBlock = tooltipBlock.select(`.${Tooltip.tooltipContentClass}`);
36
- if (tooltipContentBlock.empty())
37
- tooltipContentBlock = tooltipBlock.append('div')
38
- .attr('class', Tooltip.tooltipContentClass);
39
- return tooltipContentBlock;
40
- }
41
- static renderTooltipLine(block) {
42
- let tooltipLine = block.getChartBlock()
43
- .select(`.${Tooltip.tooltipLineClass}`);
44
- if (tooltipLine.empty())
45
- tooltipLine = block.getChartBlock()
46
- .append('line')
47
- .attr('class', Tooltip.tooltipLineClass)
48
- .lower();
49
- return tooltipLine;
50
- }
51
- static setTooltipLineAttributes(tooltipLine, attributes, transition) {
52
- interrupt(tooltipLine.node());
53
- if (transition > 0 && tooltipLine.style('display') === 'block') {
54
- tooltipLine
55
- .interrupt()
56
- .transition()
57
- .duration(transition)
58
- .ease(easeLinear)
59
- .attr('x1', attributes.x1)
60
- .attr('x2', attributes.x2)
61
- .attr('y1', attributes.y1)
62
- .attr('y2', attributes.y2);
63
- }
64
- else {
65
- tooltipLine
66
- .attr('x1', attributes.x1)
67
- .attr('x2', attributes.x2)
68
- .attr('y1', attributes.y1)
69
- .attr('y2', attributes.y2);
70
- }
71
- }
72
- static getLineWidth(tooltipLine) {
73
- return parseFloat(tooltipLine.style('stroke-width'));
74
- }
75
- static renderTooltipArrow(tooltipBlock) {
76
- let arrowSize = ARROW_SIZE / 2;
77
- let tooltipArrow = tooltipBlock.select(`.${Tooltip.tooltipArrowClass}`);
78
- if (tooltipArrow.empty())
79
- tooltipArrow = tooltipBlock
80
- .append('div')
81
- .attr('class', Tooltip.tooltipArrowClass)
82
- .style('position', 'absolute')
83
- .style('left', `${ARROW_DEFAULT_POSITION}px`)
84
- .style('border-top-width', `${arrowSize}px`)
85
- .style('border-right-width', `${arrowSize}px`)
86
- .style('border-bottom-width', `0px`)
87
- .style('border-left-width', `${arrowSize}px`);
88
- return tooltipArrow;
89
- }
90
- static setBlockCoordinate(tooltipBlock, tooltipCoordinate) {
91
- tooltipBlock
92
- .style('right', tooltipCoordinate.right)
93
- .style('bottom', tooltipCoordinate.bottom)
94
- .style('left', tooltipCoordinate.left)
95
- .style('top', tooltipCoordinate.top);
96
- }
97
- static setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, chartOrientation, transition = null) {
98
- interrupt(tooltipBlock.node());
99
- if (!transition || transition <= 0)
100
- this.setBlockCoordinate(tooltipBlock, tooltipCoordinate);
101
- if (chartOrientation === 'vertical' && tooltipBlock.style('left') !== '0px' && tooltipBlock.style('right') !== '0px' && tooltipCoordinate.right !== '0px' && tooltipCoordinate.left !== null) {
102
- tooltipBlock
103
- .style('right', tooltipCoordinate.right)
104
- .style('bottom', tooltipCoordinate.bottom)
105
- .style('top', tooltipCoordinate.top)
106
- .interrupt()
107
- .transition()
108
- .duration(transition)
109
- .ease(easeLinear)
110
- .style('left', tooltipCoordinate.left);
111
- }
112
- else if (chartOrientation === 'horizontal' && tooltipBlock.style('top') !== '0px' && parseInt(tooltipBlock.style('bottom')) > 0 && tooltipCoordinate.bottom === null) {
113
- tooltipBlock
114
- .style('left', tooltipCoordinate.left)
115
- .style('bottom', tooltipCoordinate.bottom)
116
- .style('right', tooltipCoordinate.right)
117
- .interrupt()
118
- .transition()
119
- .duration(transition)
120
- .ease(easeLinear)
121
- .style('top', tooltipCoordinate.top);
122
- }
123
- else {
124
- this.setBlockCoordinate(tooltipBlock, tooltipCoordinate);
125
- }
126
- }
127
- }
@@ -1,36 +0,0 @@
1
- import { Selection, BaseType } from 'd3-selection';
2
- import { MdtChartsDataSource, TooltipHtml } from "../../../config/config";
3
- import { IntervalChartModel, OptionsModelData, PolarChartModel, TwoDimensionalChartModel } from "../../../model/model";
4
- import { Size } from "../../../config/config";
5
- export interface TooltipLineAttributes {
6
- x1: number;
7
- x2: number;
8
- y1: number;
9
- y2: number;
10
- }
11
- export interface TooltipCoordinate {
12
- left: string;
13
- top: string;
14
- right: string;
15
- bottom: string;
16
- }
17
- export declare const ARROW_SIZE = 20;
18
- export declare const ARROW_DEFAULT_POSITION = 9;
19
- export declare const TOOLTIP_ARROW_PADDING_X: number;
20
- export declare const TOOLTIP_ARROW_PADDING_Y = 13;
21
- export declare class TooltipDomHelper {
22
- private static readonly groupClass;
23
- private static readonly headClass;
24
- private static readonly textItemClass;
25
- private static readonly maxContentWidth;
26
- static fillForMulty2DCharts(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, charts: TwoDimensionalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, htmlHandler?: TooltipHtml): void;
27
- static fillForPolarChart(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, chart: PolarChartModel, data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, markColor: string, htmlHandler?: TooltipHtml): void;
28
- static fillForIntervalChart(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, charts: IntervalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, htmlHandler?: TooltipHtml): void;
29
- static getRecalcedCoordinateByArrow(coordinate: [number, number], tooltipBlock: Selection<HTMLElement, unknown, HTMLElement, any>, blockSize: Size, tooltipArrow: Selection<BaseType, unknown, HTMLElement, any>, translateX?: number, translateY?: number): [number, number];
30
- private static renderHead;
31
- private static fillValuesContent;
32
- private static getTooltipItemHtml;
33
- private static setTooltipArrowCoordinate;
34
- private static fillContentByFunction;
35
- private static setWhiteSpaceForTextBlocks;
36
- }
@@ -1,114 +0,0 @@
1
- import { ValueFormatter, } from "../../valueFormatter";
2
- import { TooltipHelper } from './tooltipHelper';
3
- import { Helper } from '../../helpers/helper';
4
- export const ARROW_SIZE = 20;
5
- export const ARROW_DEFAULT_POSITION = 9;
6
- export const TOOLTIP_ARROW_PADDING_X = ARROW_DEFAULT_POSITION - (ARROW_SIZE * Math.sqrt(2) - ARROW_SIZE) / 2 + 14;
7
- export const TOOLTIP_ARROW_PADDING_Y = 13;
8
- export class TooltipDomHelper {
9
- static fillForMulty2DCharts(contentBlock, charts, data, dataOptions, keyValue, htmlHandler) {
10
- contentBlock.html('');
11
- if (!htmlHandler) {
12
- this.renderHead(contentBlock, keyValue);
13
- charts.forEach(chart => {
14
- chart.data.valueFields.forEach((field, index) => {
15
- const html = this.getTooltipItemHtml(data, dataOptions, keyValue, field);
16
- this.fillValuesContent(contentBlock, chart.style.elementColors[index % chart.style.elementColors.length], html);
17
- });
18
- });
19
- }
20
- else {
21
- this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler);
22
- }
23
- }
24
- static fillForPolarChart(contentBlock, chart, data, dataOptions, keyValue, markColor, htmlHandler) {
25
- contentBlock.html('');
26
- if (!htmlHandler) {
27
- this.renderHead(contentBlock, keyValue);
28
- const html = this.getTooltipItemHtml(data, dataOptions, keyValue, chart.data.valueField);
29
- this.fillValuesContent(contentBlock, markColor, html);
30
- }
31
- else {
32
- this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler);
33
- }
34
- }
35
- static fillForIntervalChart(contentBlock, charts, data, dataOptions, keyValue, htmlHandler) {
36
- contentBlock.html('');
37
- if (!htmlHandler) {
38
- this.renderHead(contentBlock, keyValue);
39
- charts.forEach(chart => {
40
- let html = this.getTooltipItemHtml(data, dataOptions, keyValue, chart.data.valueField1);
41
- this.fillValuesContent(contentBlock, chart.style.elementColors[0 % chart.style.elementColors.length], html);
42
- html = this.getTooltipItemHtml(data, dataOptions, keyValue, chart.data.valueField2);
43
- this.fillValuesContent(contentBlock, chart.style.elementColors[0 % chart.style.elementColors.length], html);
44
- });
45
- }
46
- else {
47
- this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler);
48
- }
49
- }
50
- static getRecalcedCoordinateByArrow(coordinate, tooltipBlock, blockSize, tooltipArrow, translateX = 0, translateY = 0) {
51
- const tooltipBlockNode = tooltipBlock.node();
52
- const horizontalPad = TooltipHelper.getHorizontalPad(coordinate[0], tooltipBlockNode.getBoundingClientRect().width, blockSize, translateX);
53
- const verticalPad = TooltipHelper.getVerticalPad(coordinate[1], tooltipBlockNode.getBoundingClientRect().height, translateY);
54
- this.setTooltipArrowCoordinate(tooltipArrow, TooltipHelper.getTooltipArrowPadding(tooltipBlockNode.getBoundingClientRect().width, horizontalPad));
55
- return [coordinate[0] - TOOLTIP_ARROW_PADDING_X - horizontalPad,
56
- coordinate[1] - TOOLTIP_ARROW_PADDING_Y - tooltipBlockNode.getBoundingClientRect().height - verticalPad];
57
- }
58
- static renderHead(contentBlock, keyValue) {
59
- contentBlock.append('div')
60
- .attr('class', `${this.groupClass} ${this.headClass}`)
61
- .style('white-space', 'nowrap')
62
- .text(keyValue);
63
- }
64
- static fillValuesContent(contentBlock, markColor, tooltipHtml) {
65
- const group = contentBlock.append('div')
66
- .attr('class', this.groupClass);
67
- if (markColor)
68
- group.append('div')
69
- .attr('class', 'tooltip-color')
70
- .append('span')
71
- .attr('class', 'tooltip-circle')
72
- .style('background-color', markColor);
73
- const textBlock = group.append('div')
74
- .attr('class', 'tooltip-texts')
75
- .append('div')
76
- .attr('class', this.textItemClass)
77
- .html(tooltipHtml)
78
- .style('white-space', 'nowrap');
79
- if (textBlock.node().getBoundingClientRect().width > this.maxContentWidth) {
80
- textBlock.style('white-space', 'normal');
81
- contentBlock.select(`.${this.headClass}`).style('white-space', 'normal');
82
- }
83
- }
84
- static getTooltipItemHtml(data, dataOptions, keyValue, valueField) {
85
- const row = data[dataOptions.dataSource].find(d => d[dataOptions.keyField.name] === keyValue);
86
- const text = `<span class="tooltip-field-title">${valueField.title}</span>
87
- <span class="tooltip-field-value">${ValueFormatter.formatField(valueField.format, row[valueField.name])}</span>`;
88
- return text;
89
- }
90
- static setTooltipArrowCoordinate(tooltipArrow, horizontalPad) {
91
- if (horizontalPad !== 0)
92
- tooltipArrow.style('left', `${ARROW_DEFAULT_POSITION + Math.floor(horizontalPad)}px`);
93
- else
94
- tooltipArrow.style('left', `${ARROW_DEFAULT_POSITION}px`);
95
- }
96
- static fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler) {
97
- const row = Helper.getRowsByKeys([keyValue], dataOptions.keyField.name, data[dataOptions.dataSource])[0];
98
- contentBlock.html(htmlHandler(row));
99
- this.setWhiteSpaceForTextBlocks(contentBlock);
100
- contentBlock.selectAll('.tooltip-text-item').style('display', 'block');
101
- }
102
- static setWhiteSpaceForTextBlocks(contentBlock) {
103
- contentBlock.style('min-width', null);
104
- contentBlock.selectAll(`.${this.textItemClass}`).style('white-space', 'pre');
105
- if (contentBlock.node().getBoundingClientRect().width > this.maxContentWidth) {
106
- contentBlock.selectAll(`.${this.textItemClass}`).style('white-space', 'pre-wrap');
107
- contentBlock.style('min-width', this.maxContentWidth + 'px');
108
- }
109
- }
110
- }
111
- TooltipDomHelper.groupClass = 'tooltip-group';
112
- TooltipDomHelper.headClass = 'tooltip-head';
113
- TooltipDomHelper.textItemClass = 'tooltip-text-item';
114
- TooltipDomHelper.maxContentWidth = 500;
@@ -1,16 +0,0 @@
1
- import { AxisScale } from "d3-axis";
2
- import { ChartOrientation } from "../../../config/config";
3
- import { BlockMargin, Orient } from "../../../model/model";
4
- import { TooltipCoordinate, TooltipLineAttributes } from "./tooltipDomHelper";
5
- import { Size } from "../../../config/config";
6
- export declare class TooltipHelper {
7
- private static convexsize;
8
- static getHorizontalPad(coordinateX: number, tooltipBlockWidth: number, blockSize: Size, translateX: number): number;
9
- static getVerticalPad(coordinateY: number, tooltipBlockHeight: number, translateY: number): number;
10
- static getTooltipArrowPadding(tooltipBlockWidth: number, horizontalPad: number): number;
11
- static getCoordinateByPointer(pointer: [number, number]): TooltipCoordinate;
12
- static getTooltipFixedCoordinate(scaleKey: AxisScale<any>, margin: BlockMargin, keyValue: string, blockBoundingRect: DOMRect, tooltipBoundingRect: DOMRect, keyAxisOrient: Orient, winWidth: number, winHeight: number): TooltipCoordinate;
13
- static getTooltipCursorCoordinate(pointer: [number, number], blockBoundingRect: DOMRect, tooltipBoundingRect: DOMRect, winWidth: number, winHeight: number): TooltipCoordinate;
14
- static getTooltipLineAttributes(scaleKey: AxisScale<any>, margin: BlockMargin, key: string, chartOrientation: ChartOrientation, blockSize: Size): TooltipLineAttributes;
15
- static recalcToolTipCoordinateByViewPort(blockBounding: DOMRect, tooltipBounding: DOMRect, coordinate: TooltipCoordinate, winWidth: number, winHeight: number): TooltipCoordinate;
16
- }
@@ -1,99 +0,0 @@
1
- import { Helper } from "../../helpers/helper";
2
- import { Scale } from "../scale/scale";
3
- import { ARROW_DEFAULT_POSITION, TOOLTIP_ARROW_PADDING_X, TOOLTIP_ARROW_PADDING_Y } from "./tooltipDomHelper";
4
- export class TooltipHelper {
5
- static getHorizontalPad(coordinateX, tooltipBlockWidth, blockSize, translateX) {
6
- let pad = 0;
7
- if (tooltipBlockWidth + coordinateX - TOOLTIP_ARROW_PADDING_X + translateX > blockSize.width)
8
- pad = tooltipBlockWidth + coordinateX - TOOLTIP_ARROW_PADDING_X + translateX - blockSize.width;
9
- return pad;
10
- }
11
- static getVerticalPad(coordinateY, tooltipBlockHeight, translateY) {
12
- let pad = 0;
13
- if (coordinateY - TOOLTIP_ARROW_PADDING_Y - tooltipBlockHeight + translateY < -tooltipBlockHeight - TOOLTIP_ARROW_PADDING_Y)
14
- pad = coordinateY;
15
- return pad; // return zero or sub zero
16
- }
17
- static getTooltipArrowPadding(tooltipBlockWidth, horizontalPad) {
18
- return horizontalPad > tooltipBlockWidth
19
- ? tooltipBlockWidth - ARROW_DEFAULT_POSITION - 20 * Math.sqrt(2)
20
- : horizontalPad; // If tooltip arrow has coordinate outside svg, it take X position in end of tooltip block
21
- }
22
- static getCoordinateByPointer(pointer) {
23
- const coordinate = {
24
- left: null,
25
- top: null,
26
- right: null,
27
- bottom: null
28
- };
29
- coordinate.left = pointer[0] + 'px';
30
- coordinate.top = pointer[1] + 'px';
31
- return coordinate;
32
- }
33
- static getTooltipFixedCoordinate(scaleKey, margin, keyValue, blockBoundingRect, tooltipBoundingRect, keyAxisOrient, winWidth, winHeight) {
34
- const coordinate = {
35
- top: null,
36
- bottom: null,
37
- left: null,
38
- right: null
39
- };
40
- if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top') {
41
- coordinate.left = Scale.getScaledValue(scaleKey, keyValue) + margin.left - tooltipBoundingRect.width / 2 + 'px';
42
- if (keyAxisOrient === 'bottom')
43
- coordinate.top = margin.top - 5 - tooltipBoundingRect.height + 'px';
44
- else
45
- coordinate.top = blockBoundingRect.height - margin.bottom + 'px';
46
- }
47
- if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
48
- coordinate.top = Scale.getScaledValue(scaleKey, keyValue) + margin.top - tooltipBoundingRect.height / 2 + 'px';
49
- if (keyAxisOrient === 'left')
50
- coordinate.left = blockBoundingRect.width - margin.right + 'px';
51
- else
52
- coordinate.left = margin.left - tooltipBoundingRect.width + 'px';
53
- }
54
- return this.recalcToolTipCoordinateByViewPort(blockBoundingRect, tooltipBoundingRect, coordinate, winWidth, winHeight);
55
- }
56
- static getTooltipCursorCoordinate(pointer, blockBoundingRect, tooltipBoundingRect, winWidth, winHeight) {
57
- const pad = 10;
58
- const coordinate = {
59
- top: pointer[1] + pad + 'px',
60
- bottom: null,
61
- left: pointer[0] + pad + 'px',
62
- right: null
63
- };
64
- return this.recalcToolTipCoordinateByViewPort(blockBoundingRect, tooltipBoundingRect, coordinate, winWidth, winHeight);
65
- }
66
- static getTooltipLineAttributes(scaleKey, margin, key, chartOrientation, blockSize) {
67
- const attributes = {
68
- x1: 0, x2: 0, y1: 0, y2: 0
69
- };
70
- if (chartOrientation === 'vertical') {
71
- attributes.x1 = Math.ceil(Scale.getScaledValue(scaleKey, key) + margin.left) - 0.5;
72
- attributes.x2 = Math.ceil(Scale.getScaledValue(scaleKey, key) + margin.left) - 0.5;
73
- attributes.y1 = margin.top - this.convexsize;
74
- attributes.y2 = blockSize.height - margin.bottom + this.convexsize * 2;
75
- }
76
- else {
77
- attributes.x1 = margin.left - this.convexsize;
78
- attributes.x2 = blockSize.width - margin.right + this.convexsize * 2;
79
- attributes.y1 = Scale.getScaledValue(scaleKey, key) + margin.top;
80
- attributes.y2 = Scale.getScaledValue(scaleKey, key) + margin.top;
81
- }
82
- return attributes;
83
- }
84
- static recalcToolTipCoordinateByViewPort(blockBounding, tooltipBounding, coordinate, winWidth, winHeight) {
85
- const scrollPad = 18;
86
- const tooltipLeftAtBlock = Helper.getPXValueFromString(coordinate.left);
87
- if (tooltipLeftAtBlock < 0 && -tooltipLeftAtBlock > blockBounding.left)
88
- coordinate.left = -blockBounding.left + 'px';
89
- if (blockBounding.left + tooltipLeftAtBlock + tooltipBounding.width > winWidth - scrollPad)
90
- coordinate.left = winWidth - blockBounding.left - tooltipBounding.width - scrollPad + 'px';
91
- const tooltipTopAtBlock = Helper.getPXValueFromString(coordinate.top);
92
- if (tooltipTopAtBlock + blockBounding.top < 0 && -tooltipTopAtBlock > blockBounding.top)
93
- coordinate.top = -blockBounding.top + 'px';
94
- if (blockBounding.top + tooltipTopAtBlock + tooltipBounding.height > winHeight)
95
- coordinate.top = blockBounding.height - tooltipBounding.height - (blockBounding.bottom - winHeight) + 'px';
96
- return coordinate;
97
- }
98
- }
99
- TooltipHelper.convexsize = 5;
@@ -1,33 +0,0 @@
1
- import { AxisScale } from "d3-axis";
2
- import { MdtChartsDataRow, Size } from "../../config/config";
3
- import { BlockMargin, TwoDimensionalOptionsModel, PolarOptionsModel, DonutChartSettings } from "../../model/model";
4
- import { Block } from "../block/block";
5
- export declare type FilterCallback = (rows: MdtChartsDataRow[]) => void;
6
- export interface SelectDetails {
7
- multySelect: boolean;
8
- keyValue?: string;
9
- }
10
- export declare class FilterEventManager {
11
- private callback;
12
- private fullDataset;
13
- private filterable;
14
- private block;
15
- private selectedKeys;
16
- constructor(callback: FilterCallback, fullDataset: MdtChartsDataRow[], filtrable: boolean, keyFieldName: string, selectedIds?: number[]);
17
- setBlock(block: Block): void;
18
- getSelectedKeys(): string[];
19
- updateData(newDataset: MdtChartsDataRow[]): void;
20
- isSelected(keyValue: string): boolean;
21
- clearKeysFor2D(options: TwoDimensionalOptionsModel): void;
22
- clearKeysForPolar(margin: BlockMargin, blockSize: Size, options: PolarOptionsModel, donutSettings: DonutChartSettings): void;
23
- private setKey;
24
- private addId;
25
- private removeId;
26
- private processKey;
27
- setListenerPolar(margin: BlockMargin, blockSize: Size, options: PolarOptionsModel, donutSettings: DonutChartSettings): void;
28
- event2DUpdate(options: TwoDimensionalOptionsModel): void;
29
- registerEventFor2D(scaleKey: AxisScale<any>, margin: BlockMargin, blockSize: Size, options: TwoDimensionalOptionsModel): void;
30
- private registerEventToDonut;
31
- private getMultyParamByEvent;
32
- private getMultySelectParam;
33
- }
@@ -1,127 +0,0 @@
1
- import { pointer, select } from "d3-selection";
2
- import { SelectHighlighter } from "../elementHighlighter/selectHighlighter";
3
- import { TipBox } from "../features/tipBox/tipBox";
4
- import { TipBoxHelper } from "../features/tipBox/tipBoxHelper";
5
- import { Helper } from "../helpers/helper";
6
- import { Donut } from "../polarNotation/donut/donut";
7
- export class FilterEventManager {
8
- constructor(callback, fullDataset, filtrable, keyFieldName, selectedIds = []) {
9
- this.callback = callback;
10
- this.fullDataset = fullDataset;
11
- this.selectedKeys = Helper.getKeysByIds(selectedIds, keyFieldName, fullDataset);
12
- this.filterable = filtrable;
13
- }
14
- setBlock(block) {
15
- this.block = block;
16
- }
17
- getSelectedKeys() {
18
- return this.selectedKeys;
19
- }
20
- updateData(newDataset) {
21
- this.fullDataset = newDataset;
22
- }
23
- isSelected(keyValue) {
24
- return this.selectedKeys.findIndex(key => key === keyValue) !== -1;
25
- }
26
- clearKeysFor2D(options) {
27
- this.selectedKeys = [];
28
- if (this.callback)
29
- this.callback([]);
30
- SelectHighlighter.clear2D(this.block, options);
31
- }
32
- clearKeysForPolar(margin, blockSize, options, donutSettings) {
33
- this.selectedKeys = [];
34
- if (this.callback)
35
- this.callback([]);
36
- SelectHighlighter.clearPolar(margin, blockSize, this.block, options, Donut.getAllArcGroups(this.block), donutSettings);
37
- }
38
- setKey(key) {
39
- this.selectedKeys = [key];
40
- }
41
- addId(key) {
42
- this.selectedKeys.push(key);
43
- }
44
- removeId(key) {
45
- this.selectedKeys.splice(this.selectedKeys.findIndex(k => k === key), 1);
46
- }
47
- processKey(multySelect, keyValue) {
48
- if (multySelect) {
49
- if (this.getSelectedKeys().findIndex(key => key === keyValue) === -1) {
50
- this.addId(keyValue);
51
- return true;
52
- }
53
- else {
54
- this.removeId(keyValue);
55
- return false;
56
- }
57
- }
58
- else {
59
- if (this.getSelectedKeys()[0] === keyValue && this.getSelectedKeys().length === 1) {
60
- this.removeId(keyValue);
61
- return false;
62
- }
63
- else {
64
- this.setKey(keyValue);
65
- return true;
66
- }
67
- }
68
- }
69
- setListenerPolar(margin, blockSize, options, donutSettings) {
70
- if (this.filterable) {
71
- this.registerEventToDonut(margin, blockSize, options, donutSettings);
72
- const selectedElems = Donut.getAllArcGroups(this.block).filter(d => this.selectedKeys.findIndex(sid => sid === d.data[options.data.keyField.name]) !== -1);
73
- this.selectedKeys = [];
74
- selectedElems.dispatch('click', { bubbles: false, cancelable: true, detail: { multySelect: true } });
75
- }
76
- }
77
- event2DUpdate(options) {
78
- if (this.filterable) {
79
- const removedKeys = [];
80
- this.selectedKeys.forEach(key => {
81
- if (this.fullDataset.findIndex(row => row[options.data.keyField.name] === key) === -1)
82
- removedKeys.push(key);
83
- });
84
- removedKeys.forEach(rKey => this.selectedKeys.splice(this.selectedKeys.findIndex(sKey => sKey === rKey), 1));
85
- this.selectedKeys.forEach(key => {
86
- SelectHighlighter.click2DHandler(true, true, key, this.selectedKeys, this.block, options);
87
- });
88
- }
89
- }
90
- registerEventFor2D(scaleKey, margin, blockSize, options) {
91
- if (this.filterable) {
92
- const tipBox = TipBox.renderOrGet(this.block, margin, blockSize);
93
- const thisClass = this;
94
- tipBox.on('click', function (e) {
95
- const multySelect = thisClass.getMultySelectParam(e);
96
- const keyValue = e.detail.keyValue || TipBoxHelper.getKeyValueByPointer(pointer(e, this), options.orient, margin, blockSize, scaleKey, options.scale.key.type);
97
- const appended = thisClass.processKey(multySelect, keyValue);
98
- SelectHighlighter.click2DHandler(multySelect, appended, keyValue, thisClass.selectedKeys, thisClass.block, options);
99
- if (thisClass.callback) {
100
- thisClass.callback(Helper.getRowsByKeys(thisClass.selectedKeys, options.data.keyField.name, thisClass.fullDataset));
101
- }
102
- });
103
- }
104
- }
105
- registerEventToDonut(margin, blockSize, options, donutSettings) {
106
- const arcItems = Donut.getAllArcGroups(this.block);
107
- const thisClass = this;
108
- arcItems.on('click', function (e, dataRow) {
109
- const multySelect = thisClass.getMultySelectParam(e);
110
- const keyValue = dataRow.data[options.data.keyField.name];
111
- const appended = thisClass.processKey(multySelect, keyValue);
112
- SelectHighlighter.clickPolarHandler(multySelect, appended, select(this), thisClass.getSelectedKeys(), margin, blockSize, thisClass.block, options, arcItems, donutSettings);
113
- if (thisClass.callback) {
114
- thisClass.callback(Helper.getRowsByKeys(thisClass.selectedKeys, options.data.keyField.name, thisClass.fullDataset));
115
- }
116
- });
117
- }
118
- getMultyParamByEvent(e) {
119
- return e.ctrlKey || e.metaKey;
120
- }
121
- getMultySelectParam(e) {
122
- const isMultyButtonToggle = this.getMultyParamByEvent(e);
123
- return isMultyButtonToggle === undefined
124
- ? (e.detail.multySelect === undefined ? false : e.detail.multySelect)
125
- : isMultyButtonToggle;
126
- }
127
- }
@@ -1,30 +0,0 @@
1
- import { Selection, BaseType } from 'd3-selection';
2
- import { MdtChartsDataRow } from '../../config/config';
3
- import { ChartStyle, TwoDimensionalChartModel } from "../../model/model";
4
- import { Block } from "../block/block";
5
- declare type StyleColorType = 'fill' | 'stroke';
6
- export declare enum SelectionCondition {
7
- Include = 0,
8
- Exclude = 1
9
- }
10
- export declare class DomHelper {
11
- static setCssClasses(elem: Selection<BaseType, unknown, any, unknown>, cssClasses: string[]): void;
12
- static get2DChartElements(block: Block, chart: TwoDimensionalChartModel): Selection<BaseType, MdtChartsDataRow, BaseType, unknown>;
13
- static getCssPropertyValue(node: Element, propertyName: string): string;
14
- static getSelectionNumericAttr(selection: Selection<BaseType, unknown, BaseType, unknown>, attrName: string): number;
15
- static setChartStyle(elements: Selection<BaseType, unknown, BaseType, unknown>, chartStyle: ChartStyle, fieldIndex: number, styleType: StyleColorType): void;
16
- static setChartElementColor(elements: Selection<BaseType, unknown, BaseType, unknown>, colorPalette: string[], fieldIndex: number, styleType: StyleColorType): void;
17
- static cropSvgLabels(labelBlocks: Selection<SVGGraphicsElement, unknown, BaseType, unknown>, maxWidth: number): void;
18
- /**
19
- * Возвращает выборку элементов, ключи которых содержатся или НЕ содержатся в переданном массиве
20
- * @param initialSelection Изначальная выборка
21
- * @param dataWrapped Содержаться ли данные в обертке .data
22
- * @param keyFieldName название поля ключей
23
- * @param keyValues значения ключей
24
- * @param condition включать или исключать элменты по ключам
25
- * @returns Выборка по ключам
26
- */
27
- static getChartElementsByKeys<T extends BaseType>(initialSelection: Selection<T, MdtChartsDataRow, BaseType, unknown>, dataWrapped: boolean, keyFieldName: string, keyValues: string[], condition?: SelectionCondition): Selection<T, any, BaseType, unknown>;
28
- private static setChartOpacity;
29
- }
30
- export {};
@@ -1,68 +0,0 @@
1
- import { MarkDot } from "../features/markDots/markDot";
2
- import { Bar } from "../twoDimensionalNotation/bar/bar";
3
- export var SelectionCondition;
4
- (function (SelectionCondition) {
5
- SelectionCondition[SelectionCondition["Include"] = 0] = "Include";
6
- SelectionCondition[SelectionCondition["Exclude"] = 1] = "Exclude";
7
- })(SelectionCondition || (SelectionCondition = {}));
8
- export class DomHelper {
9
- static setCssClasses(elem, cssClasses) {
10
- cssClasses.forEach(cssClass => {
11
- elem.classed(cssClass, true);
12
- });
13
- }
14
- static get2DChartElements(block, chart) {
15
- if (chart.type === 'line' || chart.type === 'area')
16
- return MarkDot.getMarkDotForChart(block, chart.cssClasses);
17
- else
18
- return Bar.getAllBarsForChart(block, chart.cssClasses);
19
- }
20
- static getCssPropertyValue(node, propertyName) {
21
- return window.getComputedStyle(node).getPropertyValue(propertyName);
22
- }
23
- static getSelectionNumericAttr(selection, attrName) {
24
- return parseFloat(selection.attr(attrName));
25
- }
26
- static setChartStyle(elements, chartStyle, fieldIndex, styleType) {
27
- this.setChartElementColor(elements, chartStyle.elementColors, fieldIndex, styleType);
28
- this.setChartOpacity(elements, chartStyle.opacity);
29
- }
30
- static setChartElementColor(elements, colorPalette, fieldIndex, styleType) {
31
- elements.style(styleType, colorPalette[fieldIndex % colorPalette.length]);
32
- }
33
- static cropSvgLabels(labelBlocks, maxWidth) {
34
- labelBlocks.nodes().forEach(node => {
35
- if (node.getBBox().width > maxWidth) {
36
- const text = node.textContent;
37
- let textLength = text.length;
38
- while (node.getBBox().width > maxWidth && textLength > 0) {
39
- node.textContent = text.substring(0, --textLength) + '...';
40
- }
41
- if (textLength === 0)
42
- node.textContent = '';
43
- }
44
- });
45
- }
46
- /**
47
- * Возвращает выборку элементов, ключи которых содержатся или НЕ содержатся в переданном массиве
48
- * @param initialSelection Изначальная выборка
49
- * @param dataWrapped Содержаться ли данные в обертке .data
50
- * @param keyFieldName название поля ключей
51
- * @param keyValues значения ключей
52
- * @param condition включать или исключать элменты по ключам
53
- * @returns Выборка по ключам
54
- */
55
- static getChartElementsByKeys(initialSelection, dataWrapped, keyFieldName, keyValues, condition = SelectionCondition.Include) {
56
- return initialSelection.filter(d => {
57
- let i;
58
- if (dataWrapped)
59
- i = keyValues.findIndex(kv => kv === d.data[keyFieldName]);
60
- else
61
- i = keyValues.findIndex(kv => kv === d[keyFieldName]);
62
- return condition === SelectionCondition.Exclude ? i === -1 : i !== -1;
63
- });
64
- }
65
- static setChartOpacity(elements, opacity) {
66
- elements.attr('opacity', opacity);
67
- }
68
- }