mdt-charts 1.9.11 → 1.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/lib/config/config.d.ts +148 -0
  2. package/lib/config/config.js +1 -0
  3. package/lib/designer/designerConfig.d.ts +71 -0
  4. package/lib/designer/designerConfig.js +1 -0
  5. package/lib/engine/block/block.d.ts +35 -0
  6. package/lib/engine/block/block.js +110 -0
  7. package/lib/engine/block/blockHelper.d.ts +12 -0
  8. package/lib/engine/block/blockHelper.js +19 -0
  9. package/lib/engine/colorReader/colorReader.d.ts +10 -0
  10. package/lib/engine/colorReader/colorReader.js +21 -0
  11. package/lib/engine/contentManager.d.ts +9 -0
  12. package/lib/engine/contentManager.js +29 -0
  13. package/lib/engine/elementHighlighter/elementHighlighter.d.ts +30 -0
  14. package/lib/engine/elementHighlighter/elementHighlighter.js +198 -0
  15. package/lib/engine/elementHighlighter/selectHighlighter.d.ts +11 -0
  16. package/lib/engine/elementHighlighter/selectHighlighter.js +95 -0
  17. package/lib/engine/engine.d.ts +20 -0
  18. package/lib/engine/engine.js +64 -0
  19. package/lib/engine/features/aggregator/aggregator.d.ts +22 -0
  20. package/lib/engine/features/aggregator/aggregator.js +95 -0
  21. package/lib/engine/features/axis/axis.d.ts +12 -0
  22. package/lib/engine/features/axis/axis.js +118 -0
  23. package/lib/engine/features/axis/axisDomHelper.d.ts +7 -0
  24. package/lib/engine/features/axis/axisDomHelper.js +24 -0
  25. package/lib/engine/features/axis/axisHelper.d.ts +9 -0
  26. package/lib/engine/features/axis/axisHelper.js +53 -0
  27. package/lib/engine/features/axis/axisLabelDomHelper.d.ts +17 -0
  28. package/lib/engine/features/axis/axisLabelDomHelper.js +143 -0
  29. package/lib/engine/features/axis/axisLabelsEventManager.d.ts +6 -0
  30. package/lib/engine/features/axis/axisLabelsEventManager.js +36 -0
  31. package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +23 -0
  32. package/lib/engine/features/embeddedLabels/embeddedLabels.js +147 -0
  33. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +8 -0
  34. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +30 -0
  35. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +27 -0
  36. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +65 -0
  37. package/lib/engine/features/gridLine/gidLineHelper.d.ts +13 -0
  38. package/lib/engine/features/gridLine/gidLineHelper.js +30 -0
  39. package/lib/engine/features/gridLine/gridLine.d.ts +11 -0
  40. package/lib/engine/features/gridLine/gridLine.js +67 -0
  41. package/lib/engine/features/legend/legend.d.ts +22 -0
  42. package/lib/engine/features/legend/legend.js +112 -0
  43. package/lib/engine/features/legend/legendDomHelper.d.ts +8 -0
  44. package/lib/engine/features/legend/legendDomHelper.js +48 -0
  45. package/lib/engine/features/legend/legendEventsManager.d.ts +12 -0
  46. package/lib/engine/features/legend/legendEventsManager.js +47 -0
  47. package/lib/engine/features/legend/legendHelper.d.ts +21 -0
  48. package/lib/engine/features/legend/legendHelper.js +99 -0
  49. package/lib/engine/features/markDots/markDot.d.ts +20 -0
  50. package/lib/engine/features/markDots/markDot.js +68 -0
  51. package/lib/engine/features/markDots/markDotsHelper.d.ts +6 -0
  52. package/lib/engine/features/markDots/markDotsHelper.js +16 -0
  53. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +14 -0
  54. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +97 -0
  55. package/lib/engine/features/scale/scale.d.ts +16 -0
  56. package/lib/engine/features/scale/scale.js +74 -0
  57. package/lib/engine/features/tipBox/tipBox.d.ts +11 -0
  58. package/lib/engine/features/tipBox/tipBox.js +32 -0
  59. package/lib/engine/features/tipBox/tipBoxHelper.d.ts +16 -0
  60. package/lib/engine/features/tipBox/tipBoxHelper.js +48 -0
  61. package/lib/engine/features/title/title.d.ts +9 -0
  62. package/lib/engine/features/title/title.js +35 -0
  63. package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +16 -0
  64. package/lib/engine/features/tolltip/newTooltip/newTooltip.js +26 -0
  65. package/lib/engine/features/tolltip/newTooltip/newTooltip.test.d.ts +1 -0
  66. package/lib/engine/features/tolltip/newTooltip/newTooltip.test.js +186 -0
  67. package/lib/engine/features/tolltip/newTooltip/newTooltipService.d.ts +17 -0
  68. package/lib/engine/features/tolltip/newTooltip/newTooltipService.js +26 -0
  69. package/lib/engine/features/tolltip/tooltip.d.ts +19 -0
  70. package/lib/engine/features/tolltip/tooltip.js +181 -0
  71. package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +17 -0
  72. package/lib/engine/features/tolltip/tooltipComponentsManager.js +125 -0
  73. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +30 -0
  74. package/lib/engine/features/tolltip/tooltipDomHelper.js +103 -0
  75. package/lib/engine/features/tolltip/tooltipHelper.d.ts +18 -0
  76. package/lib/engine/features/tolltip/tooltipHelper.js +93 -0
  77. package/lib/engine/filterManager/filterEventManager.d.ts +33 -0
  78. package/lib/engine/filterManager/filterEventManager.js +127 -0
  79. package/lib/engine/helpers/domHelper.d.ts +30 -0
  80. package/lib/engine/helpers/domHelper.js +68 -0
  81. package/lib/engine/helpers/helper.d.ts +30 -0
  82. package/lib/engine/helpers/helper.js +89 -0
  83. package/lib/engine/helpers/namesHelper.d.ts +5 -0
  84. package/lib/engine/helpers/namesHelper.js +9 -0
  85. package/lib/engine/intervalNotation/gantt.d.ts +10 -0
  86. package/lib/engine/intervalNotation/gantt.js +62 -0
  87. package/lib/engine/intervalNotation/intervalManager.d.ts +7 -0
  88. package/lib/engine/intervalNotation/intervalManager.js +30 -0
  89. package/lib/engine/polarNotation/donut/DonutHelper.d.ts +15 -0
  90. package/lib/engine/polarNotation/donut/DonutHelper.js +60 -0
  91. package/lib/engine/polarNotation/donut/donut.d.ts +32 -0
  92. package/lib/engine/polarNotation/donut/donut.js +125 -0
  93. package/lib/engine/polarNotation/polarManager.d.ts +10 -0
  94. package/lib/engine/polarNotation/polarManager.js +55 -0
  95. package/lib/engine/transitionManager.d.ts +19 -0
  96. package/lib/engine/transitionManager.js +64 -0
  97. package/lib/engine/twoDimensionalNotation/area/area.d.ts +17 -0
  98. package/lib/engine/twoDimensionalNotation/area/area.js +131 -0
  99. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +9 -0
  100. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +40 -0
  101. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +34 -0
  102. package/lib/engine/twoDimensionalNotation/bar/bar.js +216 -0
  103. package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +24 -0
  104. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +103 -0
  105. package/lib/engine/twoDimensionalNotation/line/line.d.ts +17 -0
  106. package/lib/engine/twoDimensionalNotation/line/line.js +132 -0
  107. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +8 -0
  108. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +28 -0
  109. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +11 -0
  110. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +101 -0
  111. package/lib/engine/valueFormatter.d.ts +6 -0
  112. package/lib/engine/valueFormatter.js +8 -0
  113. package/lib/main.d.ts +79 -0
  114. package/lib/main.js +88 -0
  115. package/lib/model/chartStyleModel.d.ts +16 -0
  116. package/lib/model/chartStyleModel.js +67 -0
  117. package/lib/model/configsValidator/configValidator.d.ts +5 -0
  118. package/lib/model/configsValidator/configValidator.js +7 -0
  119. package/lib/model/dataManagerModel.d.ts +22 -0
  120. package/lib/model/dataManagerModel.js +137 -0
  121. package/lib/model/featuresModel/axisModel.d.ts +18 -0
  122. package/lib/model/featuresModel/axisModel.js +111 -0
  123. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +7 -0
  124. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +86 -0
  125. package/lib/model/featuresModel/legendModel/legendModel.d.ts +13 -0
  126. package/lib/model/featuresModel/legendModel/legendModel.js +78 -0
  127. package/lib/model/featuresModel/otherComponents.d.ts +6 -0
  128. package/lib/model/featuresModel/otherComponents.js +12 -0
  129. package/lib/model/featuresModel/scaleModel.d.ts +17 -0
  130. package/lib/model/featuresModel/scaleModel.js +100 -0
  131. package/lib/model/featuresModel/titleModel.d.ts +4 -0
  132. package/lib/model/featuresModel/titleModel.js +14 -0
  133. package/lib/model/featuresModel/tooltipModel.d.ts +4 -0
  134. package/lib/model/featuresModel/tooltipModel.js +7 -0
  135. package/lib/model/marginModel.d.ts +19 -0
  136. package/lib/model/marginModel.js +126 -0
  137. package/lib/model/model.d.ts +221 -0
  138. package/lib/model/model.js +1 -0
  139. package/lib/model/modelBuilder.d.ts +16 -0
  140. package/lib/model/modelBuilder.js +128 -0
  141. package/lib/model/modelHelper.d.ts +7 -0
  142. package/lib/model/modelHelper.js +41 -0
  143. package/lib/model/notations/intervalModel.d.ts +8 -0
  144. package/lib/model/notations/intervalModel.js +93 -0
  145. package/lib/model/notations/polarModel.d.ts +7 -0
  146. package/lib/model/notations/polarModel.js +27 -0
  147. package/lib/model/notations/twoDimensionalModel.d.ts +19 -0
  148. package/lib/model/notations/twoDimensionalModel.js +85 -0
  149. package/lib/optionsServices/publicOptionsService.d.ts +6 -0
  150. package/lib/optionsServices/publicOptionsService.js +8 -0
  151. package/lib/optionsServices/validators/sizeValidator.d.ts +5 -0
  152. package/lib/optionsServices/validators/sizeValidator.js +13 -0
  153. package/lib/style/charts-main.css +243 -0
  154. package/lib/style/charts-main.less +243 -0
  155. package/package.json +1 -1
  156. package/dist/index.html +0 -363
  157. package/dist/listeners.89e1e272264c0e680de8.js +0 -278
  158. package/dist/main.f8b6bc6fee33cef1116c.js +0 -228
  159. package/dist/src_engine_engine_ts.ccee2a280374e0083541.js +0 -759
  160. package/dist/vendors-node_modules_chroma-js_chroma_js-node_modules_d3-array_src_max_js-node_modules_d3-arr-c3fc24.b32acc465b8557229277.js +0 -1869
