dtable-statistic 4.3.15 → 4.3.16
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.
|
@@ -39,7 +39,10 @@ async function calculateResult(chart, value, _ref) {
|
|
|
39
39
|
const isGroupChart = !!groupColumn;
|
|
40
40
|
let result = [];
|
|
41
41
|
if (!isGroupChart) {
|
|
42
|
-
const
|
|
42
|
+
const completedColumn = (0, _dtableUtils.getTableColumnByKey)(table, completed_column);
|
|
43
|
+
const targetColumn = (0, _dtableUtils.getTableColumnByKey)(table, target_column);
|
|
44
|
+
let labelCountMap = {};
|
|
45
|
+
let labels = [];
|
|
43
46
|
statRows.forEach(row => {
|
|
44
47
|
let {
|
|
45
48
|
_id: rowId
|
|
@@ -52,43 +55,59 @@ async function calculateResult(chart, value, _ref) {
|
|
|
52
55
|
label = label[0];
|
|
53
56
|
}
|
|
54
57
|
label = (0, _rowUtils.getFormattedLabel)(nameColumn, label, value.collaborators);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
currentValue =
|
|
61
|
-
targetValue =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
58
|
+
let currentValue = (0, _rowUtils.getCellValue)(row, formulaRow, completedColumn);
|
|
59
|
+
let targetValue = (0, _rowUtils.getCellValue)(row, formulaRow, targetColumn);
|
|
60
|
+
currentValue = (0, _dtableUtils.isNumber)(currentValue) ? currentValue : 0;
|
|
61
|
+
targetValue = (0, _dtableUtils.isNumber)(targetValue) ? targetValue : 0;
|
|
62
|
+
if (labelCountMap[label]) {
|
|
63
|
+
labelCountMap[label].currentValue = currentValue + labelCountMap[label].currentValue;
|
|
64
|
+
labelCountMap[label].targetValue = targetValue + labelCountMap[label].targetValue;
|
|
65
|
+
} else {
|
|
66
|
+
labelCountMap[label] = {
|
|
67
|
+
currentValue,
|
|
68
|
+
targetValue
|
|
69
|
+
};
|
|
70
|
+
labels.push(label);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
labels.forEach(label => {
|
|
75
|
+
if (labelCountMap[label]) {
|
|
76
|
+
const {
|
|
77
|
+
currentValue,
|
|
78
|
+
targetValue
|
|
79
|
+
} = labelCountMap[label];
|
|
80
|
+
if (currentValue < targetValue) {
|
|
81
|
+
result.unshift({
|
|
82
|
+
name: label,
|
|
83
|
+
value: currentValue,
|
|
84
|
+
type: 'completed',
|
|
85
|
+
current_value: currentValue,
|
|
86
|
+
target_value: targetValue
|
|
87
|
+
}, {
|
|
88
|
+
name: label,
|
|
89
|
+
value: targetValue - currentValue,
|
|
90
|
+
type: 'uncompleted',
|
|
91
|
+
current_value: currentValue,
|
|
92
|
+
target_value: targetValue
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
result.unshift({
|
|
96
|
+
name: label,
|
|
97
|
+
value: currentValue,
|
|
98
|
+
type: 'completed',
|
|
99
|
+
current_value: currentValue,
|
|
100
|
+
target_value: targetValue
|
|
101
|
+
});
|
|
86
102
|
}
|
|
87
103
|
}
|
|
88
104
|
});
|
|
89
105
|
} else {
|
|
90
|
-
const
|
|
91
|
-
const
|
|
106
|
+
const completedColumn = (0, _dtableUtils.getTableColumnByKey)(table, completed_column);
|
|
107
|
+
const targetColumn = (0, _dtableUtils.getTableColumnByKey)(table, target_column);
|
|
108
|
+
let labelCountMap = {};
|
|
109
|
+
let colorMap = {};
|
|
110
|
+
let labelGroups = [];
|
|
92
111
|
let colorIndex = 0;
|
|
93
112
|
let isFormulaType = _dtableUtils.FORMULA_COLUMN_TYPES_MAP[groupColumn.type];
|
|
94
113
|
const isGroupColumnDataAsAnArray = (0, _commonUtils.isArrayCellValue)(groupColumn);
|
|
@@ -116,54 +135,72 @@ async function calculateResult(chart, value, _ref) {
|
|
|
116
135
|
colorMap[groupLabel] = color;
|
|
117
136
|
colorIndex++;
|
|
118
137
|
}
|
|
119
|
-
|
|
120
|
-
if (groupLabel && (!cache || !cache[groupLabel])) {
|
|
121
|
-
const completedColumn = (0, _dtableUtils.getTableColumnByKey)(table, completed_column);
|
|
122
|
-
const targetColumn = (0, _dtableUtils.getTableColumnByKey)(table, target_column);
|
|
138
|
+
if (groupLabel) {
|
|
123
139
|
let currentValue = (0, _rowUtils.getCellValue)(row, formulaRow, completedColumn);
|
|
124
140
|
let targetValue = (0, _rowUtils.getCellValue)(row, formulaRow, targetColumn);
|
|
125
141
|
currentValue = (0, _dtableUtils.isNumber)(currentValue) ? currentValue : 0;
|
|
126
142
|
targetValue = (0, _dtableUtils.isNumber)(targetValue) ? targetValue : 0;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
value: currentValue,
|
|
132
|
-
color,
|
|
133
|
-
type: 'completed',
|
|
134
|
-
current_value: currentValue,
|
|
135
|
-
target_value: targetValue
|
|
136
|
-
});
|
|
143
|
+
const concatLabel = "".concat(label, "_").concat(groupLabel);
|
|
144
|
+
if (labelCountMap[concatLabel]) {
|
|
145
|
+
labelCountMap[concatLabel].currentValue = currentValue + labelCountMap[concatLabel].currentValue;
|
|
146
|
+
labelCountMap[concatLabel].targetValue = targetValue + labelCountMap[concatLabel].targetValue;
|
|
137
147
|
} else {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}, {
|
|
147
|
-
name: label,
|
|
148
|
-
group_label: groupLabel,
|
|
149
|
-
value: targetValue - currentValue,
|
|
150
|
-
color,
|
|
151
|
-
type: 'uncompleted',
|
|
152
|
-
current_value: currentValue,
|
|
153
|
-
target_value: targetValue
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
if (cache) {
|
|
157
|
-
cache[groupLabel] = 1;
|
|
158
|
-
memo.set(label, cache);
|
|
159
|
-
} else {
|
|
160
|
-
memo.set(label, {
|
|
161
|
-
[groupLabel]: 1
|
|
148
|
+
labelCountMap[concatLabel] = {
|
|
149
|
+
currentValue,
|
|
150
|
+
targetValue
|
|
151
|
+
};
|
|
152
|
+
labelGroups.push({
|
|
153
|
+
key: concatLabel,
|
|
154
|
+
label,
|
|
155
|
+
groupLabel
|
|
162
156
|
});
|
|
163
157
|
}
|
|
164
158
|
}
|
|
165
159
|
}
|
|
166
160
|
});
|
|
161
|
+
labelGroups.forEach(labelGroup => {
|
|
162
|
+
const {
|
|
163
|
+
key,
|
|
164
|
+
label,
|
|
165
|
+
groupLabel
|
|
166
|
+
} = labelGroup;
|
|
167
|
+
if (labelCountMap[key]) {
|
|
168
|
+
const color = colorMap[groupLabel];
|
|
169
|
+
const {
|
|
170
|
+
currentValue,
|
|
171
|
+
targetValue
|
|
172
|
+
} = labelCountMap[key];
|
|
173
|
+
if (currentValue < targetValue) {
|
|
174
|
+
result.unshift({
|
|
175
|
+
name: label,
|
|
176
|
+
group_label: groupLabel,
|
|
177
|
+
value: currentValue,
|
|
178
|
+
color,
|
|
179
|
+
type: 'completed',
|
|
180
|
+
current_value: currentValue,
|
|
181
|
+
target_value: targetValue
|
|
182
|
+
}, {
|
|
183
|
+
name: label,
|
|
184
|
+
group_label: groupLabel,
|
|
185
|
+
value: targetValue - currentValue,
|
|
186
|
+
color,
|
|
187
|
+
type: 'uncompleted',
|
|
188
|
+
current_value: currentValue,
|
|
189
|
+
target_value: targetValue
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
result.unshift({
|
|
193
|
+
name: label,
|
|
194
|
+
group_label: groupLabel,
|
|
195
|
+
value: currentValue,
|
|
196
|
+
color,
|
|
197
|
+
type: 'completed',
|
|
198
|
+
current_value: currentValue,
|
|
199
|
+
target_value: targetValue
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
167
204
|
result.colorMap = colorMap;
|
|
168
205
|
}
|
|
169
206
|
return result;
|