@omegagrid/grid-core 0.10.2 → 0.10.4
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/dist/__generated/functions.d.ts +4 -0
- package/dist/__generated/functions.d.ts.map +1 -0
- package/dist/__generated/functions.js +45 -0
- package/dist/__generated/functions.js.map +1 -0
- package/dist/calculations/autofill.d.ts +7 -0
- package/dist/calculations/autofill.d.ts.map +1 -0
- package/dist/calculations/autofill.js +84 -0
- package/dist/calculations/autofill.js.map +1 -0
- package/dist/calculations/conditions.d.ts +4 -0
- package/dist/calculations/conditions.d.ts.map +1 -0
- package/dist/calculations/conditions.js +41 -0
- package/dist/calculations/conditions.js.map +1 -0
- package/dist/calculations/context.d.ts +53 -0
- package/dist/calculations/context.d.ts.map +1 -0
- package/dist/calculations/context.js +85 -0
- package/dist/calculations/context.js.map +1 -0
- package/dist/calculations/formula.d.ts +89 -0
- package/dist/calculations/formula.d.ts.map +1 -0
- package/dist/calculations/formula.js +443 -0
- package/dist/calculations/formula.js.map +1 -0
- package/dist/calculations/functions/dates.d.ts +13 -0
- package/dist/calculations/functions/dates.d.ts.map +1 -0
- package/dist/calculations/functions/dates.js +58 -0
- package/dist/calculations/functions/dates.js.map +1 -0
- package/dist/calculations/functions/index.d.ts +11 -0
- package/dist/calculations/functions/index.d.ts.map +1 -0
- package/dist/calculations/functions/index.js +21 -0
- package/dist/calculations/functions/index.js.map +1 -0
- package/dist/calculations/functions/logical.d.ts +11 -0
- package/dist/calculations/functions/logical.d.ts.map +1 -0
- package/dist/calculations/functions/logical.js +50 -0
- package/dist/calculations/functions/logical.js.map +1 -0
- package/dist/calculations/functions/lookup.d.ts +18 -0
- package/dist/calculations/functions/lookup.d.ts.map +1 -0
- package/dist/calculations/functions/lookup.js +169 -0
- package/dist/calculations/functions/lookup.js.map +1 -0
- package/dist/calculations/functions/math.d.ts +72 -0
- package/dist/calculations/functions/math.d.ts.map +1 -0
- package/dist/calculations/functions/math.js +182 -0
- package/dist/calculations/functions/math.js.map +1 -0
- package/dist/calculations/functions/special.d.ts +2 -0
- package/dist/calculations/functions/special.d.ts.map +1 -0
- package/dist/calculations/functions/special.js +51 -0
- package/dist/calculations/functions/special.js.map +1 -0
- package/dist/calculations/functions/statistical.d.ts +7 -0
- package/dist/calculations/functions/statistical.d.ts.map +1 -0
- package/dist/calculations/functions/statistical.js +47 -0
- package/dist/calculations/functions/statistical.js.map +1 -0
- package/dist/calculations/functions/text.d.ts +29 -0
- package/dist/calculations/functions/text.d.ts.map +1 -0
- package/dist/calculations/functions/text.js +58 -0
- package/dist/calculations/functions/text.js.map +1 -0
- package/dist/calculations/helpers.d.ts +13 -0
- package/dist/calculations/helpers.d.ts.map +1 -0
- package/dist/calculations/helpers.js +32 -0
- package/dist/calculations/helpers.js.map +1 -0
- package/dist/calculations/index.d.ts +7 -0
- package/dist/calculations/index.d.ts.map +1 -0
- package/dist/calculations/index.js +7 -0
- package/dist/calculations/index.js.map +1 -0
- package/dist/calculations/operators.d.ts +19 -0
- package/dist/calculations/operators.d.ts.map +1 -0
- package/dist/calculations/operators.js +58 -0
- package/dist/calculations/operators.js.map +1 -0
- package/dist/calculations/tokenization.d.ts +36 -0
- package/dist/calculations/tokenization.d.ts.map +1 -0
- package/dist/calculations/tokenization.js +203 -0
- package/dist/calculations/tokenization.js.map +1 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +2 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/range.d.ts +66 -0
- package/dist/common/range.d.ts.map +1 -0
- package/dist/common/range.js +222 -0
- package/dist/common/range.js.map +1 -0
- package/dist/constants.d.ts +68 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +127 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/model/calculationModel.d.ts +30 -0
- package/dist/model/calculationModel.d.ts.map +1 -0
- package/dist/model/calculationModel.js +206 -0
- package/dist/model/calculationModel.js.map +1 -0
- package/dist/model/cellModel.d.ts +134 -0
- package/dist/model/cellModel.d.ts.map +1 -0
- package/dist/model/cellModel.js +371 -0
- package/dist/model/cellModel.js.map +1 -0
- package/dist/model/columnModel.d.ts +160 -0
- package/dist/model/columnModel.d.ts.map +1 -0
- package/dist/model/columnModel.js +159 -0
- package/dist/model/columnModel.js.map +1 -0
- package/dist/model/commentModel.d.ts +58 -0
- package/dist/model/commentModel.d.ts.map +1 -0
- package/dist/model/commentModel.js +81 -0
- package/dist/model/commentModel.js.map +1 -0
- package/dist/model/conditionalFormats.d.ts +104 -0
- package/dist/model/conditionalFormats.d.ts.map +1 -0
- package/dist/model/conditionalFormats.js +414 -0
- package/dist/model/conditionalFormats.js.map +1 -0
- package/dist/model/cssStyle.d.ts +20 -0
- package/dist/model/cssStyle.d.ts.map +1 -0
- package/dist/model/cssStyle.js +301 -0
- package/dist/model/cssStyle.js.map +1 -0
- package/dist/model/dependencies.d.ts +30 -0
- package/dist/model/dependencies.d.ts.map +1 -0
- package/dist/model/dependencies.js +139 -0
- package/dist/model/dependencies.js.map +1 -0
- package/dist/model/dependencyModel.d.ts +9 -0
- package/dist/model/dependencyModel.d.ts.map +1 -0
- package/dist/model/dependencyModel.js +9 -0
- package/dist/model/dependencyModel.js.map +1 -0
- package/dist/model/elementModel.d.ts +103 -0
- package/dist/model/elementModel.d.ts.map +1 -0
- package/dist/model/elementModel.js +181 -0
- package/dist/model/elementModel.js.map +1 -0
- package/dist/model/filterModel.d.ts +35 -0
- package/dist/model/filterModel.d.ts.map +1 -0
- package/dist/model/filterModel.js +153 -0
- package/dist/model/filterModel.js.map +1 -0
- package/dist/model/gridModel.d.ts +181 -0
- package/dist/model/gridModel.d.ts.map +1 -0
- package/dist/model/gridModel.js +797 -0
- package/dist/model/gridModel.js.map +1 -0
- package/dist/model/groupModel.d.ts +26 -0
- package/dist/model/groupModel.d.ts.map +1 -0
- package/dist/model/groupModel.js +112 -0
- package/dist/model/groupModel.js.map +1 -0
- package/dist/model/history.d.ts +24 -0
- package/dist/model/history.d.ts.map +1 -0
- package/dist/model/history.js +35 -0
- package/dist/model/history.js.map +1 -0
- package/dist/model/index.d.ts +23 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +23 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/iterableRange.d.ts +49 -0
- package/dist/model/iterableRange.d.ts.map +1 -0
- package/dist/model/iterableRange.js +108 -0
- package/dist/model/iterableRange.js.map +1 -0
- package/dist/model/merges.d.ts +34 -0
- package/dist/model/merges.d.ts.map +1 -0
- package/dist/model/merges.js +123 -0
- package/dist/model/merges.js.map +1 -0
- package/dist/model/namingModel.d.ts +25 -0
- package/dist/model/namingModel.d.ts.map +1 -0
- package/dist/model/namingModel.js +77 -0
- package/dist/model/namingModel.js.map +1 -0
- package/dist/model/options.d.ts +257 -0
- package/dist/model/options.d.ts.map +1 -0
- package/dist/model/options.js +35 -0
- package/dist/model/options.js.map +1 -0
- package/dist/model/rowModel.d.ts +104 -0
- package/dist/model/rowModel.d.ts.map +1 -0
- package/dist/model/rowModel.js +155 -0
- package/dist/model/rowModel.js.map +1 -0
- package/dist/model/selectionModel.d.ts +19 -0
- package/dist/model/selectionModel.d.ts.map +1 -0
- package/dist/model/selectionModel.js +40 -0
- package/dist/model/selectionModel.js.map +1 -0
- package/dist/model/sortingModel.d.ts +46 -0
- package/dist/model/sortingModel.d.ts.map +1 -0
- package/dist/model/sortingModel.js +157 -0
- package/dist/model/sortingModel.js.map +1 -0
- package/dist/model/style.d.ts +90 -0
- package/dist/model/style.d.ts.map +1 -0
- package/dist/model/style.js +34 -0
- package/dist/model/style.js.map +1 -0
- package/dist/model/styleModel.d.ts +22 -0
- package/dist/model/styleModel.d.ts.map +1 -0
- package/dist/model/styleModel.js +91 -0
- package/dist/model/styleModel.js.map +1 -0
- package/dist/model/tableTheme.d.ts +46 -0
- package/dist/model/tableTheme.d.ts.map +1 -0
- package/dist/model/tableTheme.js +93 -0
- package/dist/model/tableTheme.js.map +1 -0
- package/dist/model/validations.d.ts +5 -0
- package/dist/model/validations.d.ts.map +1 -0
- package/dist/model/validations.js +24 -0
- package/dist/model/validations.js.map +1 -0
- package/dist/sparklines/index.d.ts +2 -0
- package/dist/sparklines/index.d.ts.map +1 -0
- package/dist/sparklines/index.js +2 -0
- package/dist/sparklines/index.js.map +1 -0
- package/dist/sparklines/sparklines.d.ts +59 -0
- package/dist/sparklines/sparklines.d.ts.map +1 -0
- package/dist/sparklines/sparklines.js +176 -0
- package/dist/sparklines/sparklines.js.map +1 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +11 -0
- package/dist/utils.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { Formula } from "../calculations";
|
|
2
|
+
import { CellRange } from "../common";
|
|
3
|
+
import { IterableAddressRange } from "../model";
|
|
4
|
+
import { colors, log } from "@omegagrid/core";
|
|
5
|
+
import { DependencyModel } from "./dependencyModel";
|
|
6
|
+
const ICON_CLR_RED = '#ff0000';
|
|
7
|
+
const ICON_CLR_YELLOW = '#fcd53f';
|
|
8
|
+
const ICON_CLR_GREEN = '#00bb5e';
|
|
9
|
+
const ICON_CLR_GRAY = '#555555';
|
|
10
|
+
export const iconSets = new Map([
|
|
11
|
+
['3Arrows', [
|
|
12
|
+
{ icon: ['fas', 'down'], color: ICON_CLR_RED },
|
|
13
|
+
{ icon: ['fas', 'right'], color: ICON_CLR_YELLOW },
|
|
14
|
+
{ icon: ['fas', 'up'], color: ICON_CLR_GREEN }
|
|
15
|
+
]],
|
|
16
|
+
['3ArrowsGray', [
|
|
17
|
+
{ icon: ['fas', 'down'], color: ICON_CLR_GRAY },
|
|
18
|
+
{ icon: ['fas', 'right'], color: ICON_CLR_GRAY },
|
|
19
|
+
{ icon: ['fas', 'up'], color: ICON_CLR_GRAY }
|
|
20
|
+
]],
|
|
21
|
+
['3Flags', [
|
|
22
|
+
{ icon: ['fas', 'flag-pennant'], color: ICON_CLR_RED },
|
|
23
|
+
{ icon: ['fas', 'flag-pennant'], color: ICON_CLR_YELLOW },
|
|
24
|
+
{ icon: ['fas', 'flag-pennant'], color: ICON_CLR_GREEN }
|
|
25
|
+
]],
|
|
26
|
+
['3TrafficLights1', [
|
|
27
|
+
{ icon: ['fas', 'circle'], color: ICON_CLR_RED },
|
|
28
|
+
{ icon: ['fas', 'circle'], color: ICON_CLR_YELLOW },
|
|
29
|
+
{ icon: ['fas', 'circle'], color: ICON_CLR_GREEN }
|
|
30
|
+
]],
|
|
31
|
+
['3TrafficLights2', [
|
|
32
|
+
{ icon: ['fas', 'square-o'], color: ICON_CLR_RED },
|
|
33
|
+
{ icon: ['fas', 'square-o'], color: ICON_CLR_YELLOW },
|
|
34
|
+
{ icon: ['fas', 'square-o'], color: ICON_CLR_GREEN }
|
|
35
|
+
]],
|
|
36
|
+
['3Signs', [
|
|
37
|
+
{ icon: ['fas', 'square'], rotation: 45, color: ICON_CLR_RED },
|
|
38
|
+
{ icon: ['fas', 'triangle'], color: ICON_CLR_YELLOW },
|
|
39
|
+
{ icon: ['fas', 'circle'], color: ICON_CLR_GREEN }
|
|
40
|
+
]],
|
|
41
|
+
['3Symbols', [
|
|
42
|
+
{ icon: ['fas', 'circle-xmark'], color: ICON_CLR_RED },
|
|
43
|
+
{ icon: ['fas', 'circle-exclamation'], color: ICON_CLR_YELLOW },
|
|
44
|
+
{ icon: ['fas', 'circle-check'], color: ICON_CLR_GREEN }
|
|
45
|
+
]],
|
|
46
|
+
['3Symbols2', [
|
|
47
|
+
{ icon: ['fas', 'xmark'], color: ICON_CLR_RED },
|
|
48
|
+
{ icon: ['fas', 'exclamation'], color: ICON_CLR_YELLOW },
|
|
49
|
+
{ icon: ['fas', 'check'], color: ICON_CLR_GREEN }
|
|
50
|
+
]],
|
|
51
|
+
['3Stars', [
|
|
52
|
+
{ icon: ['fal', 'star'], color: ICON_CLR_YELLOW },
|
|
53
|
+
{ icon: ['fas', 'star-half-stroke'], color: ICON_CLR_YELLOW },
|
|
54
|
+
{ icon: ['fas', 'star'], color: ICON_CLR_YELLOW }
|
|
55
|
+
]],
|
|
56
|
+
['3Triangles', [
|
|
57
|
+
{ icon: 'caret-down', color: ICON_CLR_RED },
|
|
58
|
+
{ icon: 'dash', color: ICON_CLR_YELLOW },
|
|
59
|
+
{ icon: 'caret-up', color: ICON_CLR_GREEN }
|
|
60
|
+
]],
|
|
61
|
+
['4Arrows', [
|
|
62
|
+
{ icon: ['fas', 'down'], color: ICON_CLR_RED },
|
|
63
|
+
{ icon: ['fas', 'down-right'], color: ICON_CLR_YELLOW },
|
|
64
|
+
{ icon: ['fas', 'up-right'], color: ICON_CLR_YELLOW },
|
|
65
|
+
{ icon: ['fas', 'up'], color: ICON_CLR_GREEN }
|
|
66
|
+
]],
|
|
67
|
+
['4ArrowsGray', [
|
|
68
|
+
{ icon: ['fas', 'down'], color: ICON_CLR_GRAY },
|
|
69
|
+
{ icon: ['fas', 'down-right'], color: ICON_CLR_GRAY },
|
|
70
|
+
{ icon: ['fas', 'up-right'], color: ICON_CLR_GRAY },
|
|
71
|
+
{ icon: ['fas', 'up'], color: ICON_CLR_GRAY }
|
|
72
|
+
]],
|
|
73
|
+
['4RedToBlack', [
|
|
74
|
+
{ icon: ['fas', 'circle'], color: '#000000' },
|
|
75
|
+
{ icon: ['fas', 'circle'], color: '#b1b1b1' },
|
|
76
|
+
{ icon: ['fas', 'circle'], color: '#edb2a3' },
|
|
77
|
+
{ icon: ['fas', 'circle'], color: ICON_CLR_RED }
|
|
78
|
+
]],
|
|
79
|
+
['4Rating', [
|
|
80
|
+
{ icon: 'signal-bars-weak', color: '#4a7db1' },
|
|
81
|
+
{ icon: 'signal-bars-fair', color: '#4a7db1' },
|
|
82
|
+
{ icon: 'signal-bars-good', color: '#4a7db1' },
|
|
83
|
+
{ icon: ['fas', 'signal-bars'], color: '#4a7db1' }
|
|
84
|
+
]],
|
|
85
|
+
['4TrafficLights', [
|
|
86
|
+
{ icon: ['fas', 'circle'], color: '#000000' },
|
|
87
|
+
{ icon: ['fas', 'circle'], color: ICON_CLR_RED },
|
|
88
|
+
{ icon: ['fas', 'circle'], color: ICON_CLR_YELLOW },
|
|
89
|
+
{ icon: ['fas', 'circle'], color: ICON_CLR_GREEN }
|
|
90
|
+
]],
|
|
91
|
+
['5Arrows', [
|
|
92
|
+
{ icon: ['fas', 'down'], color: ICON_CLR_RED },
|
|
93
|
+
{ icon: ['fas', 'down-right'], color: ICON_CLR_YELLOW },
|
|
94
|
+
{ icon: ['fas', 'right'], color: ICON_CLR_YELLOW },
|
|
95
|
+
{ icon: ['fas', 'up-right'], color: ICON_CLR_YELLOW },
|
|
96
|
+
{ icon: ['fas', 'up'], color: ICON_CLR_GREEN },
|
|
97
|
+
]],
|
|
98
|
+
['5ArrowsGray', [
|
|
99
|
+
{ icon: ['fas', 'down'], color: ICON_CLR_GRAY },
|
|
100
|
+
{ icon: ['fas', 'down-right'], color: ICON_CLR_GRAY },
|
|
101
|
+
{ icon: ['fas', 'right'], color: ICON_CLR_GRAY },
|
|
102
|
+
{ icon: ['fas', 'up-right'], color: ICON_CLR_GRAY },
|
|
103
|
+
{ icon: ['fas', 'up'], color: ICON_CLR_GRAY },
|
|
104
|
+
]],
|
|
105
|
+
['5Rating', [
|
|
106
|
+
{ icon: ['fal', 'signal-bars'] },
|
|
107
|
+
{ icon: ['fal', 'signal-bars-weak'], color: '#4a7db1' },
|
|
108
|
+
{ icon: ['fal', 'signal-bars-fair'], color: '#4a7db1' },
|
|
109
|
+
{ icon: ['fal', 'signal-bars-good'], color: '#4a7db1' },
|
|
110
|
+
{ icon: ['fas', 'signal-bars'], color: '#4a7db1' },
|
|
111
|
+
]],
|
|
112
|
+
['5Quarters', [
|
|
113
|
+
{ icon: ['fal', 'circle'], color: '#505050' },
|
|
114
|
+
{ icon: ['fas', 'circle-quarter-stroke'], color: '#505050' },
|
|
115
|
+
{ icon: ['fas', 'circle-half-stroke'], color: '#505050' },
|
|
116
|
+
{ icon: ['fas', 'circle-three-quarters-stroke'], color: '#505050' },
|
|
117
|
+
{ icon: ['fas', 'circle'], color: '#505050' }
|
|
118
|
+
]]
|
|
119
|
+
]);
|
|
120
|
+
const getIcon = (iconset, index) => {
|
|
121
|
+
const i = iconSets.get(iconset);
|
|
122
|
+
return i ? i[index] : null;
|
|
123
|
+
};
|
|
124
|
+
export class ConditionalFormats extends DependencyModel {
|
|
125
|
+
constructor(model, sourceData) {
|
|
126
|
+
super(model, 'conditionalFormats');
|
|
127
|
+
this.formats = [];
|
|
128
|
+
this.cellFormatMap = new Map();
|
|
129
|
+
this.extremes = new Map();
|
|
130
|
+
if (sourceData)
|
|
131
|
+
this.populate(sourceData);
|
|
132
|
+
}
|
|
133
|
+
populate(sourceData) {
|
|
134
|
+
sourceData.forEach(item => {
|
|
135
|
+
try {
|
|
136
|
+
this.add(item);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
log.getLogger().error(`conditional format error: ${JSON.stringify(item)}`, error);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
refresh() {
|
|
144
|
+
this.dependencies.clear();
|
|
145
|
+
this.cellFormatMap.clear();
|
|
146
|
+
this.extremes.clear();
|
|
147
|
+
this.formats.forEach(item => this.initConditionalFormat(item));
|
|
148
|
+
}
|
|
149
|
+
clearCellDependecies(cell) {
|
|
150
|
+
const addr = cell.address;
|
|
151
|
+
this.dependencies.clearCellDependecies(addr);
|
|
152
|
+
// clear cached formulas
|
|
153
|
+
const item = this.cellFormatMap.get(addr);
|
|
154
|
+
item.forEach(i => ({ cf: i.cf }));
|
|
155
|
+
// TODO - update extremes
|
|
156
|
+
// maybe it should return all affected cells
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
getExtremes(cf) {
|
|
160
|
+
if (this.extremes.has(cf.key))
|
|
161
|
+
return this.extremes.get(cf.key);
|
|
162
|
+
const extremes = [Infinity, -Infinity];
|
|
163
|
+
cf.ranges.forEach(r => {
|
|
164
|
+
for (const row of this.model.getValuesInRange(r)) {
|
|
165
|
+
for (const v of row) {
|
|
166
|
+
if (v == null)
|
|
167
|
+
continue;
|
|
168
|
+
if (isNaN(v))
|
|
169
|
+
continue;
|
|
170
|
+
extremes[0] = Math.min(extremes[0], v);
|
|
171
|
+
extremes[1] = Math.max(extremes[1], v);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
if (cf.cmin) {
|
|
176
|
+
if (cf.cmin.t == 'num')
|
|
177
|
+
extremes[0] = cf.cmin.v;
|
|
178
|
+
else if (cf.cmin.t == 'percent') {
|
|
179
|
+
extremes[0] = extremes[0] + (extremes[1] - extremes[0]) * cf.cmin.v / 100;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (cf.cmax) {
|
|
183
|
+
if (cf.cmax.t == 'num')
|
|
184
|
+
extremes[1] = cf.cmax.v;
|
|
185
|
+
else if (cf.cmax.t == 'percent') {
|
|
186
|
+
extremes[1] = extremes[0] + (extremes[1] - extremes[0]) * cf.cmax.v / 100;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
this.extremes.set(cf.key, extremes);
|
|
190
|
+
return extremes;
|
|
191
|
+
}
|
|
192
|
+
invalidateExtremes(cell) {
|
|
193
|
+
this.cellFormatMap.get(cell.address).forEach(item => this.extremes.delete(item.cf.key));
|
|
194
|
+
}
|
|
195
|
+
evaluateScaleFormat(cell, ccf) {
|
|
196
|
+
const v = cell.value;
|
|
197
|
+
if (v == null)
|
|
198
|
+
return null;
|
|
199
|
+
const [min, max] = this.getExtremes(ccf.cf);
|
|
200
|
+
let fgColor;
|
|
201
|
+
const amount = (v - min) / (max - min);
|
|
202
|
+
if (ccf.cf.cmid?.color) {
|
|
203
|
+
// 3 color scale
|
|
204
|
+
if (amount == 0.5) {
|
|
205
|
+
fgColor = '#' + ccf.cf.cmid.color;
|
|
206
|
+
}
|
|
207
|
+
else if (amount > 0.5) {
|
|
208
|
+
fgColor = colors.mix('#' + ccf.cf.cmid.color, '#' + ccf.cf.cmax.color, (amount - 0.5) * 2);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
fgColor = colors.mix('#' + ccf.cf.cmin.color, '#' + ccf.cf.cmid.color, amount * 2);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (ccf.cf.cmin?.color && ccf.cf.cmax?.color) {
|
|
215
|
+
// 2 color scale
|
|
216
|
+
fgColor = colors.mix('#' + ccf.cf.cmin.color, '#' + ccf.cf.cmax.color, amount);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
color: colors.contrastColor(fgColor).substring(1),
|
|
223
|
+
fgColor: fgColor.substring(1)
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
evaluateBarFormat(cell, ccf) {
|
|
227
|
+
const v = cell.value;
|
|
228
|
+
if (v == null)
|
|
229
|
+
return null;
|
|
230
|
+
const ext = this.getExtremes(ccf.cf);
|
|
231
|
+
let min = ext[0];
|
|
232
|
+
const max = ext[1];
|
|
233
|
+
const hasNegative = min < 0;
|
|
234
|
+
if (!hasNegative)
|
|
235
|
+
min = min - 0.1 * (max - min);
|
|
236
|
+
const amount = Math.round((100 * (v - min) / (max - min)));
|
|
237
|
+
if (!ccf.initialized) {
|
|
238
|
+
ccf.initialized = true;
|
|
239
|
+
ccf.cf.ranges.forEach(r => this._dependencies.add(cell.address, r.A1, null));
|
|
240
|
+
}
|
|
241
|
+
const gradient = [];
|
|
242
|
+
if (hasNegative) {
|
|
243
|
+
const offset = Math.round(-100 * min / (max - min));
|
|
244
|
+
if (v >= 0) {
|
|
245
|
+
gradient.push(`#00000000 ${offset}%`);
|
|
246
|
+
gradient.push(`#${ccf.cf.color} ${offset}%`);
|
|
247
|
+
gradient.push(`#${ccf.cf.color} ${amount}%`);
|
|
248
|
+
gradient.push(`#00000000 ${amount}%`);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
gradient.push(`#00000000 ${amount}%`);
|
|
252
|
+
gradient.push(`#ff0000 ${amount}%`);
|
|
253
|
+
gradient.push(`#ff0000 ${offset}%`);
|
|
254
|
+
gradient.push(`#00000000 ${offset}%`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
gradient.push(`#${ccf.cf.color} ${amount}%`);
|
|
259
|
+
gradient.push(`#00000000 ${amount}%`);
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
cssStyle: {
|
|
263
|
+
backgroundClip: 'padding-box',
|
|
264
|
+
backgroundImage: `linear-gradient(90deg, ${gradient.join(',')})`
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
evaluateFormulaFormat(cell, ccf) {
|
|
269
|
+
if (!ccf.initialized && ccf.cf.condition) {
|
|
270
|
+
ccf.initialized = true;
|
|
271
|
+
const addr = cell.address;
|
|
272
|
+
const f = new Formula(ccf.cf.condition, this.model.calculations.tokenizer);
|
|
273
|
+
ccf.f = f.shift({
|
|
274
|
+
index: 0,
|
|
275
|
+
offset: cell.c - ccf.cf.firstCell.c1,
|
|
276
|
+
direction: 'right'
|
|
277
|
+
}).shift({
|
|
278
|
+
index: 0,
|
|
279
|
+
offset: cell.r - ccf.cf.firstCell.r1,
|
|
280
|
+
direction: 'down'
|
|
281
|
+
});
|
|
282
|
+
f.cells.forEach(dep => this._dependencies.add(addr, dep[1].A1, dep[2]));
|
|
283
|
+
f.ranges.forEach(dep => this._dependencies.add(addr, dep[1].A1, dep[2]));
|
|
284
|
+
f.variables.forEach(([_i, v]) => {
|
|
285
|
+
const c = this.model.getCellByName(v, cell.range);
|
|
286
|
+
if (c)
|
|
287
|
+
this._dependencies.add(addr, c.address, null);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
// if condition is not provided, it evaluates to true
|
|
291
|
+
const res = ccf.f ? this.model.calculations.evaluateFormula(ccf.f, cell) : true;
|
|
292
|
+
if (!res)
|
|
293
|
+
return null;
|
|
294
|
+
const style = { ...ccf.cf.style };
|
|
295
|
+
if (!style.color)
|
|
296
|
+
colors.plainHex(colors.contrastColor(colors.css(ccf.cf.style.fgColor)));
|
|
297
|
+
return style;
|
|
298
|
+
}
|
|
299
|
+
evaluateIconFormat(cell, ccf) {
|
|
300
|
+
const v = cell.value;
|
|
301
|
+
if (v == null)
|
|
302
|
+
return null;
|
|
303
|
+
const [min, max] = this.getExtremes(ccf.cf);
|
|
304
|
+
let percentValue;
|
|
305
|
+
for (let i = ccf.cf.thresh.length - 1; i >= 0; i--) {
|
|
306
|
+
const thresh = ccf.cf.thresh[i];
|
|
307
|
+
if (thresh.t === 'percent') {
|
|
308
|
+
if (percentValue == null)
|
|
309
|
+
percentValue = 100 * (v - min) / (max - min);
|
|
310
|
+
if (percentValue >= thresh.v) {
|
|
311
|
+
return { icon: getIcon(ccf.cf.v, i) };
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
else if (thresh.t === 'num') {
|
|
315
|
+
if (v >= thresh.v) {
|
|
316
|
+
return { icon: getIcon(ccf.cf.v, i) };
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
evaluate(cell) {
|
|
323
|
+
const addr = cell.address;
|
|
324
|
+
const formats = this.cellFormatMap.get(addr);
|
|
325
|
+
if (!formats)
|
|
326
|
+
return null;
|
|
327
|
+
let style = null;
|
|
328
|
+
let diffStyle = null;
|
|
329
|
+
for (const item of formats) {
|
|
330
|
+
try {
|
|
331
|
+
switch (item.cf.type) {
|
|
332
|
+
case 'formula':
|
|
333
|
+
diffStyle = this.evaluateFormulaFormat(cell, item);
|
|
334
|
+
break;
|
|
335
|
+
case 'scale':
|
|
336
|
+
diffStyle = this.evaluateScaleFormat(cell, item);
|
|
337
|
+
break;
|
|
338
|
+
case 'bar':
|
|
339
|
+
diffStyle = this.evaluateBarFormat(cell, item);
|
|
340
|
+
break;
|
|
341
|
+
case 'icon':
|
|
342
|
+
diffStyle = this.evaluateIconFormat(cell, item);
|
|
343
|
+
break;
|
|
344
|
+
default:
|
|
345
|
+
diffStyle = null;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
log.getLogger().error(`Conditional format error: ${JSON.stringify(item)}`, error);
|
|
351
|
+
}
|
|
352
|
+
if (diffStyle) {
|
|
353
|
+
style = style ? { ...style, ...diffStyle } : diffStyle;
|
|
354
|
+
if (item.cf.stop)
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return style;
|
|
359
|
+
}
|
|
360
|
+
initConditionalFormat(item) {
|
|
361
|
+
item.firstCell = null;
|
|
362
|
+
item.ranges.forEach(range => {
|
|
363
|
+
for (const r of new IterableAddressRange(range.intersect(this.model.gridRange))) {
|
|
364
|
+
const a1 = r.A1;
|
|
365
|
+
switch (item.type) {
|
|
366
|
+
case 'formula':
|
|
367
|
+
if (!item.firstCell) {
|
|
368
|
+
item.firstCell = r;
|
|
369
|
+
item.formula = item.condition ? new Formula(item.condition, this.model.calculations.tokenizer) : null;
|
|
370
|
+
}
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
const ccfs = this.cellFormatMap.get(a1) || this.cellFormatMap.set(a1, []).get(a1);
|
|
374
|
+
ccfs.push({ cf: item });
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
return item;
|
|
378
|
+
}
|
|
379
|
+
add(itemSource) {
|
|
380
|
+
const item = {
|
|
381
|
+
key: itemSource.ranges,
|
|
382
|
+
ranges: CellRange.fromA1s(itemSource.ranges),
|
|
383
|
+
type: itemSource.type || 'formula',
|
|
384
|
+
firstCell: null,
|
|
385
|
+
formula: null,
|
|
386
|
+
style: itemSource.style ? this.model.styles.add(itemSource.style) : null,
|
|
387
|
+
condition: itemSource.condition,
|
|
388
|
+
stop: !!itemSource.stop,
|
|
389
|
+
cmin: itemSource.cmin,
|
|
390
|
+
cmid: itemSource.cmid,
|
|
391
|
+
cmax: itemSource.cmax,
|
|
392
|
+
color: itemSource.color,
|
|
393
|
+
v: itemSource.v,
|
|
394
|
+
thresh: itemSource.thresh
|
|
395
|
+
};
|
|
396
|
+
this.formats.push(this.initConditionalFormat(item));
|
|
397
|
+
}
|
|
398
|
+
getSourceData() {
|
|
399
|
+
return this.formats.map(format => ({
|
|
400
|
+
type: format.type,
|
|
401
|
+
ranges: CellRange.toA1s(format.ranges),
|
|
402
|
+
style: format.style,
|
|
403
|
+
condition: format.condition,
|
|
404
|
+
stop: format.stop,
|
|
405
|
+
cmin: format.cmin,
|
|
406
|
+
cmid: format.cmid,
|
|
407
|
+
cmax: format.cmax,
|
|
408
|
+
color: format.color,
|
|
409
|
+
v: format.v,
|
|
410
|
+
thresh: format.thresh
|
|
411
|
+
}));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
//# sourceMappingURL=conditionalFormats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionalFormats.js","sourceRoot":"","sources":["../../src/model/conditionalFormats.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAiB,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAe,SAAS,EAAgB,MAAM,WAAW,CAAA;AAChE,OAAO,EAAwB,oBAAoB,EAAgB,MAAM,UAAU,CAAA;AACnF,OAAO,EAAY,MAAM,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AA0FpD,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,M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ACL,CAAC;CAGD","sourcesContent":["import { StyleSource } from \"../types\";\nimport { Formula, FormulaString } from \"../calculations\"\nimport { CellAddress, CellRange, RangeAddress } from \"../common\"\nimport { CellModel, GridModel, IterableAddressRange, Style, Color } from \"../model\"\nimport { IconSpec, colors, log } from \"@omegagrid/core\";\nimport { DependencyModel } from \"./dependencyModel\";\n\nexport type ConditionalFormatTypeDiffStyle =\n 'avg' | /* Format only values that are above or below average */\n 'blank' | /* Format only cells that contain: Blanks or no Blanks */\n 'date' | /* Format only cells that contain: Dates Occurring */\n 'dup' | /* Format all duplicate values */\n 'error' | /* Format only cells that contain: Errors or No Errors */\n 'formula' | /* Format values where formula is true */\n 'rank' | /* Format only top or bottom ranked values */\n 'text' | /* Format only cells that contain: Specific Text */\n 'unique' | /* Format all unique values */\n 'val' ; /* Format only cells that contain: Cell Value */\n\nexport type ConditionalFormatTypeNoDiff =\n 'bar' | /* Format all cells based on values: Data Bars */\n 'icon' | /* Format all cells based on values: Icon Sets */\n 'scale' ; /* Format all cells based on values: 2- or 3- color scale */\n\nexport type ConditionalFormatIconType =\n\t'3Arrows'\t\t\t| /* 3 Arrows (Colored) */\n\t'3ArrowsGray'\t\t| /* 3 Arrows (Gray) */\n\t'3Flags'\t\t\t| /* 3 Flags */\n\t'3TrafficLights1'\t| /* 3 Traffic Lights (unrimmed) */\n\t'3TrafficLights2'\t| /* 3 Traffic Lights (rimmed) */\n\t'3Signs'\t\t\t| /* 3 Signs */\n\t'3Symbols'\t\t\t| /* 3 Symbols (Circled) */\n\t'3Symbols2'\t\t\t| /* 3 Symbols (Uncircled) */\n\t'3Stars'\t\t\t| /* 3 Stars */\n\t'3Triangles'\t\t| /* 3 Triangles */\n\t'4Arrows'\t\t\t| /* 4 Arrows (Colored) */\n\t'4ArrowsGray'\t\t| /* 4 Arrows (Gray) */\n\t'4RedToBlack'\t\t| /* Red To Black */\n\t'4Rating'\t\t\t| /* 4 Ratings */\n\t'4TrafficLights'\t| /* 4 Traffic Lights */\n\t'5Arrows'\t\t\t| /* 5 Arrows (Colored) */\n\t'5ArrowsGray'\t\t| /* 5 Arrows (Gray) */\n\t'5Rating'\t\t\t| /* 5 Ratings */\n\t'5Quarters'\t\t\t| /* 5 Quarters */\n\t'5Boxes' \t\t\t; /* 5 Boxes */\n\nexport type ConditionalFormatIconSetDefinition = {\n\ttype: string,\n\tcount: number,\n\ticons: IconSpec[]\n}\n\nexport type ConditionalFormatType = ConditionalFormatTypeDiffStyle | ConditionalFormatTypeNoDiff;\nexport type ConditionalFormatThresholdType = 'num'|'percent'|'percentile'|'formula'|'min'|'max';\nexport type ConditionalFormatThreshold = {t?: ConditionalFormatThresholdType, v?: number, f?: FormulaString, color?: Color};\n\nexport type ConditionalFormatItemSource = {\n\ttype?: ConditionalFormatType,\n\tranges: RangeAddress,\n\tstyle?: StyleSource,\n\tcondition?: FormulaString,\n\tstop?: boolean,\n\tcmin?: ConditionalFormatThreshold,\n\tcmid?: ConditionalFormatThreshold,\n\tcmax?: ConditionalFormatThreshold,\n\tcolor?: Color,\n\tv?: ConditionalFormatIconType|unknown,\n\tthresh?: ConditionalFormatThreshold[]\n};\n\nexport type ConditionalFormatSource = ConditionalFormatItemSource[];\n\nexport type ConditionalFormat = {\n\ttype: ConditionalFormatType,\n\tkey?: string,\n\tranges?: CellRange[],\n\tfirstCell?: CellRange,\n\tstyle?: Style,\n\tcondition?: FormulaString,\n\tformula?: Formula,\n\tstop?: boolean,\n\tcmin?: ConditionalFormatThreshold,\n\tcmid?: ConditionalFormatThreshold,\n\tcmax?: ConditionalFormatThreshold,\n\tcolor?: Color,\n\tv?: ConditionalFormatIconType|unknown,\n\tthresh?: ConditionalFormatThreshold[]\n}\n\nexport type CellConditionalFormat = {\n\tcf: ConditionalFormat, \n\tf?: Formula,\n\tinitialized?: boolean\n}\n\nconst ICON_CLR_RED = '#ff0000';\nconst ICON_CLR_YELLOW = '#fcd53f';\nconst ICON_CLR_GREEN = '#00bb5e';\nconst ICON_CLR_GRAY = '#555555';\n\nexport const iconSets = new Map<ConditionalFormatIconType, IconSpec[]>([\n\t['3Arrows', [\n\t\t{icon: ['fas', 'down'], color: ICON_CLR_RED}, \n\t\t{icon: ['fas', 'right'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'up'], color: ICON_CLR_GREEN}\n\t]],\n\t['3ArrowsGray', [\n\t\t{icon: ['fas', 'down'], color: ICON_CLR_GRAY}, \n\t\t{icon: ['fas', 'right'], color: ICON_CLR_GRAY}, \n\t\t{icon: ['fas', 'up'], color: ICON_CLR_GRAY}\n\t]],\n\t['3Flags', [\n\t\t{icon: ['fas', 'flag-pennant'], color: ICON_CLR_RED}, \n\t\t{icon: ['fas', 'flag-pennant'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'flag-pennant'], color: ICON_CLR_GREEN}\n\t]],\n\t['3TrafficLights1', [\n\t\t{icon: ['fas', 'circle'], color: ICON_CLR_RED}, \n\t\t{icon: ['fas', 'circle'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'circle'], color: ICON_CLR_GREEN}\n\t]],\n\t['3TrafficLights2', [\n\t\t{icon: ['fas', 'square-o'], color: ICON_CLR_RED}, \n\t\t{icon: ['fas', 'square-o'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'square-o'], color: ICON_CLR_GREEN}\n\t]],\n\t['3Signs', [\n\t\t{icon: ['fas', 'square'], rotation: 45, color: ICON_CLR_RED},\n\t\t{icon: ['fas', 'triangle'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'circle'], color: ICON_CLR_GREEN}\n\t]],\n\t['3Symbols', [\n\t\t{icon: ['fas', 'circle-xmark'], color: ICON_CLR_RED}, \n\t\t{icon: ['fas', 'circle-exclamation'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'circle-check'], color: ICON_CLR_GREEN}\n\t]],\n\t['3Symbols2', [\n\t\t{icon: ['fas', 'xmark'], color: ICON_CLR_RED}, \n\t\t{icon: ['fas', 'exclamation'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'check'], color: ICON_CLR_GREEN}\n\t]],\n\t['3Stars', [\n\t\t{icon: ['fal', 'star'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'star-half-stroke'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'star'], color: ICON_CLR_YELLOW}\n\t]],\n\t['3Triangles', [\n\t\t{icon: 'caret-down', color: ICON_CLR_RED}, \n\t\t{icon: 'dash', color: ICON_CLR_YELLOW}, \n\t\t{icon: 'caret-up', color: ICON_CLR_GREEN}\n\t]],\n\t['4Arrows', [\n\t\t{icon: ['fas', 'down'], color: ICON_CLR_RED}, \n\t\t{icon: ['fas', 'down-right'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'up-right'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'up'], color: ICON_CLR_GREEN}\n\t]],\n\t['4ArrowsGray', [\n\t\t{icon: ['fas', 'down'], color: ICON_CLR_GRAY}, \n\t\t{icon: ['fas', 'down-right'], color: ICON_CLR_GRAY}, \n\t\t{icon: ['fas', 'up-right'], color: ICON_CLR_GRAY}, \n\t\t{icon: ['fas', 'up'], color: ICON_CLR_GRAY}\n\t]],\n\t['4RedToBlack', [\n\t\t{icon: ['fas', 'circle'], color: '#000000'}, \n\t\t{icon: ['fas', 'circle'], color: '#b1b1b1'}, \n\t\t{icon: ['fas', 'circle'], color: '#edb2a3'}, \n\t\t{icon: ['fas', 'circle'], color: ICON_CLR_RED}\n\t]],\t\n\t['4Rating', [\n\t\t{icon: 'signal-bars-weak', color: '#4a7db1'}, \n\t\t{icon: 'signal-bars-fair', color: '#4a7db1'}, \n\t\t{icon: 'signal-bars-good', color: '#4a7db1'}, \n\t\t{icon: ['fas', 'signal-bars'], color: '#4a7db1'}\n\t]],\n\t['4TrafficLights', [\n\t\t{icon: ['fas', 'circle'], color: '#000000'}, \n\t\t{icon: ['fas', 'circle'], color: ICON_CLR_RED}, \n\t\t{icon: ['fas', 'circle'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'circle'], color: ICON_CLR_GREEN}\n\t]],\n\t['5Arrows', [\n\t\t{icon: ['fas', 'down'], color: ICON_CLR_RED}, \n\t\t{icon: ['fas', 'down-right'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'right'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'up-right'], color: ICON_CLR_YELLOW}, \n\t\t{icon: ['fas', 'up'], color: ICON_CLR_GREEN},\n\t]],\n\t['5ArrowsGray', [\n\t\t{icon: ['fas', 'down'], color: ICON_CLR_GRAY}, \n\t\t{icon: ['fas', 'down-right'], color: ICON_CLR_GRAY}, \n\t\t{icon: ['fas', 'right'], color: ICON_CLR_GRAY}, \n\t\t{icon: ['fas', 'up-right'], color: ICON_CLR_GRAY}, \n\t\t{icon: ['fas', 'up'], color: ICON_CLR_GRAY},\n\t]], \n\t['5Rating', [\n\t\t{icon: ['fal', 'signal-bars']}, \n\t\t{icon: ['fal', 'signal-bars-weak'], color: '#4a7db1'}, \n\t\t{icon: ['fal', 'signal-bars-fair'], color: '#4a7db1'}, \n\t\t{icon: ['fal', 'signal-bars-good'], color: '#4a7db1'}, \n\t\t{icon: ['fas', 'signal-bars'], color: '#4a7db1'},\n\t]],\n\t['5Quarters', [\n\t\t{icon: ['fal', 'circle'], color: '#505050'}, \n\t\t{icon: ['fas', 'circle-quarter-stroke'], color: '#505050'}, \n\t\t{icon: ['fas', 'circle-half-stroke'], color: '#505050'}, \n\t\t{icon: ['fas', 'circle-three-quarters-stroke'], color: '#505050'}, \n\t\t{icon: ['fas', 'circle'], color: '#505050'}\n\t]]\n]);\n\nconst getIcon = (iconset: ConditionalFormatIconType, index: number) => {\n\tconst i = iconSets.get(iconset);\n\treturn i ? i[index] : null;\n}\n\nexport class ConditionalFormats extends DependencyModel {\n\n\tpublic readonly formats: ConditionalFormat[] = [];\n\tpublic readonly cellFormatMap = new Map<CellAddress, CellConditionalFormat[]>();\n\tpublic readonly extremes = new Map<string, [number, number]>();\n\n\tconstructor(model: GridModel, sourceData?: ConditionalFormatSource) {\n\t\tsuper(model, 'conditionalFormats');\n\t\tif (sourceData) this.populate(sourceData);\n\t}\n\n\tpopulate(sourceData: ConditionalFormatSource) {\n\t\tsourceData.forEach(item => {\n\t\t\ttry {\n\t\t\t\tthis.add(item);\n\t\t\t} catch (error) {\n\t\t\t\tlog.getLogger().error(`conditional format error: ${JSON.stringify(item)}`, error);\n\t\t\t}\n\t\t});\n\t}\n\n\trefresh() {\n\t\tthis.dependencies.clear();\n\t\tthis.cellFormatMap.clear();\n\t\tthis.extremes.clear();\n\t\tthis.formats.forEach(item => this.initConditionalFormat(item));\n\t}\n\n\tclearCellDependecies(cell: CellModel) {\n\t\tconst addr = cell.address;\n\t\tthis.dependencies.clearCellDependecies(addr);\n\t\t\n\t\t// clear cached formulas\n\t\tconst item = this.cellFormatMap.get(addr);\n\t\titem.forEach(i => ({cf: i.cf}));\n\t\t\n\t\t// TODO - update extremes\n\t\t// maybe it should return all affected cells\n\n\t\treturn this;\n\t}\n\n\tgetExtremes(cf: ConditionalFormat) {\n\t\tif (this.extremes.has(cf.key)) return this.extremes.get(cf.key);\n\n\t\tconst extremes: [number, number] = [Infinity, -Infinity];\n\n\t\tcf.ranges.forEach(r => {\n\t\t\tfor (const row of this.model.getValuesInRange(r)) {\n\t\t\t\tfor (const v of row) {\n\t\t\t\t\tif (v == null) continue;\n\t\t\t\t\tif (isNaN(v as number)) continue;\n\t\t\t\t\textremes[0] = Math.min(extremes[0], v as number);\n\t\t\t\t\textremes[1] = Math.max(extremes[1], v as number);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t\n\t\tif (cf.cmin) {\n\t\t\tif (cf.cmin.t == 'num') extremes[0] = cf.cmin.v;\n\t\t\telse if (cf.cmin.t == 'percent') {\n\t\t\t\textremes[0] = extremes[0] + (extremes[1] - extremes[0]) * cf.cmin.v / 100;\n\t\t\t}\n\t\t}\n\n\t\tif (cf.cmax) {\n\t\t\tif (cf.cmax.t == 'num') extremes[1] = cf.cmax.v;\n\t\t\telse if (cf.cmax.t == 'percent') {\n\t\t\t\textremes[1] = extremes[0] + (extremes[1] - extremes[0]) * cf.cmax.v / 100;\n\t\t\t}\n\t\t}\n\n\t\tthis.extremes.set(cf.key, extremes);\n\t\treturn extremes;\n\t}\n\n\tinvalidateExtremes(cell: CellModel) {\n\t\tthis.cellFormatMap.get(cell.address).forEach(item => this.extremes.delete(item.cf.key));\n\t}\n\n\tevaluateScaleFormat(cell: CellModel, ccf: CellConditionalFormat) : Style {\n\t\tconst v = cell.value;\n\t\tif (v == null) return null;\n\n\t\tconst [min, max] = this.getExtremes(ccf.cf);\n\t\tlet fgColor: string;\n\t\tconst amount = ((v as number) - min) / (max - min);\n\n\t\tif (ccf.cf.cmid?.color) {\n\t\t\t// 3 color scale\n\t\t\tif (amount == 0.5) {\n\t\t\t\tfgColor = '#' + ccf.cf.cmid.color;\n\t\t\t} else if (amount > 0.5) {\n\t\t\t\tfgColor = colors.mix('#' + ccf.cf.cmid.color, '#' + ccf.cf.cmax.color, (amount - 0.5) * 2);\n\t\t\t} else {\n\t\t\t\tfgColor = colors.mix('#' + ccf.cf.cmin.color, '#' + ccf.cf.cmid.color, amount * 2);\n\t\t\t}\n\t\t} else if (ccf.cf.cmin?.color && ccf.cf.cmax?.color) {\n\t\t\t// 2 color scale\n\t\t\tfgColor = colors.mix('#' + ccf.cf.cmin.color, '#' + ccf.cf.cmax.color, amount);\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn {\n\t\t\tcolor: colors.contrastColor(fgColor).substring(1),\n\t\t\tfgColor: fgColor.substring(1)\n\t\t};\n\t}\n\n\tevaluateBarFormat(cell: CellModel, ccf: CellConditionalFormat) : Style {\n\t\tconst v = cell.value as number;\n\t\tif (v == null) return null;\n\n\t\tconst ext = this.getExtremes(ccf.cf);\n\t\tlet min = ext[0];\n\t\tconst max = ext[1];\n\t\tconst hasNegative = min < 0;\n\t\tif (!hasNegative) min = min - 0.1 * (max - min);\n\t\tconst amount = Math.round((100 * (v - min) / (max - min)));\n\n\t\tif (!ccf.initialized) {\n\t\t\tccf.initialized = true;\n\t\t\tccf.cf.ranges.forEach(r => this._dependencies.add(cell.address, r.A1, null));\n\t\t}\n\n\t\tconst gradient: string[] = [];\n\n\t\tif (hasNegative) {\n\t\t\tconst offset = Math.round(-100 * min / (max - min));\n\t\t\tif (v >= 0) {\n\t\t\t\tgradient.push(`#00000000 ${offset}%`);\n\t\t\t\tgradient.push(`#${ccf.cf.color} ${offset}%`);\n\t\t\t\tgradient.push(`#${ccf.cf.color} ${amount}%`);\n\t\t\t\tgradient.push(`#00000000 ${amount}%`);\n\t\t\t} else {\n\t\t\t\tgradient.push(`#00000000 ${amount}%`);\n\t\t\t\tgradient.push(`#ff0000 ${amount}%`);\n\t\t\t\tgradient.push(`#ff0000 ${offset}%`);\n\t\t\t\tgradient.push(`#00000000 ${offset}%`);\n\t\t\t}\n\t\t} else {\n\t\t\tgradient.push(`#${ccf.cf.color} ${amount}%`);\n\t\t\tgradient.push(`#00000000 ${amount}%`);\n\t\t}\n\n\t\treturn {\n\t\t\tcssStyle: {\n\t\t\t\tbackgroundClip: 'padding-box',\n\t\t\t\tbackgroundImage: `linear-gradient(90deg, ${gradient.join(',')})`\n\t\t\t}\n\t\t};\n\t}\n\n\tevaluateFormulaFormat(cell: CellModel, ccf: CellConditionalFormat) {\n\t\tif (!ccf.initialized && ccf.cf.condition) {\n\t\t\tccf.initialized = true;\n\t\t\tconst addr = cell.address;\n\t\t\tconst f = new Formula(ccf.cf.condition, this.model.calculations.tokenizer);\n\t\t\tccf.f = f.shift({\n\t\t\t\tindex: 0,\n\t\t\t\toffset: cell.c - ccf.cf.firstCell.c1, \n\t\t\t\tdirection: 'right'\n\t\t\t}).shift({\n\t\t\t\tindex: 0, \n\t\t\t\toffset: cell.r - ccf.cf.firstCell.r1,\n\t\t\t\tdirection: 'down'\n\t\t\t});\n\n\t\t\tf.cells.forEach(dep => this._dependencies.add(addr, dep[1].A1, dep[2]));\n\t\t\tf.ranges.forEach(dep => this._dependencies.add(addr, dep[1].A1, dep[2]));\n\t\t\tf.variables.forEach(([_i, v]) => {\n\t\t\t\tconst c = this.model.getCellByName(v, cell.range);\n\t\t\t\tif (c) this._dependencies.add(addr, c.address, null);\n\t\t\t});\n\t\t}\n\n\t\t// if condition is not provided, it evaluates to true\n\t\tconst res = ccf.f ? this.model.calculations.evaluateFormula(ccf.f, cell) : true;\n\t\tif (!res) return null;\n\t\tconst style = {...ccf.cf.style};\n\t\tif (!style.color) colors.plainHex(colors.contrastColor(colors.css(ccf.cf.style.fgColor)));\n\t\treturn style;\n\t}\n\n\tevaluateIconFormat(cell: CellModel, ccf: CellConditionalFormat) : Style {\n\t\tconst v = cell.value;\n\t\tif (v == null) return null;\n\n\t\tconst [min, max] = this.getExtremes(ccf.cf);\n\t\tlet percentValue: number;\n\t\t\n\t\tfor (let i = ccf.cf.thresh.length - 1; i >= 0; i--) {\n\t\t\tconst thresh = ccf.cf.thresh[i];\n\t\t\tif (thresh.t === 'percent') {\n\t\t\t\tif (percentValue == null) percentValue = 100 * (v as number - min) / (max - min);\n\t\t\t\tif (percentValue >= thresh.v) {\n\t\t\t\t\treturn {icon: getIcon(ccf.cf.v as ConditionalFormatIconType, i)};\n\t\t\t\t}\n\t\t\t} else if (thresh.t === 'num') {\n\t\t\t\tif (v as number >= thresh.v) {\n\t\t\t\t\treturn {icon: getIcon(ccf.cf.v as ConditionalFormatIconType, i)};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tevaluate(cell: CellModel) {\n\t\tconst addr = cell.address;\n\t\tconst formats = this.cellFormatMap.get(addr);\n\t\tif (!formats) return null;\n\t\tlet style: Style = null;\n\t\tlet diffStyle: Style = null;\n\t\tfor (const item of formats) {\n\t\t\ttry {\n\t\t\t\tswitch (item.cf.type) {\n\t\t\t\t\tcase 'formula':\n\t\t\t\t\t\tdiffStyle = this.evaluateFormulaFormat(cell, item);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'scale':\n\t\t\t\t\t\tdiffStyle = this.evaluateScaleFormat(cell, item);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'bar':\n\t\t\t\t\t\tdiffStyle = this.evaluateBarFormat(cell, item);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'icon':\n\t\t\t\t\t\tdiffStyle = this.evaluateIconFormat(cell, item);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tdiffStyle = null;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tlog.getLogger().error(`Conditional format error: ${JSON.stringify(item)}`, error);\n\t\t\t}\n\t\t\t\n\t\t\tif (diffStyle) {\n\t\t\t\tstyle = style ? {...style, ...diffStyle} : diffStyle;\n\t\t\t\tif (item.cf.stop) break;\n\t\t\t}\n\t\t}\n\t\treturn style;\n\t}\n\n\tinitConditionalFormat(item: ConditionalFormat) {\n\t\titem.firstCell = null;\n\t\t(item.ranges as CellRange[]).forEach(range => {\n\t\t\tfor (const r of new IterableAddressRange(range.intersect(this.model.gridRange))) {\n\t\t\t\tconst a1 = r.A1;\n\t\t\t\tswitch (item.type) {\n\t\t\t\t\tcase 'formula':\n\t\t\t\t\t\tif (!item.firstCell) {\n\t\t\t\t\t\t\titem.firstCell = r;\n\t\t\t\t\t\t\titem.formula = item.condition ? new Formula(item.condition, this.model.calculations.tokenizer) : null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst ccfs = this.cellFormatMap.get(a1) || this.cellFormatMap.set(a1, []).get(a1);\n\t\t\t\tccfs.push({cf: item});\n\t\t\t}\n\t\t});\n\t\treturn item;\n\t}\n\n\tadd(itemSource: ConditionalFormatItemSource) {\n\t\tconst item: ConditionalFormat = {\n\t\t\tkey: itemSource.ranges,\n\t\t\tranges: CellRange.fromA1s(itemSource.ranges),\n\t\t\ttype: itemSource.type || 'formula',\n\t\t\tfirstCell: null,\n\t\t\tformula: null,\n\t\t\tstyle: itemSource.style ? this.model.styles.add(itemSource.style) : null,\n\t\t\tcondition: itemSource.condition,\n\t\t\tstop: !!itemSource.stop,\n\t\t\tcmin: itemSource.cmin,\n\t\t\tcmid: itemSource.cmid,\n\t\t\tcmax: itemSource.cmax,\n\t\t\tcolor: itemSource.color,\n\t\t\tv: itemSource.v,\n\t\t\tthresh: itemSource.thresh\n\t\t};\n\n\t\tthis.formats.push(this.initConditionalFormat(item));\n\t}\n\n\tgetSourceData() {\n\t\treturn this.formats.map<ConditionalFormatItemSource>(format => ({\n\t\t\ttype: format.type,\n\t\t\tranges: CellRange.toA1s(format.ranges),\n\t\t\tstyle: format.style,\n\t\t\tcondition: format.condition,\n\t\t\tstop: format.stop,\n\t\t\tcmin: format.cmin,\n\t\t\tcmid: format.cmid,\n\t\t\tcmax: format.cmax,\n\t\t\tcolor: format.color,\n\t\t\tv: format.v,\n\t\t\tthresh: format.thresh\n\t\t}));\n\t}\n\n\n}"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Border, BorderStyle, Style, VerticalAlignment } from "./style";
|
|
2
|
+
export type CSSStyle = Partial<CSSStyleDeclaration> & {
|
|
3
|
+
[propName: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function cssStyleFromString(strStyle: string): CSSStyle;
|
|
6
|
+
export type CSSBorderStyle = 'none' | 'solid' | 'double' | 'dotted' | 'dashed';
|
|
7
|
+
export declare const borderStyleCSSMap: Map<BorderStyle, {
|
|
8
|
+
width: number;
|
|
9
|
+
style: CSSBorderStyle;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const borderCSSStyleMap: Map<CSSBorderStyle, Map<number, BorderStyle>>;
|
|
12
|
+
export declare function convertCSSVerticalAlignment(align: string): VerticalAlignment;
|
|
13
|
+
export declare function convertCSSColor(color: string): string;
|
|
14
|
+
export declare const convertCSSBorder: (border: string) => Border;
|
|
15
|
+
export declare const convertToCSSBorder: (b: Border) => string;
|
|
16
|
+
export declare const addPattern: (css: CSSStyle, s: Style) => CSSStyle;
|
|
17
|
+
export declare const addGradient: (css: CSSStyle, s: Style) => CSSStyle;
|
|
18
|
+
export declare const styleToCSStyle: (s: Style) => CSSStyle;
|
|
19
|
+
export declare const cssStyleToStyle: (s: CSSStyle | string) => Style;
|
|
20
|
+
//# sourceMappingURL=cssStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cssStyle.d.ts","sourceRoot":"","sources":["../../src/model/cssStyle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAuB,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE7F,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAIrF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAO7D;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAC,OAAO,GAAC,QAAQ,GAAC,QAAQ,GAAC,QAAQ,CAAC;AACvE,eAAO,MAAM,iBAAiB;WACtB,MAAM;WACN,cAAc;EAgBpB,CAAC;AAEH,eAAO,MAAM,iBAAiB,+CAQ1B,CAAC;AAEL,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GACP,iBAAiB,CAClE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,UAK5C;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAYjD,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,GAAG,MAAM,WAQ3C,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,KAAK,QAAQ,EAAE,GAAG,KAAK,KAAI,QAiFrD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,QAAQ,EAAE,GAAG,KAAK,KAAI,QAGtD,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,GAAG,KAAK,KAAG,QAmCzC,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,GAAG,QAAQ,GAAC,MAAM,KAAG,KA4FpD,CAAA"}
|