mdt-charts 1.12.11 → 1.12.15
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.
- package/lib/config/config.d.ts +2 -2
- package/lib/engine/contentManager/contentManager.d.ts +9 -0
- package/lib/engine/contentManager/contentManager.js +15 -0
- package/lib/engine/contentManager/contentManagerFactory.d.ts +14 -0
- package/lib/engine/contentManager/contentManagerFactory.js +20 -0
- package/lib/engine/engine.js +4 -4
- package/lib/engine/features/axis/axis.js +1 -1
- package/lib/engine/features/axis/axisLabelDomHelper.js +1 -1
- package/lib/engine/features/tolltip/newTooltip/newTooltip.js +1 -1
- package/lib/engine/features/tolltip/tooltip.d.ts +4 -4
- package/lib/engine/features/tolltip/tooltip.js +4 -4
- package/lib/engine/polarNotation/polarManager.d.ts +6 -5
- package/lib/engine/polarNotation/polarManager.js +4 -4
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +7 -6
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +5 -5
- package/lib/model/dataManagerModel/dataManagerModel.d.ts +1 -0
- package/lib/model/dataManagerModel/dataManagerModel.js +7 -0
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +2 -1
- package/lib/model/featuresModel/legendModel/legendModel.js +9 -2
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +2 -3
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +2 -2
- package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +3 -1
- package/lib/model/featuresModel/scaleModel/scaleDomainService.d.ts +6 -0
- package/lib/model/featuresModel/scaleModel/scaleDomainService.js +53 -0
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +5 -12
- package/lib/model/featuresModel/scaleModel/scaleModel.js +11 -94
- package/lib/model/featuresModel/scaleModel/scaleModelServices.d.ts +5 -0
- package/lib/model/featuresModel/scaleModel/scaleModelServices.js +22 -0
- package/lib/model/margin/marginModel.d.ts +10 -0
- package/lib/model/margin/marginModel.js +20 -0
- package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +14 -0
- package/lib/model/margin/twoDim/twoDimMarginModel.js +69 -0
- package/lib/model/modelBuilder.d.ts +0 -1
- package/lib/model/modelBuilder.js +8 -12
- package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +4 -3
- package/lib/model/modelInstance/canvasModel/canvasModel.js +1 -1
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasMarginModel.d.ts +11 -0
- package/lib/{engine/features/tolltip/newTooltip/newTooltip.test.d.ts → model/modelInstance/canvasModel/canvasSizesModel/canvasMarginModel.js} +0 -0
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasSizeModel.d.ts +4 -0
- package/lib/{engine/twoDimensionalNotation/bar/stackedData/dataStacker.test.d.ts → model/modelInstance/canvasModel/canvasSizesModel/canvasSizeModel.js} +0 -0
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.d.ts +11 -0
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +26 -0
- package/lib/model/modelInstance/canvasModel/titleCanvas.js +1 -1
- package/lib/model/notations/intervalModel.d.ts +3 -3
- package/lib/model/notations/intervalModel.js +8 -9
- package/lib/model/notations/polar/donut/donutAggregatorService.d.ts +1 -0
- package/lib/model/notations/polar/donut/donutAggregatorService.js +19 -4
- package/lib/model/notations/twoDimensionalModel.d.ts +2 -2
- package/lib/model/notations/twoDimensionalModel.js +6 -4
- package/lib/style/charts-main.css +9 -9
- package/lib/style/charts-main.less +9 -9
- package/package.json +1 -1
- package/tsconfig.production.json +2 -1
- package/lib/engine/features/tolltip/newTooltip/newTooltip.test.js +0 -186
- package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.test.js +0 -199
- package/lib/model/featuresModel/scaleModel.d.ts +0 -19
- package/lib/model/featuresModel/scaleModel.js +0 -115
- package/lib/model/marginModel.d.ts +0 -17
- package/lib/model/marginModel.js +0 -80
- package/lib/model/modelHelper.d.ts +0 -7
- package/lib/model/modelHelper.js +0 -41
- package/lib/model/modelInstance/dataModel.d.ts +0 -11
- package/lib/model/modelInstance/dataModel.js +0 -23
- package/lib/model/notations/polarModel.d.ts +0 -15
- package/lib/model/notations/polarModel.js +0 -59
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { NewTooltipServiceClass } from "./newTooltipService";
|
|
2
|
-
const ignoredValue = 0;
|
|
3
|
-
const ignoredBigvalue = 1000000;
|
|
4
|
-
describe('newTooltipService', () => {
|
|
5
|
-
const getIgnoredSize = (big) => {
|
|
6
|
-
return {
|
|
7
|
-
height: big ? ignoredBigvalue : ignoredValue,
|
|
8
|
-
width: big ? ignoredBigvalue : ignoredValue
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
const getSizeWithOne = (key, value) => {
|
|
12
|
-
const size = getIgnoredSize();
|
|
13
|
-
size[key] = value;
|
|
14
|
-
return size;
|
|
15
|
-
};
|
|
16
|
-
const getPosWithOne = (key, value) => {
|
|
17
|
-
const coordinate = {
|
|
18
|
-
left: ignoredValue,
|
|
19
|
-
top: ignoredValue
|
|
20
|
-
};
|
|
21
|
-
coordinate[key] = value;
|
|
22
|
-
return coordinate;
|
|
23
|
-
};
|
|
24
|
-
const getBoundingWithOne = (key, value) => {
|
|
25
|
-
const blockBounding = {
|
|
26
|
-
left: ignoredValue,
|
|
27
|
-
bottom: ignoredValue,
|
|
28
|
-
height: ignoredValue,
|
|
29
|
-
top: ignoredValue,
|
|
30
|
-
width: ignoredValue
|
|
31
|
-
};
|
|
32
|
-
blockBounding[key] = value;
|
|
33
|
-
return blockBounding;
|
|
34
|
-
};
|
|
35
|
-
const service = new NewTooltipServiceClass();
|
|
36
|
-
describe('getTooltipByWindow with parentBlock', () => {
|
|
37
|
-
test('should return left point equal to `-(left of parent block)` if left of tooltip is less', () => {
|
|
38
|
-
const tooltipBounding = getIgnoredSize();
|
|
39
|
-
const preCoordinate = getPosWithOne("left", -50);
|
|
40
|
-
const windowSize = getIgnoredSize(true);
|
|
41
|
-
const blockBounding = getBoundingWithOne("left", 10);
|
|
42
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
43
|
-
expect(res.left).toBe(-blockBounding.left);
|
|
44
|
-
});
|
|
45
|
-
test('should return left point equal to left of preCoordinate if left of tooltip is less', () => {
|
|
46
|
-
const tooltipBounding = getIgnoredSize();
|
|
47
|
-
const preCoordinate = getPosWithOne("left", 20);
|
|
48
|
-
const windowSize = getIgnoredSize(true);
|
|
49
|
-
const blockBounding = getBoundingWithOne("left", 10);
|
|
50
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
51
|
-
expect(res.left).toBe(preCoordinate.left);
|
|
52
|
-
});
|
|
53
|
-
test('should return left point equal to `(window width - tooltip width)` if right of tooltip is bigger', () => {
|
|
54
|
-
const tooltipBounding = getSizeWithOne("width", 50);
|
|
55
|
-
const preCoordinate = getPosWithOne("left", 20);
|
|
56
|
-
const windowSize = getSizeWithOne("width", 90);
|
|
57
|
-
const blockBounding = getBoundingWithOne("left", 30);
|
|
58
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
59
|
-
expect(res.left).toBe(-8); // 50 + 20 + 30 > 90 => 90 - 30 - 50 - scrollPad(18)
|
|
60
|
-
});
|
|
61
|
-
test('should return left point equal to left of preCoordinate if right of tooltip is less than window width', () => {
|
|
62
|
-
const tooltipBounding = getSizeWithOne("width", 50);
|
|
63
|
-
const preCoordinate = getPosWithOne("left", 20);
|
|
64
|
-
const windowSize = getSizeWithOne("width", 200);
|
|
65
|
-
const blockBounding = getBoundingWithOne("left", 30);
|
|
66
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
67
|
-
expect(res.left).toBe(preCoordinate.left); // 50 + 20 + 30 < 200
|
|
68
|
-
});
|
|
69
|
-
test('should return top point equal to `-(top of parent block)` if top of tooltip is less', () => {
|
|
70
|
-
const tooltipBounding = getIgnoredSize();
|
|
71
|
-
const preCoordinate = getPosWithOne("top", -40);
|
|
72
|
-
const windowSize = getIgnoredSize(true);
|
|
73
|
-
const blockBounding = getBoundingWithOne("top", -20);
|
|
74
|
-
let res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
75
|
-
expect(res.top).toBe(-blockBounding.top);
|
|
76
|
-
blockBounding.top = -60;
|
|
77
|
-
res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
78
|
-
expect(res.top).toBe(-blockBounding.top); // 60 by blockBounding = 0 by window
|
|
79
|
-
blockBounding.top = -100;
|
|
80
|
-
preCoordinate.top = 20;
|
|
81
|
-
res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
82
|
-
expect(res.top).toBe(-blockBounding.top);
|
|
83
|
-
blockBounding.top = -10;
|
|
84
|
-
preCoordinate.top = 5;
|
|
85
|
-
res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
86
|
-
expect(res.top).toBe(-blockBounding.top);
|
|
87
|
-
});
|
|
88
|
-
test('should return top point equal top of preCoordinate if top of tooltip is bigger', () => {
|
|
89
|
-
const tooltipBounding = getIgnoredSize();
|
|
90
|
-
const preCoordinate = getPosWithOne("top", 20);
|
|
91
|
-
const windowSize = getIgnoredSize(true);
|
|
92
|
-
const blockBounding = getBoundingWithOne("top", 100);
|
|
93
|
-
let res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
94
|
-
expect(res.top).toBe(preCoordinate.top);
|
|
95
|
-
preCoordinate.top = -99;
|
|
96
|
-
res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
97
|
-
expect(res.top).toBe(preCoordinate.top);
|
|
98
|
-
});
|
|
99
|
-
test('should return top point equal to `(winHeight - tooltipHeight)` if bottom of tooltip is bigger than window height', () => {
|
|
100
|
-
const tooltipBounding = getSizeWithOne("height", 50);
|
|
101
|
-
const preCoordinate = getPosWithOne("top", 90);
|
|
102
|
-
const windowSize = getSizeWithOne("height", 200);
|
|
103
|
-
const blockBounding = {
|
|
104
|
-
left: ignoredValue,
|
|
105
|
-
bottom: 210,
|
|
106
|
-
height: 110,
|
|
107
|
-
top: 100,
|
|
108
|
-
width: ignoredValue
|
|
109
|
-
};
|
|
110
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
111
|
-
expect(res.top).toBe(50); // 110 - 50 - (210 - 200)
|
|
112
|
-
});
|
|
113
|
-
test('should return top point equal to top of preCoordinate if bottom of tooltip is less than height of window', () => {
|
|
114
|
-
const tooltipBounding = getSizeWithOne("height", 50);
|
|
115
|
-
const preCoordinate = getPosWithOne("top", 90);
|
|
116
|
-
const windowSize = getSizeWithOne("height", 300);
|
|
117
|
-
const blockBounding = {
|
|
118
|
-
left: ignoredValue,
|
|
119
|
-
bottom: 210,
|
|
120
|
-
height: 110,
|
|
121
|
-
top: 100,
|
|
122
|
-
width: ignoredValue
|
|
123
|
-
};
|
|
124
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
125
|
-
expect(res.top).toBe(preCoordinate.top); // 90 + 50 + 100 < 300
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
describe('getTooltipByWindow without parentBlock', () => {
|
|
129
|
-
test('should return left point equal to 0 if left of tooltip is less', () => {
|
|
130
|
-
const tooltipBounding = getIgnoredSize();
|
|
131
|
-
const preCoordinate = getPosWithOne("left", -50);
|
|
132
|
-
const windowSize = getIgnoredSize(true);
|
|
133
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
134
|
-
expect(res.left === 0).toBe(true); // negative zero jest not matching with simple zero
|
|
135
|
-
});
|
|
136
|
-
test('should return left point equal to left of preCoordinate if left of tooltip is bigger than 0', () => {
|
|
137
|
-
const tooltipBounding = getIgnoredSize();
|
|
138
|
-
const preCoordinate = getPosWithOne("left", 20);
|
|
139
|
-
const windowSize = getIgnoredSize(true);
|
|
140
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
141
|
-
expect(res.left).toBe(preCoordinate.left);
|
|
142
|
-
});
|
|
143
|
-
test('should return left point equal to `(window width - tooltip width)` if right of tooltip is bigger', () => {
|
|
144
|
-
const tooltipBounding = getSizeWithOne("width", 50);
|
|
145
|
-
const preCoordinate = getPosWithOne("left", 60);
|
|
146
|
-
const windowSize = getSizeWithOne("width", 100);
|
|
147
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
148
|
-
expect(res.left).toBe(32); // 60 + 50 > 100 => 100 - 50 - scrollPad(18)
|
|
149
|
-
});
|
|
150
|
-
test('should return left point equal to left of preCoordinate if right of tooltip is less than window width', () => {
|
|
151
|
-
const tooltipBounding = getSizeWithOne("width", 50);
|
|
152
|
-
const preCoordinate = getPosWithOne("left", 20);
|
|
153
|
-
const windowSize = getSizeWithOne("width", 200);
|
|
154
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
155
|
-
expect(res.left).toBe(preCoordinate.left); // 50 + 20 < 200
|
|
156
|
-
});
|
|
157
|
-
test('should return top point equal to 0 if top of tooltip is less than 0', () => {
|
|
158
|
-
const tooltipBounding = getIgnoredSize();
|
|
159
|
-
const preCoordinate = getPosWithOne("top", -40);
|
|
160
|
-
const windowSize = getIgnoredSize(true);
|
|
161
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
162
|
-
expect(res.top === 0).toBe(true);
|
|
163
|
-
});
|
|
164
|
-
test('should return top point equal top of preCoordinate if top of tooltip is bigger than 0', () => {
|
|
165
|
-
const tooltipBounding = getIgnoredSize();
|
|
166
|
-
const preCoordinate = getPosWithOne("top", 20);
|
|
167
|
-
const windowSize = getIgnoredSize(true);
|
|
168
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
169
|
-
expect(res.top).toBe(preCoordinate.top);
|
|
170
|
-
});
|
|
171
|
-
test('should return top point equal to `(winHeight - tooltipHeight)` if bottom of tooltip is bigger than window height', () => {
|
|
172
|
-
const tooltipBounding = getSizeWithOne("height", 50);
|
|
173
|
-
const preCoordinate = getPosWithOne("top", 90);
|
|
174
|
-
const windowSize = getSizeWithOne("height", 100);
|
|
175
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
176
|
-
expect(res.top).toBe(50); // 90 + 50 > 100 => 100 - 50
|
|
177
|
-
});
|
|
178
|
-
test('should return top point equal to top of preCoordinate if bottom of tooltip is less than height of window', () => {
|
|
179
|
-
const tooltipBounding = getSizeWithOne("height", 50);
|
|
180
|
-
const preCoordinate = getPosWithOne("top", 90);
|
|
181
|
-
const windowSize = getSizeWithOne("height", 300);
|
|
182
|
-
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
183
|
-
expect(res.top).toBe(preCoordinate.top); // 90 + 50 < 300
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
});
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { DataStacker } from "./dataStacker";
|
|
2
|
-
import { DataStackerService } from "./dataStackerService";
|
|
3
|
-
describe('DataStacker', () => {
|
|
4
|
-
const stacker = new DataStacker();
|
|
5
|
-
describe('getStackedData', () => {
|
|
6
|
-
describe('for positive values', () => {
|
|
7
|
-
let dataRows = [
|
|
8
|
-
{ price: 12, count: 30 },
|
|
9
|
-
{ price: 30, count: 12 },
|
|
10
|
-
{ price: 0, count: 100 },
|
|
11
|
-
{ price: 10, count: 0 }
|
|
12
|
-
];
|
|
13
|
-
const valueFields = ["price", "count"];
|
|
14
|
-
test('should return right stack', () => {
|
|
15
|
-
const res = stacker.getStackedData(dataRows, valueFields);
|
|
16
|
-
expect(res).toEqual([
|
|
17
|
-
[
|
|
18
|
-
{ "0": 0, "1": 12, data: dataRows[0] },
|
|
19
|
-
{ "0": 0, "1": 30, data: dataRows[1] },
|
|
20
|
-
{ "0": 0, "1": 0, data: dataRows[2] },
|
|
21
|
-
{ "0": 0, "1": 10, data: dataRows[3] },
|
|
22
|
-
],
|
|
23
|
-
[
|
|
24
|
-
{ "0": 12, "1": 42, data: dataRows[0] },
|
|
25
|
-
{ "0": 30, "1": 42, data: dataRows[1] },
|
|
26
|
-
{ "0": 0, "1": 100, data: dataRows[2] },
|
|
27
|
-
{ "0": 10, "1": 10, data: dataRows[3] },
|
|
28
|
-
]
|
|
29
|
-
]);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe('for negative values', () => {
|
|
33
|
-
let dataRows = [
|
|
34
|
-
{ price: -12, count: -30 },
|
|
35
|
-
{ price: -30, count: -12 },
|
|
36
|
-
{ price: 0, count: -100 },
|
|
37
|
-
{ price: -10, count: 0 }
|
|
38
|
-
];
|
|
39
|
-
const valueFields = ["price", "count"];
|
|
40
|
-
test('should return right stack', () => {
|
|
41
|
-
const res = stacker.getStackedData(dataRows, valueFields);
|
|
42
|
-
expect(res).toEqual([
|
|
43
|
-
[
|
|
44
|
-
{ "0": 0, "1": -12, data: dataRows[0] },
|
|
45
|
-
{ "0": 0, "1": -30, data: dataRows[1] },
|
|
46
|
-
{ "0": 0, "1": 0, data: dataRows[2] },
|
|
47
|
-
{ "0": 0, "1": -10, data: dataRows[3] },
|
|
48
|
-
],
|
|
49
|
-
[
|
|
50
|
-
{ "0": -12, "1": -42, data: dataRows[0] },
|
|
51
|
-
{ "0": -30, "1": -42, data: dataRows[1] },
|
|
52
|
-
{ "0": 0, "1": -100, data: dataRows[2] },
|
|
53
|
-
{ "0": -10, "1": -10, data: dataRows[3] },
|
|
54
|
-
]
|
|
55
|
-
]);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('DataStackerService', () => {
|
|
61
|
-
const service = new DataStackerService();
|
|
62
|
-
let data = [
|
|
63
|
-
[
|
|
64
|
-
{ "0": 0, "1": 42, data: {} },
|
|
65
|
-
{ "0": 0, "1": -123, data: {} }
|
|
66
|
-
]
|
|
67
|
-
];
|
|
68
|
-
describe('getLastValue', () => {
|
|
69
|
-
test('should return 0 if vfIndex is 0', () => {
|
|
70
|
-
const res = service.getValue0(data, 0, 0, 0);
|
|
71
|
-
expect(res).toBe(0);
|
|
72
|
-
});
|
|
73
|
-
test('should return last positive values if positive value exists and need positive', () => {
|
|
74
|
-
const res = service.getValue0(data, 1, 0, 12);
|
|
75
|
-
expect(res).toBe(42);
|
|
76
|
-
});
|
|
77
|
-
test('should return 0 if positive value not exists and need positive', () => {
|
|
78
|
-
const res = service.getValue0(data, 1, 1, 12);
|
|
79
|
-
expect(res).toBe(0);
|
|
80
|
-
});
|
|
81
|
-
test('should return last negative value if negative value exists and need negative', () => {
|
|
82
|
-
const res = service.getValue0(data, 1, 1, -12);
|
|
83
|
-
expect(res).toBe(-123);
|
|
84
|
-
});
|
|
85
|
-
test('should return 0 if negative value not exists and need negative', () => {
|
|
86
|
-
const res = service.getValue0(data, 1, 0, -12);
|
|
87
|
-
expect(res).toBe(0);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
describe('getValue1', () => {
|
|
91
|
-
test('should return sum of value0 + value from data', () => {
|
|
92
|
-
let res = service.getValue1(0, 12);
|
|
93
|
-
expect(res).toBe(12);
|
|
94
|
-
res = service.getValue1(-12, -30);
|
|
95
|
-
expect(res).toBe(-42);
|
|
96
|
-
res = service.getValue1(0, 30);
|
|
97
|
-
expect(res).toBe(30);
|
|
98
|
-
res = service.getValue1(0, -30);
|
|
99
|
-
expect(res).toBe(-30);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
describe('real example (positive only)', () => {
|
|
104
|
-
const stacker = new DataStacker();
|
|
105
|
-
const data = [
|
|
106
|
-
{
|
|
107
|
-
$id: 1,
|
|
108
|
-
brand: "BMW BMW",
|
|
109
|
-
price: 100000,
|
|
110
|
-
count: 12000,
|
|
111
|
-
color: "red"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
$id: 2,
|
|
115
|
-
brand: "LADA",
|
|
116
|
-
price: 0,
|
|
117
|
-
count: 1000,
|
|
118
|
-
color: "green"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
$id: 3,
|
|
122
|
-
brand: "MERCEDES",
|
|
123
|
-
price: 15000,
|
|
124
|
-
count: 1200,
|
|
125
|
-
color: "blue"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
$id: 4,
|
|
129
|
-
brand: "AUDI",
|
|
130
|
-
price: 20000,
|
|
131
|
-
count: 500,
|
|
132
|
-
color: "yellow"
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
$id: 5,
|
|
136
|
-
brand: "VOLKSWAGEN",
|
|
137
|
-
price: 115000,
|
|
138
|
-
count: 6000,
|
|
139
|
-
color: "cyan"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
$id: 6,
|
|
143
|
-
brand: "DODGE",
|
|
144
|
-
price: 115000,
|
|
145
|
-
count: 4000,
|
|
146
|
-
color: "red"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
$id: 7,
|
|
150
|
-
brand: "SAAB",
|
|
151
|
-
price: 50000,
|
|
152
|
-
count: 11000,
|
|
153
|
-
color: "orange"
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
$id: 8,
|
|
157
|
-
brand: "HONDA",
|
|
158
|
-
price: 20000,
|
|
159
|
-
count: 2000,
|
|
160
|
-
color: "brown"
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
$id: 9,
|
|
164
|
-
brand: "TOYOTA",
|
|
165
|
-
price: 40000,
|
|
166
|
-
count: 15000,
|
|
167
|
-
color: "pink"
|
|
168
|
-
}
|
|
169
|
-
];
|
|
170
|
-
const valueFields = ["price", "count"];
|
|
171
|
-
const stackedData = [
|
|
172
|
-
[
|
|
173
|
-
{ "0": 0, "1": 100000, data: data[0] },
|
|
174
|
-
{ "0": 0, "1": 0, data: data[1] },
|
|
175
|
-
{ "0": 0, "1": 15000, data: data[2] },
|
|
176
|
-
{ "0": 0, "1": 20000, data: data[3] },
|
|
177
|
-
{ "0": 0, "1": 115000, data: data[4] },
|
|
178
|
-
{ "0": 0, "1": 115000, data: data[5] },
|
|
179
|
-
{ "0": 0, "1": 50000, data: data[6] },
|
|
180
|
-
{ "0": 0, "1": 20000, data: data[7] },
|
|
181
|
-
{ "0": 0, "1": 40000, data: data[8] }
|
|
182
|
-
],
|
|
183
|
-
[
|
|
184
|
-
{ "0": 100000, "1": 112000, data: data[0] },
|
|
185
|
-
{ "0": 0, "1": 1000, data: data[1] },
|
|
186
|
-
{ "0": 15000, "1": 16200, data: data[2] },
|
|
187
|
-
{ "0": 20000, "1": 20500, data: data[3] },
|
|
188
|
-
{ "0": 115000, "1": 121000, data: data[4] },
|
|
189
|
-
{ "0": 115000, "1": 119000, data: data[5] },
|
|
190
|
-
{ "0": 50000, "1": 61000, data: data[6] },
|
|
191
|
-
{ "0": 20000, "1": 22000, data: data[7] },
|
|
192
|
-
{ "0": 40000, "1": 55000, data: data[8] }
|
|
193
|
-
]
|
|
194
|
-
];
|
|
195
|
-
test('check on real example', () => {
|
|
196
|
-
const res = stacker.getStackedData(data, valueFields);
|
|
197
|
-
expect(res).toEqual(stackedData);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
|
|
2
|
-
import { AxisPosition, NumberDomain, IntervalChart, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions, ChartOrientation, MdtChartsDataSource, MdtChartsDataRow } from "../../config/config";
|
|
3
|
-
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
4
|
-
export declare enum ScaleType {
|
|
5
|
-
Key = 0,
|
|
6
|
-
Value = 1
|
|
7
|
-
}
|
|
8
|
-
export declare class ScaleModel {
|
|
9
|
-
static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts: MdtChartsTwoDimensionalChart[], barCharts: MdtChartsTwoDimensionalChart[]): ScaleKeyModel;
|
|
10
|
-
static getScaleLinear(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, canvasModel: CanvasModel): ScaleValueModel;
|
|
11
|
-
static getRangePeek(scaleType: ScaleType, chartOrientation: string, canvasModel: CanvasModel): number;
|
|
12
|
-
static getDateValueDomain(data: MdtChartsDataSource, chart: IntervalChart, keyAxisPosition: AxisPosition, dataSource: string): [Date, Date];
|
|
13
|
-
static getLinearDomain(configDomain: NumberDomain, data: MdtChartsDataSource, configOptions: MdtChartsTwoDimensionalOptions): [number, number];
|
|
14
|
-
static getScaleKeyType(charts: MdtChartsTwoDimensionalChart[]): ScaleKeyType;
|
|
15
|
-
static getScaleValueType(charts: MdtChartsTwoDimensionalChart[] | IntervalChart[]): ScaleValueType;
|
|
16
|
-
static getElementsAmount(barCharts: MdtChartsTwoDimensionalChart[]): number;
|
|
17
|
-
static getScaleMaxValue(charts: MdtChartsTwoDimensionalChart[], dataRows: MdtChartsDataRow[]): number;
|
|
18
|
-
static getScaleMinValue(charts: MdtChartsTwoDimensionalChart[], dataRows: MdtChartsDataRow[]): number;
|
|
19
|
-
}
|
|
@@ -1,115 +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, canvasModel, charts, barCharts) {
|
|
9
|
-
return {
|
|
10
|
-
domain: allowableKeys,
|
|
11
|
-
range: {
|
|
12
|
-
start: 0,
|
|
13
|
-
end: ScaleModel.getRangePeek(ScaleType.Key, orient, canvasModel)
|
|
14
|
-
},
|
|
15
|
-
type: ScaleModel.getScaleKeyType(charts),
|
|
16
|
-
elementsAmount: this.getElementsAmount(barCharts)
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
static getScaleLinear(options, data, canvasModel) {
|
|
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, canvasModel)
|
|
25
|
-
},
|
|
26
|
-
type: ScaleModel.getScaleValueType(options.charts)
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
static getRangePeek(scaleType, chartOrientation, canvasModel) {
|
|
30
|
-
if (chartOrientation === 'vertical')
|
|
31
|
-
return scaleType === ScaleType.Key
|
|
32
|
-
? canvasModel.getChartBlockWidth()
|
|
33
|
-
: canvasModel.getChartBlockHeight();
|
|
34
|
-
return scaleType === ScaleType.Key
|
|
35
|
-
? canvasModel.getChartBlockHeight()
|
|
36
|
-
: canvasModel.getChartBlockWidth();
|
|
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 = this.getScaleMinValue(configOptions.charts, data[configOptions.data.dataSource]);
|
|
51
|
-
else
|
|
52
|
-
domainPeekMin = configDomain.start;
|
|
53
|
-
if (configDomain.end === -1)
|
|
54
|
-
domainPeekMax = this.getScaleMaxValue(configOptions.charts, data[configOptions.data.dataSource]);
|
|
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, dataRows) {
|
|
84
|
-
let max = 0;
|
|
85
|
-
charts.forEach(chart => {
|
|
86
|
-
dataRows.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
|
-
static getScaleMinValue(charts, dataRows) {
|
|
101
|
-
let min = 0;
|
|
102
|
-
charts.forEach(chart => {
|
|
103
|
-
dataRows.forEach(dataRow => {
|
|
104
|
-
let sumInRow = 0;
|
|
105
|
-
chart.data.valueFields.forEach(field => {
|
|
106
|
-
if (dataRow[field.name] < sumInRow)
|
|
107
|
-
sumInRow = dataRow[field.name];
|
|
108
|
-
});
|
|
109
|
-
if (min > sumInRow)
|
|
110
|
-
min = sumInRow;
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
return min;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
|
|
2
|
-
import { DesignerConfig } from "../designer/designerConfig";
|
|
3
|
-
import { DataScope, LegendBlockModel, Orient, OtherCommonComponents } from "./model";
|
|
4
|
-
import { ModelInstance } from "./modelInstance/modelInstance";
|
|
5
|
-
import { CanvasModel } from "./modelInstance/canvasModel/canvasModel";
|
|
6
|
-
export declare const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
7
|
-
export declare const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
8
|
-
export declare class MarginModel {
|
|
9
|
-
private static twoDimLegendModel;
|
|
10
|
-
static initMargin(designerConfig: DesignerConfig, config: MdtChartsConfig, otherComponents: OtherCommonComponents, data: MdtChartsDataSource, modelInstance: ModelInstance): void;
|
|
11
|
-
static recalcMarginByVerticalAxisLabel(modelInstance: ModelInstance, config: MdtChartsConfig, designerConfig: DesignerConfig, dataScope: DataScope): void;
|
|
12
|
-
static appendToGlobalMarginValuesLegendMargin(canvasModel: CanvasModel, position: Orient, legendBlockModel: LegendBlockModel): void;
|
|
13
|
-
private static getHorizontalMarginByAxisLabels;
|
|
14
|
-
private static recalcVerticalMarginByAxisLabelHeight;
|
|
15
|
-
private static recalcHorizontalMarginByAxisLabelWidth;
|
|
16
|
-
private static recalcMarginByTitle;
|
|
17
|
-
}
|
package/lib/model/marginModel.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { AxisModel } from "./featuresModel/axisModel";
|
|
2
|
-
import { DataManagerModel } from "./dataManagerModel/dataManagerModel";
|
|
3
|
-
import { AxisType } from "./modelBuilder";
|
|
4
|
-
import { TwoDimensionalModel } from "./notations/twoDimensionalModel";
|
|
5
|
-
import { keyAxisLabelHorizontalLog, keyAxisLabelVerticalLog } from "./featuresModel/scaleModel/scaleAxisRecalcer";
|
|
6
|
-
import { TwoDimLegendModel } from "./featuresModel/legendModel/twoDimLegendModel";
|
|
7
|
-
export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
8
|
-
export const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
9
|
-
export class MarginModel {
|
|
10
|
-
static initMargin(designerConfig, config, otherComponents, data, modelInstance) {
|
|
11
|
-
const canvasModel = modelInstance.canvasModel;
|
|
12
|
-
canvasModel.initMargin(Object.assign({}, designerConfig.canvas.chartBlockMargin));
|
|
13
|
-
this.recalcMarginByTitle(canvasModel, otherComponents.titleBlock);
|
|
14
|
-
if (config.options.type === '2d') {
|
|
15
|
-
this.twoDimLegendModel.recalcMarginWith2DLegend(modelInstance, otherComponents.legendBlock);
|
|
16
|
-
const labelSize = this.getHorizontalMarginByAxisLabels(designerConfig.canvas.axisLabel.maxSize.main, config.options.axis, data, config.options);
|
|
17
|
-
this.recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel, config.options.orientation, config.options.axis);
|
|
18
|
-
// Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
|
|
19
|
-
// При этом все графики должны иметь: embeddedLabels = 'key'
|
|
20
|
-
// И все графики должны быть типа bar.
|
|
21
|
-
const showingFlag = config.options.type === '2d'
|
|
22
|
-
? !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(config.options.charts, config.options.orientation)
|
|
23
|
-
: true;
|
|
24
|
-
this.recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, config.options.orientation, config.options.axis, showingFlag);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
static recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, dataScope) {
|
|
28
|
-
if ((config.options.type === '2d' || config.options.type === 'interval') && config.options.orientation === 'vertical') {
|
|
29
|
-
const axisLabelSize = AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataScope.allowableKeys);
|
|
30
|
-
const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length, config.options.axis.key);
|
|
31
|
-
const marginOrient = config.options.axis.key.position === 'end' ? 'bottom' : 'top';
|
|
32
|
-
if (axisConfig === 'rotated') {
|
|
33
|
-
modelInstance.canvasModel.decreaseMarginSide(marginOrient, axisLabelSize.height);
|
|
34
|
-
modelInstance.canvasModel.increaseMarginSide(marginOrient, axisLabelSize.width, keyAxisLabelVerticalLog);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
static appendToGlobalMarginValuesLegendMargin(canvasModel, position, legendBlockModel) {
|
|
39
|
-
const legendCoordinate = legendBlockModel.coordinate;
|
|
40
|
-
if (position === 'left' || position === 'right')
|
|
41
|
-
canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.left + legendCoordinate[position].margin.right);
|
|
42
|
-
else
|
|
43
|
-
canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom);
|
|
44
|
-
}
|
|
45
|
-
static getHorizontalMarginByAxisLabels(labelsMaxWidth, axis, data, options) {
|
|
46
|
-
const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, options.orientation, axis.key.position);
|
|
47
|
-
let labelsTexts;
|
|
48
|
-
if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
|
|
49
|
-
labelsTexts = DataManagerModel.getDataValuesByKeyField(data, options.data.dataSource, options.data.keyField.name);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
labelsTexts = ['0000'];
|
|
53
|
-
}
|
|
54
|
-
return AxisModel.getLabelSize(labelsMaxWidth, labelsTexts);
|
|
55
|
-
}
|
|
56
|
-
static recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel, orientation, axis) {
|
|
57
|
-
const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, orientation, axis.key.position);
|
|
58
|
-
const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
|
|
59
|
-
if ((keyAxisOrient === 'bottom' || keyAxisOrient === 'top')) {
|
|
60
|
-
if (axis.key.visibility)
|
|
61
|
-
canvasModel.increaseMarginSide(keyAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING, keyAxisLabelVerticalLog);
|
|
62
|
-
}
|
|
63
|
-
else if (axis.value.visibility)
|
|
64
|
-
canvasModel.increaseMarginSide(valueAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING);
|
|
65
|
-
}
|
|
66
|
-
static recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, orientation, axis, isShow) {
|
|
67
|
-
const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, orientation, axis.key.position);
|
|
68
|
-
const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
|
|
69
|
-
if ((keyAxisOrient === 'left' || keyAxisOrient === 'right') && isShow && axis.key.visibility) {
|
|
70
|
-
canvasModel.increaseMarginSide(keyAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING, keyAxisLabelHorizontalLog);
|
|
71
|
-
}
|
|
72
|
-
else if ((valueAxisOrient === 'left' || valueAxisOrient === 'right') && axis.value.visibility) {
|
|
73
|
-
canvasModel.increaseMarginSide(valueAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
static recalcMarginByTitle(canvasModel, titleBlockModel) {
|
|
77
|
-
canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size + titleBlockModel.margin.bottom);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
MarginModel.twoDimLegendModel = new TwoDimLegendModel();
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { MdtChartsDataSource, IntervalChart } from "../config/config";
|
|
2
|
-
export declare class ModelHelper {
|
|
3
|
-
static getSum(items: number[]): number;
|
|
4
|
-
static getMinAndMaxOfIntervalData(data: MdtChartsDataSource, dataSource: string, chart: IntervalChart): [Date, Date];
|
|
5
|
-
static getUniqueValues(values: string[]): string[];
|
|
6
|
-
static getStringScore(word: string): number;
|
|
7
|
-
}
|
package/lib/model/modelHelper.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export class ModelHelper {
|
|
2
|
-
static getSum(items) {
|
|
3
|
-
return items.reduce((acc, item) => acc + item, 0);
|
|
4
|
-
}
|
|
5
|
-
static getMinAndMaxOfIntervalData(data, dataSource, chart) {
|
|
6
|
-
let min = data[dataSource][0][chart.data.valueField1.name];
|
|
7
|
-
let max = data[dataSource][0][chart.data.valueField1.name];
|
|
8
|
-
const chartData = data[dataSource];
|
|
9
|
-
const valueField1 = chart.data.valueField1.name;
|
|
10
|
-
const valueField2 = chart.data.valueField2.name;
|
|
11
|
-
chartData.forEach(dataRow => {
|
|
12
|
-
if (dataRow[valueField1] > max)
|
|
13
|
-
max = dataRow[valueField1];
|
|
14
|
-
if (dataRow[valueField1] < min)
|
|
15
|
-
min = dataRow[valueField1];
|
|
16
|
-
if (dataRow[valueField2] > max)
|
|
17
|
-
max = dataRow[valueField2];
|
|
18
|
-
if (dataRow[valueField2] < min)
|
|
19
|
-
min = dataRow[valueField2];
|
|
20
|
-
});
|
|
21
|
-
return [min, max];
|
|
22
|
-
}
|
|
23
|
-
static getUniqueValues(values) {
|
|
24
|
-
const uniqueValues = values.filter((keyValue, index, self) => self.indexOf(keyValue) === index);
|
|
25
|
-
return uniqueValues;
|
|
26
|
-
}
|
|
27
|
-
static getStringScore(word) {
|
|
28
|
-
// lower case letter width ~ 0.74 from upper case width.
|
|
29
|
-
// Number width == lower case letter width
|
|
30
|
-
let score = 0;
|
|
31
|
-
const upperLetterScore = 1;
|
|
32
|
-
const lowerLetterScore = 0.74;
|
|
33
|
-
for (let i = 0; i < word.length; i++) {
|
|
34
|
-
if (word[i].toUpperCase() === word[i] && parseFloat(word[i]).toString() !== word[i])
|
|
35
|
-
score += upperLetterScore;
|
|
36
|
-
else
|
|
37
|
-
score += lowerLetterScore;
|
|
38
|
-
}
|
|
39
|
-
return score;
|
|
40
|
-
}
|
|
41
|
-
}
|