@@ -0,0 +1,86 @@
1
+ import { CLASSES } from "../../modelBuilder";
2
+ import { LegendModel } from "./legendModel";
3
+ export class LegendCanvasModel {
4
+ static getLegendHeight(texts, blockWidth, marginLeft, marginRight, itemsPosition, legendPosition) {
5
+ const legendWrapper = document.createElement('div');
6
+ legendWrapper.style.opacity = '0';
7
+ legendWrapper.style.display = 'flex';
8
+ if (itemsPosition === 'column')
9
+ legendWrapper.style.flexDirection = 'column';
10
+ legendWrapper.style.position = 'absolute';
11
+ legendWrapper.style.width = blockWidth - marginLeft - marginRight + 'px';
12
+ texts.forEach(text => {
13
+ const itemWrapper = document.createElement('div');
14
+ const colorBlock = document.createElement('span');
15
+ const textBlock = document.createElement('span');
16
+ itemWrapper.classList.add(LegendModel.getLegendItemClass(itemsPosition));
17
+ if (itemsPosition === 'column') {
18
+ itemWrapper.style.whiteSpace = 'nowrap';
19
+ itemWrapper.classList.add(LegendModel.getMarginClass(legendPosition));
20
+ }
21
+ colorBlock.classList.add(CLASSES.legendColor);
22
+ textBlock.classList.add(CLASSES.legendLabel);
23
+ textBlock.textContent = text;
24
+ itemWrapper.append(colorBlock, textBlock);
25
+ legendWrapper.append(itemWrapper);
26
+ });
27
+ document.body.append(legendWrapper);
28
+ const height = legendWrapper.offsetHeight;
29
+ legendWrapper.remove();
30
+ return height;
31
+ }
32
+ static getLegendItemWidth(text) {
33
+ const itemWrapper = document.createElement('div');
34
+ itemWrapper.style.opacity = '0';
35
+ const colorBlock = document.createElement('span');
36
+ const textBlock = document.createElement('span');
37
+ itemWrapper.style.display = 'inline-block';
38
+ itemWrapper.classList.add(CLASSES.legendItem);
39
+ colorBlock.classList.add(CLASSES.legendColor);
40
+ textBlock.classList.add(CLASSES.legendLabel);
41
+ textBlock.textContent = text;
42
+ itemWrapper.append(colorBlock, textBlock);
43
+ document.body.append(itemWrapper);
44
+ const sumWidth = itemWrapper.getBoundingClientRect().width
45
+ + parseFloat(window.getComputedStyle(itemWrapper, null).getPropertyValue('margin-left'))
46
+ + parseFloat(window.getComputedStyle(itemWrapper, null).getPropertyValue('margin-right'));
47
+ itemWrapper.remove();
48
+ return sumWidth;
49
+ }
50
+ static findElementsAmountByLegendSize(texts, position, legendBlockWidth, legendBlockHeight) {
51
+ const legendWrapper = document.createElement('div');
52
+ legendWrapper.style.opacity = '0';
53
+ legendWrapper.style.display = 'flex';
54
+ legendWrapper.style.flexDirection = 'column';
55
+ legendWrapper.style.position = 'absolute';
56
+ legendWrapper.style.width = legendBlockWidth + 'px';
57
+ document.body.append(legendWrapper);
58
+ let amount = 0;
59
+ for (let i = 0; i < texts.length; i++) {
60
+ const itemWrapper = document.createElement('div');
61
+ const colorBlock = document.createElement('span');
62
+ const textBlock = document.createElement('span');
63
+ itemWrapper.classList.add('legend-item-row');
64
+ if (position === 'bottom')
65
+ textBlock.classList.add('legend-label-nowrap', 'mt-10');
66
+ else
67
+ itemWrapper.classList.add('mt-15');
68
+ colorBlock.classList.add(CLASSES.legendColor);
69
+ textBlock.classList.add(CLASSES.legendLabel);
70
+ textBlock.textContent = texts[i];
71
+ itemWrapper.append(colorBlock, textBlock);
72
+ legendWrapper.append(itemWrapper);
73
+ if (legendWrapper.offsetHeight > legendBlockHeight) {
74
+ itemWrapper.remove();
75
+ if (legendBlockHeight - legendWrapper.offsetHeight >= 15 && position !== 'bottom')
76
+ amount = i;
77
+ else
78
+ amount = i - 1;
79
+ break;
80
+ }
81
+ amount++;
82
+ }
83
+ legendWrapper.remove();
84
+ return amount < 0 ? 0 : amount;
85
+ }
86
+ }
@@ -0,0 +1,13 @@
1
+ import { ChartNotation, Size } from "../../../config/config";
2
+ import { BlockMargin, ILegendModel, LegendBlockModel, LegendPosition, Orient } from "../../model";
3
+ import { LegendItemsDirection } from "./legendCanvasModel";
4
+ /** If donut block has width less than this const, legend change postion from "right" to "bottom" */
5
+ export declare const MIN_DONUT_BLOCK_SIZE = 260;
6
+ export declare class LegendModel {
7
+ static getLegendSize(chartNotation: ChartNotation, position: Orient, texts: string[], legendMaxWidth: number, blockSize: Size, legendBlockModel: LegendBlockModel): number;
8
+ static getBaseLegendBlockModel(notation: ChartNotation): LegendBlockModel;
9
+ static getLegendModel(chartNotation: ChartNotation, legendShow: boolean, blockSize: Size, margin: BlockMargin): ILegendModel;
10
+ static getLegendItemClass(itemsPosition: LegendItemsDirection): string;
11
+ static getMarginClass(legendPosition: LegendPosition): string;
12
+ private static getLegendWidth;
13
+ }
@@ -0,0 +1,78 @@
1
+ import { ModelHelper } from "../../modelHelper";
2
+ import { TitleModel } from "../titleModel";
3
+ import { LegendCanvasModel } from "./legendCanvasModel";
4
+ /** If donut block has width less than this const, legend change postion from "right" to "bottom" */
5
+ export const MIN_DONUT_BLOCK_SIZE = 260;
6
+ export class LegendModel {
7
+ static getLegendSize(chartNotation, position, texts, legendMaxWidth, blockSize, legendBlockModel) {
8
+ if (position === 'left' || position === 'right')
9
+ return this.getLegendWidth(texts, legendMaxWidth);
10
+ if (chartNotation === '2d' || chartNotation === 'interval') {
11
+ return LegendCanvasModel.getLegendHeight(texts, blockSize.width, legendBlockModel.coordinate[position].margin.left, legendBlockModel.coordinate[position].margin.right, 'row', position);
12
+ }
13
+ else if (chartNotation === 'polar') {
14
+ const size = LegendCanvasModel.getLegendHeight(texts, blockSize.width, legendBlockModel.coordinate[position].margin.left, legendBlockModel.coordinate[position].margin.right, 'column', position);
15
+ return size;
16
+ }
17
+ }
18
+ static getBaseLegendBlockModel(notation) {
19
+ const mt = 20, mb = 20, ml = 20, mr = 20;
20
+ const titleModelTemplate = TitleModel.getTitleModel();
21
+ return {
22
+ coordinate: {
23
+ left: {
24
+ size: 0,
25
+ margin: { top: mt, bottom: mb, left: ml, right: 0 },
26
+ pad: 0
27
+ },
28
+ bottom: {
29
+ size: 0,
30
+ margin: { top: 0, bottom: 20, left: 20, right: 20 },
31
+ pad: 0
32
+ },
33
+ right: {
34
+ size: 0,
35
+ margin: { top: titleModelTemplate.pad + titleModelTemplate.margin.top + titleModelTemplate.size, bottom: mb, left: 0, right: mr },
36
+ pad: 0
37
+ },
38
+ top: {
39
+ size: 0,
40
+ margin: { top: 20, bottom: 0, left: 20, right: 20 },
41
+ pad: titleModelTemplate.pad + titleModelTemplate.margin.top + titleModelTemplate.size
42
+ }
43
+ },
44
+ standartTooltip: notation === 'polar' ? false : true
45
+ };
46
+ }
47
+ static getLegendModel(chartNotation, legendShow, blockSize, margin) {
48
+ let legendPosition = 'off';
49
+ if (legendShow) {
50
+ if (chartNotation === '2d' || chartNotation === 'interval')
51
+ legendPosition = 'top';
52
+ else if (chartNotation === 'polar') {
53
+ legendPosition = blockSize.width - margin.left - margin.right < MIN_DONUT_BLOCK_SIZE ? 'bottom' : 'right';
54
+ }
55
+ }
56
+ return {
57
+ position: legendPosition
58
+ };
59
+ }
60
+ static getLegendItemClass(itemsPosition) {
61
+ return itemsPosition === 'column' ? 'legend-item-row' : 'legend-item-inline';
62
+ }
63
+ static getMarginClass(legendPosition) {
64
+ return legendPosition === 'right' ? 'mt-15' : 'mt-10';
65
+ }
66
+ static getLegendWidth(texts, legendMaxWidth) {
67
+ let longestText = '';
68
+ let biggestScore = 0;
69
+ texts.forEach(text => {
70
+ if (ModelHelper.getStringScore(text) > biggestScore) {
71
+ longestText = text;
72
+ biggestScore = ModelHelper.getStringScore(text);
73
+ }
74
+ });
75
+ const maxWidth = LegendCanvasModel.getLegendItemWidth(longestText + '?'); // One letter reserve
76
+ return maxWidth > legendMaxWidth ? legendMaxWidth : maxWidth;
77
+ }
78
+ }
@@ -0,0 +1,6 @@
1
+ import { OtherComponents } from "../model";
2
+ import { ElementsOptions } from "../../designer/designerConfig";
3
+ import { ChartNotation } from "../../config/config";
4
+ export declare class OtherComponentsModel {
5
+ static getOtherComponentsModel(elementsOptions: ElementsOptions, notation: ChartNotation): OtherComponents;
6
+ }
@@ -0,0 +1,12 @@
1
+ import { LegendModel } from "./legendModel/legendModel";
2
+ import { TitleModel } from "./titleModel";
3
+ import { TooltipModel } from "./tooltipModel";
4
+ export class OtherComponentsModel {
5
+ static getOtherComponentsModel(elementsOptions, notation) {
6
+ return {
7
+ legendBlock: LegendModel.getBaseLegendBlockModel(notation),
8
+ titleBlock: TitleModel.getTitleModel(),
9
+ tooltipBlock: TooltipModel.getTooltipModel(elementsOptions.tooltip)
10
+ };
11
+ }
12
+ }
@@ -0,0 +1,17 @@
1
+ import { BlockMargin, ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
2
+ import { AxisPosition, NumberDomain, IntervalChart, TwoDimensionalChart, TwoDimensionalOptions, Size, ChartOrientation, MdtChartsDataSource } from "../../config/config";
3
+ export declare enum ScaleType {
4
+ Key = 0,
5
+ Value = 1
6
+ }
7
+ export declare class ScaleModel {
8
+ static getScaleKey(allowableKeys: string[], orient: ChartOrientation, margin: BlockMargin, blockSize: Size, charts: TwoDimensionalChart[], barCharts: TwoDimensionalChart[]): ScaleKeyModel;
9
+ static getScaleLinear(options: TwoDimensionalOptions, data: MdtChartsDataSource, margin: BlockMargin, blockSize: Size): ScaleValueModel;
10
+ static getRangePeek(scaleType: ScaleType, chartOrientation: string, margin: BlockMargin, blockSize: Size): number;
11
+ static getDateValueDomain(data: MdtChartsDataSource, chart: IntervalChart, keyAxisPosition: AxisPosition, dataSource: string): [Date, Date];
12
+ static getLinearDomain(configDomain: NumberDomain, data: MdtChartsDataSource, configOptions: TwoDimensionalOptions): [number, number];
13
+ static getScaleKeyType(charts: TwoDimensionalChart[]): ScaleKeyType;
14
+ static getScaleValueType(charts: TwoDimensionalChart[] | IntervalChart[]): ScaleValueType;
15
+ static getElementsAmount(barCharts: TwoDimensionalChart[]): number;
16
+ static getScaleMaxValue(charts: TwoDimensionalChart[], dataSource: string, data: MdtChartsDataSource): number;
17
+ }
@@ -0,0 +1,100 @@
1
+ import { ModelHelper } from "../modelHelper";
2
+ export var ScaleType;
3
+ (function (ScaleType) {
4
+ ScaleType[ScaleType["Key"] = 0] = "Key";
5
+ ScaleType[ScaleType["Value"] = 1] = "Value";
6
+ })(ScaleType || (ScaleType = {}));
7
+ export class ScaleModel {
8
+ static getScaleKey(allowableKeys, orient, margin, blockSize, charts, barCharts) {
9
+ return {
10
+ domain: allowableKeys,
11
+ range: {
12
+ start: 0,
13
+ end: ScaleModel.getRangePeek(ScaleType.Key, orient, margin, blockSize)
14
+ },
15
+ type: ScaleModel.getScaleKeyType(charts),
16
+ elementsAmount: this.getElementsAmount(barCharts)
17
+ };
18
+ }
19
+ static getScaleLinear(options, data, margin, blockSize) {
20
+ return {
21
+ domain: ScaleModel.getLinearDomain(options.axis.value.domain, data, options),
22
+ range: {
23
+ start: 0,
24
+ end: ScaleModel.getRangePeek(ScaleType.Value, options.orientation, margin, blockSize)
25
+ },
26
+ type: ScaleModel.getScaleValueType(options.charts)
27
+ };
28
+ }
29
+ static getRangePeek(scaleType, chartOrientation, margin, blockSize) {
30
+ if (chartOrientation === 'vertical')
31
+ return scaleType === ScaleType.Key
32
+ ? blockSize.width - margin.left - margin.right
33
+ : blockSize.height - margin.top - margin.bottom;
34
+ return scaleType === ScaleType.Key
35
+ ? blockSize.height - margin.top - margin.bottom
36
+ : blockSize.width - margin.left - margin.right;
37
+ }
38
+ static getDateValueDomain(data, chart, keyAxisPosition, dataSource) {
39
+ const minMax = ModelHelper.getMinAndMaxOfIntervalData(data, dataSource, chart);
40
+ let domainPeekMin = minMax[0];
41
+ let domainPeekMax = minMax[1];
42
+ if (keyAxisPosition === 'start')
43
+ return [domainPeekMin, domainPeekMax];
44
+ return [domainPeekMax, domainPeekMin];
45
+ }
46
+ static getLinearDomain(configDomain, data, configOptions) {
47
+ let domainPeekMin;
48
+ let domainPeekMax;
49
+ if (configDomain.start === -1)
50
+ domainPeekMin = 0;
51
+ else
52
+ domainPeekMin = configDomain.start;
53
+ if (configDomain.end === -1)
54
+ domainPeekMax = this.getScaleMaxValue(configOptions.charts, configOptions.data.dataSource, data);
55
+ else
56
+ domainPeekMax = configDomain.end;
57
+ if (configOptions.axis.key.position === 'start')
58
+ return [domainPeekMin, domainPeekMax];
59
+ return [domainPeekMax, domainPeekMin];
60
+ }
61
+ static getScaleKeyType(charts) {
62
+ if (charts.findIndex((chart) => chart.type === 'bar') === -1)
63
+ return 'point';
64
+ return 'band';
65
+ }
66
+ static getScaleValueType(charts) {
67
+ if (charts.findIndex((chart) => chart.type === 'gantt') !== -1)
68
+ return 'datetime';
69
+ return 'linear';
70
+ }
71
+ static getElementsAmount(barCharts) {
72
+ if (barCharts.length === 0)
73
+ return 1;
74
+ let barsAmount = 0;
75
+ barCharts.forEach(chart => {
76
+ if (chart.isSegmented)
77
+ barsAmount += 1; // Если бар сегментированный, то все valueFields являются частями одного бара
78
+ else
79
+ barsAmount += chart.data.valueFields.length;
80
+ });
81
+ return barsAmount;
82
+ }
83
+ static getScaleMaxValue(charts, dataSource, data) {
84
+ let max = 0;
85
+ charts.forEach(chart => {
86
+ data[dataSource].forEach(dataRow => {
87
+ let sumInRow = 0;
88
+ chart.data.valueFields.forEach(field => {
89
+ if (chart.isSegmented)
90
+ sumInRow += dataRow[field.name];
91
+ else if (dataRow[field.name] > sumInRow)
92
+ sumInRow = dataRow[field.name];
93
+ });
94
+ if (max < sumInRow)
95
+ max = sumInRow;
96
+ });
97
+ });
98
+ return max;
99
+ }
100
+ }
@@ -0,0 +1,4 @@
1
+ import { TitleBlockModel } from "../model";
2
+ export declare class TitleModel {
3
+ static getTitleModel(): TitleBlockModel;
4
+ }
@@ -0,0 +1,14 @@
1
+ export class TitleModel {
2
+ static getTitleModel() {
3
+ return {
4
+ margin: {
5
+ bottom: 0,
6
+ left: 20,
7
+ right: 20,
8
+ top: 20
9
+ },
10
+ size: 20,
11
+ pad: 0
12
+ };
13
+ }
14
+ }
@@ -0,0 +1,4 @@
1
+ import { TooltipSettings } from "../../designer/designerConfig";
2
+ export declare class TooltipModel {
3
+ static getTooltipModel(options: TooltipSettings): TooltipSettings;
4
+ }
@@ -0,0 +1,7 @@
1
+ export class TooltipModel {
2
+ static getTooltipModel(options) {
3
+ return {
4
+ position: (options === null || options === void 0 ? void 0 : options.position) || 'followCursor'
5
+ };
6
+ }
7
+ }
@@ -0,0 +1,19 @@
1
+ import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
2
+ import { DesignerConfig } from "../designer/designerConfig";
3
+ import { BlockMargin, DataScope, LegendBlockModel, OtherComponents, PolarOptionsModel } from "./model";
4
+ import { Size } from "../config/config";
5
+ export declare const AXIS_HORIZONTAL_LABEL_PADDING = 15;
6
+ export declare const AXIS_VERTICAL_LABEL_PADDING = 10;
7
+ export declare class MarginModel {
8
+ static getMargin(designerConfig: DesignerConfig, config: MdtChartsConfig, otherComponents: OtherComponents, data: MdtChartsDataSource): BlockMargin;
9
+ static recalcPolarMarginWithScopedData(margin: BlockMargin, blockSize: Size, designerConfig: DesignerConfig, config: MdtChartsConfig, legendBlockModel: LegendBlockModel, dataScope: DataScope, options: PolarOptionsModel): void;
10
+ static recalcMarginByVerticalAxisLabel(margin: BlockMargin, config: MdtChartsConfig, designerConfig: DesignerConfig, dataScope: DataScope): void;
11
+ private static getHorizontalMarginByAxisLabels;
12
+ private static recalcVerticalMarginByAxisLabelHeight;
13
+ private static recalcHorizontalMarginByAxisLabelWidth;
14
+ private static recalcMarginWithLegend;
15
+ private static getLegendItemsContent;
16
+ private static appendToGlobalMarginValuesLegendMargin;
17
+ private static clearMarginByLegendBlockPosition;
18
+ private static recalcMarginByTitle;
19
+ }
@@ -0,0 +1,126 @@
1
+ import { AxisModel } from "./featuresModel/axisModel";
2
+ import { DataManagerModel } from "./dataManagerModel";
3
+ import { LegendModel, MIN_DONUT_BLOCK_SIZE } from "./featuresModel/legendModel/legendModel";
4
+ import { AxisType } from "./modelBuilder";
5
+ import { TwoDimensionalModel } from "./notations/twoDimensionalModel";
6
+ export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
7
+ export const AXIS_VERTICAL_LABEL_PADDING = 10;
8
+ export class MarginModel {
9
+ static getMargin(designerConfig, config, otherComponents, data) {
10
+ const margin = Object.assign({}, designerConfig.canvas.chartBlockMargin);
11
+ this.recalcMarginWithLegend(margin, config, designerConfig.canvas.legendBlock.maxWidth, otherComponents.legendBlock, data);
12
+ this.recalcMarginByTitle(margin, otherComponents.titleBlock);
13
+ if (config.options.type === '2d' || config.options.type === 'interval') {
14
+ const labelSize = this.getHorizontalMarginByAxisLabels(designerConfig.canvas.axisLabel.maxSize.main, config.options.axis, data, config.options);
15
+ this.recalcVerticalMarginByAxisLabelHeight(labelSize, margin, config.options.orientation, config.options.axis);
16
+ // Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
17
+ // При этом все графики должны иметь: embeddedLabels = 'key'
18
+ // И все графики должны быть типа bar.
19
+ const showingFlag = config.options.type === '2d'
20
+ ? !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(config.options.charts, config.options.orientation)
21
+ : true;
22
+ this.recalcHorizontalMarginByAxisLabelWidth(labelSize, margin, config.options.orientation, config.options.axis, showingFlag);
23
+ }
24
+ return margin;
25
+ }
26
+ static recalcPolarMarginWithScopedData(margin, blockSize, designerConfig, config, legendBlockModel, dataScope, options) {
27
+ let position = LegendModel.getLegendModel(config.options.type, config.options.legend.show, config.canvas.size, margin).position;
28
+ if (position !== 'off') {
29
+ if (position === 'right' && blockSize.width - margin.left - margin.right < MIN_DONUT_BLOCK_SIZE)
30
+ position = 'bottom';
31
+ this.clearMarginByLegendBlockPosition(margin, legendBlockModel);
32
+ let allowableKeys = [...dataScope.allowableKeys];
33
+ if (dataScope.hidedRecordsAmount !== 0 && position === 'bottom')
34
+ allowableKeys.push('1'); // Если есть спрятанные записи, то в массив добавляется объект, чтобы выделить место в легенде для индикатора переполнения
35
+ const legendSize = LegendModel.getLegendSize(config.options.type, position, allowableKeys, designerConfig.canvas.legendBlock.maxWidth, config.canvas.size, legendBlockModel);
36
+ margin[position] += legendSize + legendBlockModel.coordinate[position].margin[position];
37
+ legendBlockModel.coordinate[position].size = legendSize;
38
+ options.legend.position = position;
39
+ }
40
+ }
41
+ static recalcMarginByVerticalAxisLabel(margin, config, designerConfig, dataScope) {
42
+ if ((config.options.type === '2d' || config.options.type === 'interval') && config.options.orientation === 'vertical') {
43
+ const axisLabelSize = AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataScope.allowableKeys);
44
+ const axisConfig = AxisModel.getKeyAxisLabelPosition(margin, config.canvas.size, dataScope.allowableKeys.length);
45
+ const marginOrient = config.options.axis.key.position === 'end' ? 'bottom' : 'top';
46
+ if (axisConfig === 'rotated')
47
+ margin[marginOrient] += (axisLabelSize.width - axisLabelSize.height);
48
+ }
49
+ }
50
+ static getHorizontalMarginByAxisLabels(labelsMaxWidth, axis, data, options) {
51
+ const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, options.orientation, axis.key.position);
52
+ let labelsTexts;
53
+ if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
54
+ labelsTexts = DataManagerModel.getDataValuesByKeyField(data, options.data.dataSource, options.data.keyField.name);
55
+ }
56
+ else {
57
+ labelsTexts = ['0000'];
58
+ }
59
+ return AxisModel.getLabelSize(labelsMaxWidth, labelsTexts);
60
+ }
61
+ static recalcVerticalMarginByAxisLabelHeight(labelSize, margin, orientation, axis) {
62
+ const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, orientation, axis.key.position);
63
+ const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
64
+ if ((keyAxisOrient === 'bottom' || keyAxisOrient === 'top')) {
65
+ if (axis.key.visibility)
66
+ margin[keyAxisOrient] += labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING;
67
+ }
68
+ else if (axis.value.visibility) {
69
+ margin[valueAxisOrient] += labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING;
70
+ }
71
+ }
72
+ static recalcHorizontalMarginByAxisLabelWidth(labelSize, margin, orientation, axis, isShow) {
73
+ const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, orientation, axis.key.position);
74
+ const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
75
+ if ((keyAxisOrient === 'left' || keyAxisOrient === 'right') && isShow && axis.key.visibility) {
76
+ margin[keyAxisOrient] += labelSize.width + AXIS_VERTICAL_LABEL_PADDING;
77
+ }
78
+ else if ((valueAxisOrient === 'left' || valueAxisOrient === 'right') && axis.value.visibility) {
79
+ margin[valueAxisOrient] += labelSize.width + AXIS_VERTICAL_LABEL_PADDING;
80
+ }
81
+ }
82
+ static recalcMarginWithLegend(margin, config, legendMaxWidth, legendBlockModel, data) {
83
+ const legendPosition = LegendModel.getLegendModel(config.options.type, config.options.legend.show, config.canvas.size, margin).position;
84
+ if (legendPosition !== 'off') {
85
+ const legendItemsContent = this.getLegendItemsContent(config.options, data);
86
+ const legendSize = LegendModel.getLegendSize(config.options.type, legendPosition, legendItemsContent, legendMaxWidth, config.canvas.size, legendBlockModel);
87
+ margin[legendPosition] += legendSize;
88
+ if (legendSize !== 0)
89
+ this.appendToGlobalMarginValuesLegendMargin(margin, legendPosition, legendBlockModel);
90
+ legendBlockModel.coordinate[legendPosition].size = legendSize;
91
+ }
92
+ }
93
+ static getLegendItemsContent(options, data) {
94
+ if (options.type === '2d') {
95
+ let texts = [];
96
+ options.charts.forEach(chart => {
97
+ texts = texts.concat(chart.data.valueFields.map(field => field.title));
98
+ });
99
+ return texts;
100
+ }
101
+ else if (options.type === 'polar') {
102
+ return DataManagerModel.getDataValuesByKeyField(data, options.data.dataSource, options.data.keyField.name);
103
+ }
104
+ else if (options.type === 'interval') {
105
+ return [options.chart.data.valueField1.name];
106
+ }
107
+ }
108
+ static appendToGlobalMarginValuesLegendMargin(margin, position, legendBlockModel) {
109
+ const legendCoordinate = legendBlockModel.coordinate;
110
+ if (position === 'left' || position === 'right')
111
+ margin[position] += legendCoordinate[position].margin.left + legendCoordinate[position].margin.right;
112
+ else
113
+ margin[position] += legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom;
114
+ }
115
+ static clearMarginByLegendBlockPosition(margin, legendBlockModel) {
116
+ const legendCoordinate = legendBlockModel.coordinate;
117
+ ['left', 'right', 'top', 'bottom'].forEach((position) => {
118
+ margin[position] -= legendCoordinate[position].size === 0
119
+ ? 0
120
+ : legendCoordinate[position].size + legendCoordinate[position].margin[position];
121
+ });
122
+ }
123
+ static recalcMarginByTitle(margin, titleBlockModel) {
124
+ margin.top += titleBlockModel.margin.top + titleBlockModel.size;
125
+ }
126
+ }