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,137 +0,0 @@
1
- import { AxisModel } from "./featuresModel/axisModel";
2
- import { LegendCanvasModel } from "./featuresModel/legendModel/legendCanvasModel";
3
- import { MIN_DONUT_BLOCK_SIZE } from "./featuresModel/legendModel/legendModel";
4
- import { ModelHelper } from "./modelHelper";
5
- export class DataManagerModel {
6
- static getPreparedData(data, allowableKeys, config) {
7
- const scopedData = this.getScopedData(data, allowableKeys, config);
8
- this.setDataType(scopedData, config);
9
- return scopedData;
10
- }
11
- static getDataScope(config, margin, data, designerConfig, legendBlock) {
12
- if (config.options.type === '2d' || config.options.type === 'interval') {
13
- return this.getDataScopeFor2D(config.options, config.canvas.size, margin, data, designerConfig);
14
- }
15
- else if (config.options.type === 'polar') {
16
- return this.getDataScopeForPolar(config.options, config.canvas.size, margin, data, legendBlock, designerConfig.canvas.legendBlock);
17
- }
18
- }
19
- static getDataValuesByKeyField(data, dataSourceName, keyFieldName) {
20
- return data[dataSourceName].map(dataRow => dataRow[keyFieldName]);
21
- }
22
- static getDataScopeFor2D(configOptions, blockSize, margin, data, designerConfig) {
23
- // Для interval всегда один элемент, так как там может быть только один столбик
24
- let itemsLength = 1;
25
- if (configOptions.type === '2d') {
26
- itemsLength = (configOptions.charts)
27
- .filter((chart) => chart.type === 'bar').length;
28
- if (itemsLength === 0)
29
- itemsLength = 1; // Если баров нет, то для одной записи выделяется столько же места, сколько для одного столбика
30
- }
31
- if (itemsLength !== 0) {
32
- const axisLength = AxisModel.getAxisLength(configOptions.orientation, margin, blockSize);
33
- const uniqueKeys = ModelHelper.getUniqueValues(data[configOptions.data.dataSource].map(d => d[configOptions.data.keyField.name]));
34
- const dataLength = uniqueKeys.length;
35
- const limit = this.getDataLimitByItemSize(this.getElementsInGroupAmount(configOptions, itemsLength), dataLength, axisLength, designerConfig.canvas.chartOptions.bar);
36
- const allowableKeys = uniqueKeys.slice(0, limit);
37
- return {
38
- allowableKeys,
39
- hidedRecordsAmount: dataLength - allowableKeys.length
40
- };
41
- }
42
- return {
43
- allowableKeys: this.getDataValuesByKeyField(data, configOptions.data.dataSource, configOptions.data.keyField.name),
44
- hidedRecordsAmount: 0
45
- };
46
- }
47
- static getDataScopeForPolar(configOptions, blockSize, margin, data, legendBlock, legendCanvas) {
48
- const dataset = data[configOptions.data.dataSource];
49
- const keyFieldName = configOptions.data.keyField.name;
50
- const keys = dataset.map(dataRow => dataRow[keyFieldName]);
51
- if (!configOptions.legend.show) {
52
- return {
53
- allowableKeys: keys,
54
- hidedRecordsAmount: 0
55
- };
56
- }
57
- let position;
58
- if (blockSize.width - margin.left - margin.right >= MIN_DONUT_BLOCK_SIZE)
59
- position = 'right';
60
- else
61
- position = 'bottom';
62
- let maxItemsNumber;
63
- if (position === 'right') {
64
- maxItemsNumber = LegendCanvasModel.findElementsAmountByLegendSize(keys, position, legendCanvas.maxWidth, blockSize.height - margin.top - margin.bottom);
65
- }
66
- else {
67
- let marginBottom = margin.bottom - (legendBlock.coordinate.bottom.size === 0 ? legendBlock.coordinate.bottom.size : legendBlock.coordinate.bottom.size - legendBlock.coordinate.bottom.margin.bottom);
68
- maxItemsNumber = LegendCanvasModel.findElementsAmountByLegendSize(keys, position, blockSize.width - margin.left - margin.right, blockSize.height - margin.top - marginBottom - legendBlock.coordinate.bottom.margin.bottom - MIN_DONUT_BLOCK_SIZE);
69
- }
70
- return {
71
- allowableKeys: keys.slice(0, maxItemsNumber),
72
- hidedRecordsAmount: keys.length - maxItemsNumber
73
- };
74
- }
75
- /**
76
- * Выводит количество элементов (преимущественно баров) в одной группе. Группа - один ключ
77
- * @param configOptions
78
- * @param chartsLength
79
- */
80
- static getElementsInGroupAmount(configOptions, chartsLength) {
81
- if (configOptions.type === '2d')
82
- return this.getBarChartsInGroupAmount(configOptions.charts);
83
- return chartsLength;
84
- }
85
- static getBarChartsInGroupAmount(charts) {
86
- let barsAmount = 0;
87
- charts.forEach(chart => {
88
- if (chart.type === 'bar' && chart.isSegmented)
89
- barsAmount += 1; // в сегментированном баре все valueFields находятся внутри одного бара, поэтому бар всегда один.
90
- else if (chart.type === 'bar')
91
- barsAmount += chart.data.valueFields.length;
92
- });
93
- return barsAmount;
94
- }
95
- static getScopedData(data, allowableKeys, config) {
96
- const newData = {};
97
- newData[config.options.data.dataSource] = this.getScopedChartData(data[config.options.data.dataSource], allowableKeys, config.options.data.keyField.name);
98
- return newData;
99
- }
100
- static getScopedChartData(data, allowableKeys, keyFieldName) {
101
- return data.filter(d => allowableKeys.findIndex(key => key === d[keyFieldName]) !== -1);
102
- }
103
- static setDataType(data, config) {
104
- if (config.options.type === 'polar' || config.options.type === '2d') {
105
- // Форматиривание для оси ключей пока не совсем верно установлено
106
- // if(config.options.data.keyField.format === 'date') {
107
- // data[config.options.data.dataSource] = this.getTypedData(data[config.options.data.dataSource], config.options.data.keyField);
108
- // }
109
- }
110
- else if (config.options.type === 'interval') {
111
- const chart = config.options.chart;
112
- if (chart.data.valueField1.format === 'date') {
113
- data[config.options.data.dataSource] = this.getTypedData(data[config.options.data.dataSource], chart.data.valueField1);
114
- }
115
- if (chart.data.valueField2.format === 'date') {
116
- data[config.options.data.dataSource] = this.getTypedData(data[config.options.data.dataSource], chart.data.valueField2);
117
- }
118
- }
119
- }
120
- static getTypedData(data, field) {
121
- if (field.format === 'date')
122
- data.forEach(d => {
123
- d[field.name] = new Date(d[field.name]);
124
- });
125
- return data;
126
- }
127
- static getDataLimitByItemSize(elementsInGroupAmount, dataLength, axisLength, barOptions) {
128
- let sumSize = dataLength * (elementsInGroupAmount * barOptions.minBarWidth + (elementsInGroupAmount - 1) * barOptions.barDistance + barOptions.groupMinDistance);
129
- while (dataLength !== 0 && axisLength < sumSize) {
130
- dataLength--;
131
- // find whole space for bars in group + distance between bars + group distance
132
- sumSize = dataLength * (elementsInGroupAmount * barOptions.minBarWidth + (elementsInGroupAmount - 1)
133
- * barOptions.barDistance + barOptions.groupMinDistance);
134
- }
135
- return dataLength;
136
- }
137
- }
@@ -1,18 +0,0 @@
1
- import { AxisPosition, ChartOrientation, DataOptions, MdtChartsDataSource, DiscreteAxisOptions, NumberAxisOptions, Size, TwoDimensionalChart } from "../../config/config";
2
- import { AxisLabelPosition, AxisModelOptions, BlockMargin, Orient } from "../model";
3
- import { AxisType } from "../modelBuilder";
4
- import { AxisLabelCanvas, TooltipSettings } from "../../designer/designerConfig";
5
- export interface LabelSize {
6
- width: number;
7
- height: number;
8
- }
9
- export declare class AxisModel {
10
- static getKeyAxis(charts: TwoDimensionalChart[], data: MdtChartsDataSource, dataOptions: DataOptions, orient: ChartOrientation, axisConfig: DiscreteAxisOptions, labelConfig: AxisLabelCanvas, margin: BlockMargin, blockSize: Size, tooltipSettings: TooltipSettings): AxisModelOptions;
11
- static getValueAxis(orient: ChartOrientation, axisConfig: NumberAxisOptions, labelConfig: AxisLabelCanvas, margin: BlockMargin, blockSize: Size): AxisModelOptions;
12
- static getAxisLength(chartOrientation: ChartOrientation, margin: BlockMargin, blockSize: Size): number;
13
- static getAxisOrient(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition): Orient;
14
- static getAxisTranslateX(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition, margin: BlockMargin, blockWidth: number): number;
15
- static getAxisTranslateY(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition, margin: BlockMargin, blockHeight: number): number;
16
- static getKeyAxisLabelPosition(margin: BlockMargin, blockSize: Size, scopedDataLength: number): AxisLabelPosition;
17
- static getLabelSize(labelMaxWidth: number, labelTexts: any[]): LabelSize;
18
- }
@@ -1,111 +0,0 @@
1
- import { ModelHelper } from "../modelHelper";
2
- import { AxisType, CLASSES } from "../modelBuilder";
3
- import { DataManagerModel } from "../dataManagerModel";
4
- import { TwoDimensionalModel } from "../notations/twoDimensionalModel";
5
- export class AxisModel {
6
- static getKeyAxis(charts, data, dataOptions, orient, axisConfig, labelConfig, margin, blockSize, tooltipSettings) {
7
- return {
8
- type: 'key',
9
- orient: AxisModel.getAxisOrient(AxisType.Key, orient, axisConfig.position),
10
- translate: {
11
- translateX: AxisModel.getAxisTranslateX(AxisType.Key, orient, axisConfig.position, margin, blockSize.width),
12
- translateY: AxisModel.getAxisTranslateY(AxisType.Key, orient, axisConfig.position, margin, blockSize.height)
13
- },
14
- cssClass: 'key-axis',
15
- ticks: axisConfig.ticks,
16
- labels: {
17
- maxSize: AxisModel.getLabelSize(labelConfig.maxSize.main, data[dataOptions.dataSource].map(d => d[dataOptions.keyField.name])).width,
18
- position: AxisModel.getKeyAxisLabelPosition(margin, blockSize, DataManagerModel.getDataValuesByKeyField(data, dataOptions.dataSource, dataOptions.keyField.name).length),
19
- visible: !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(charts, orient),
20
- defaultTooltip: tooltipSettings.position === 'fixed'
21
- },
22
- visibility: axisConfig.visibility
23
- };
24
- }
25
- static getValueAxis(orient, axisConfig, labelConfig, margin, blockSize) {
26
- return {
27
- type: 'value',
28
- orient: AxisModel.getAxisOrient(AxisType.Value, orient, axisConfig.position),
29
- translate: {
30
- translateX: AxisModel.getAxisTranslateX(AxisType.Value, orient, axisConfig.position, margin, blockSize.width),
31
- translateY: AxisModel.getAxisTranslateY(AxisType.Value, orient, axisConfig.position, margin, blockSize.height)
32
- },
33
- cssClass: 'value-axis',
34
- ticks: axisConfig.ticks,
35
- labels: {
36
- maxSize: labelConfig.maxSize.main,
37
- position: 'straight',
38
- visible: true,
39
- defaultTooltip: true
40
- },
41
- visibility: axisConfig.visibility
42
- };
43
- }
44
- static getAxisLength(chartOrientation, margin, blockSize) {
45
- if (chartOrientation === 'horizontal') {
46
- return blockSize.height - margin.top - margin.bottom;
47
- }
48
- else {
49
- return blockSize.width - margin.left - margin.right;
50
- }
51
- }
52
- static getAxisOrient(axisType, chartOrientation, axisPosition) {
53
- if (chartOrientation === 'vertical') {
54
- if (axisPosition === 'start')
55
- return axisType === AxisType.Key ? 'top' : 'left';
56
- return axisType === AxisType.Key ? 'bottom' : 'right';
57
- }
58
- if (axisPosition === 'start')
59
- return axisType === AxisType.Key ? 'left' : 'top';
60
- return axisType === AxisType.Key ? 'right' : 'bottom';
61
- }
62
- static getAxisTranslateX(axisType, chartOrientation, axisPosition, margin, blockWidth) {
63
- const orient = AxisModel.getAxisOrient(axisType, chartOrientation, axisPosition);
64
- if (orient === 'top' || orient === 'left')
65
- return margin.left;
66
- else if (orient === 'bottom')
67
- return margin.left;
68
- return blockWidth - margin.right;
69
- }
70
- static getAxisTranslateY(axisType, chartOrientation, axisPosition, margin, blockHeight) {
71
- const orient = AxisModel.getAxisOrient(axisType, chartOrientation, axisPosition);
72
- if (orient === 'top' || orient === 'left')
73
- return margin.top;
74
- else if (orient === 'bottom')
75
- return blockHeight - margin.bottom;
76
- return margin.top;
77
- }
78
- static getKeyAxisLabelPosition(margin, blockSize, scopedDataLength) {
79
- const minBandSize = 50;
80
- if ((blockSize.width - margin.left - margin.right) / scopedDataLength < minBandSize)
81
- return 'rotated';
82
- return 'straight';
83
- }
84
- static getLabelSize(labelMaxWidth, labelTexts) {
85
- const labelSize = {
86
- width: 0,
87
- height: 0
88
- };
89
- const textBlock = document.createElement('span');
90
- textBlock.style.opacity = '0';
91
- textBlock.style.position = 'absolute';
92
- textBlock.style.whiteSpace = 'nowrap';
93
- textBlock.classList.add(CLASSES.dataLabel);
94
- let maxLabel = '';
95
- let biggestScore = 0;
96
- let maxWidth = 0;
97
- labelTexts.forEach((text) => {
98
- if (ModelHelper.getStringScore(text) > biggestScore) {
99
- maxLabel = text;
100
- biggestScore = ModelHelper.getStringScore(text);
101
- }
102
- });
103
- textBlock.textContent = maxLabel === '0000' ? maxLabel : maxLabel + 'D';
104
- document.body.append(textBlock);
105
- maxWidth = Math.ceil(textBlock.getBoundingClientRect().width);
106
- labelSize.height = textBlock.getBoundingClientRect().height;
107
- labelSize.width = maxWidth > labelMaxWidth ? labelMaxWidth : maxWidth;
108
- textBlock.remove();
109
- return labelSize;
110
- }
111
- }
@@ -1,7 +0,0 @@
1
- import { LegendPosition } from "../../model";
2
- export declare type LegendItemsDirection = 'row' | 'column';
3
- export declare class LegendCanvasModel {
4
- static getLegendHeight(texts: string[], blockWidth: number, marginLeft: number, marginRight: number, itemsPosition: LegendItemsDirection, legendPosition: LegendPosition): number;
5
- static getLegendItemWidth(text: string): number;
6
- static findElementsAmountByLegendSize(texts: string[], position: LegendPosition, legendBlockWidth: number, legendBlockHeight: number): number;
7
- }
@@ -1,86 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
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
- }
@@ -1,78 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
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
- }
@@ -1,12 +0,0 @@
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
- }
@@ -1,17 +0,0 @@
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
- }
@@ -1,100 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- import { TitleBlockModel } from "../model";
2
- export declare class TitleModel {
3
- static getTitleModel(): TitleBlockModel;
4
- }
@@ -1,14 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- import { TooltipSettings } from "../../designer/designerConfig";
2
- export declare class TooltipModel {
3
- static getTooltipModel(options: TooltipSettings): TooltipSettings;
4
- }
@@ -1,7 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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
- }