@datarailsshared/dr_renderer 1.2.405 → 1.2.407
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/package.json +1 -1
- package/src/dr_pivottable.js +37 -89
- package/src/highcharts_renderer.js +14 -55
- package/src/pivottable.js +2 -5
- package/tests/highcharts_renderer.test.js +10 -102
package/package.json
CHANGED
package/src/dr_pivottable.js
CHANGED
@@ -174,108 +174,56 @@ let initDRPivotTable = function($, window, document) {
|
|
174
174
|
return keys.join(delim);
|
175
175
|
}
|
176
176
|
|
177
|
-
DRPivotData.prototype.processRecord = function(record
|
178
|
-
if (
|
179
|
-
|
180
|
-
|
181
|
-
this.notFirst = true;
|
182
|
-
}
|
183
|
-
let getRowAggregator = (function(_this) {
|
184
|
-
return function(key) {
|
185
|
-
return _this.aggregator(_this, key, []);
|
186
|
-
};
|
187
|
-
})(this);
|
188
|
-
let getColAggregator = (function(_this) {
|
189
|
-
return function(key) {
|
190
|
-
return _this.aggregator(_this, [], key);
|
191
|
-
};
|
192
|
-
})(this);
|
193
|
-
|
194
|
-
const rowKey = this.getAttrsKeys(record, this.rowAttrs);
|
195
|
-
const colKey = this.getAttrsKeys(record, this.colAttrs);
|
196
|
-
|
197
|
-
let flatRowKey = rowKey.join(delim);
|
198
|
-
let flatColKey = colKey.join(delim);
|
199
|
-
|
200
|
-
if (this.keysLength === rowKey.length + colKey.length) {
|
201
|
-
if (!this.isKeysSortingDoneOnBackendSide && !isFlatKeyInPivotKeys(this.rowKeys, flatRowKey)) {
|
202
|
-
this.rowKeys.push(rowKey);
|
203
|
-
}
|
204
|
-
if (!this.isKeysSortingDoneOnBackendSide && !isFlatKeyInPivotKeys(this.colKeys, flatColKey)) {
|
205
|
-
this.colKeys.push(colKey);
|
206
|
-
}
|
207
|
-
}
|
208
|
-
|
209
|
-
if (!colKey.length && !rowKey.length) {
|
210
|
-
this.allTotal.push(record);
|
211
|
-
} else if (!colKey.length && rowKey.length) {
|
212
|
-
if (!this.rowTotals[flatRowKey]) {
|
213
|
-
this.rowTotals[flatRowKey] = getRowAggregator(rowKey.slice());
|
214
|
-
this.rowTotals[flatRowKey].push(record);
|
215
|
-
}
|
216
|
-
} else if (!rowKey.length && colKey.length) {
|
217
|
-
if (!this.colTotals[flatColKey]) {
|
218
|
-
this.colTotals[flatColKey] = getColAggregator(colKey.slice());
|
219
|
-
this.colTotals[flatColKey].push(record);
|
220
|
-
}
|
221
|
-
} else {
|
222
|
-
if (!this.tree[flatRowKey]) {
|
223
|
-
this.tree[flatRowKey] = {};
|
224
|
-
}
|
225
|
-
this.tree[flatRowKey][flatColKey] = this.aggregator(this, rowKey, colKey);
|
226
|
-
this.tree[flatRowKey][flatColKey].push(record);
|
227
|
-
}
|
228
|
-
|
229
|
-
return;
|
230
|
-
}
|
231
|
-
|
232
|
-
var colKey, fColKey, fRowKey, flatColKey, flatRowKey, i, j, k, m, n, ref, results, rowKey;
|
233
|
-
rowKey = [];
|
234
|
-
colKey = [];
|
235
|
-
const recordValues = _.values(record);
|
236
|
-
const containsAverage = _.includes(recordValues, 'DR_Average');
|
237
|
-
const containsOthers = _.includes(recordValues, 'DR_Others');
|
238
|
-
if (!containsAverage && !containsOthers) {
|
239
|
-
this.allTotal.push(record);
|
177
|
+
DRPivotData.prototype.processRecord = function(record) {
|
178
|
+
if (!this.notFirst) {
|
179
|
+
this.keysLength = _.filter(_.keys(record), key => !_.includes(['data_types', 'formats', 'values_formats'], key)).length - 1;
|
180
|
+
this.notFirst = true;
|
240
181
|
}
|
241
|
-
|
182
|
+
let getRowAggregator = (function(_this) {
|
242
183
|
return function(key) {
|
243
184
|
return _this.aggregator(_this, key, []);
|
244
185
|
};
|
245
|
-
})(this)
|
246
|
-
|
186
|
+
})(this);
|
187
|
+
let getColAggregator = (function(_this) {
|
247
188
|
return function(key) {
|
248
189
|
return _this.aggregator(_this, [], key);
|
249
190
|
};
|
250
|
-
})(this)
|
191
|
+
})(this);
|
251
192
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
193
|
+
const rowKey = this.getAttrsKeys(record, this.rowAttrs);
|
194
|
+
const colKey = this.getAttrsKeys(record, this.colAttrs);
|
195
|
+
|
196
|
+
let flatRowKey = rowKey.join(delim);
|
197
|
+
let flatColKey = colKey.join(delim);
|
198
|
+
|
199
|
+
if (this.keysLength === rowKey.length + colKey.length) {
|
200
|
+
if (!this.isKeysSortingDoneOnBackendSide && !isFlatKeyInPivotKeys(this.rowKeys, flatRowKey)) {
|
201
|
+
this.rowKeys.push(rowKey);
|
202
|
+
}
|
203
|
+
if (!this.isKeysSortingDoneOnBackendSide && !isFlatKeyInPivotKeys(this.colKeys, flatColKey)) {
|
204
|
+
this.colKeys.push(colKey);
|
205
|
+
}
|
256
206
|
}
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
207
|
+
|
208
|
+
if (!colKey.length && !rowKey.length) {
|
209
|
+
this.allTotal.push(record);
|
210
|
+
} else if (!colKey.length && rowKey.length) {
|
211
|
+
if (!this.rowTotals[flatRowKey]) {
|
212
|
+
this.rowTotals[flatRowKey] = getRowAggregator(rowKey.slice());
|
213
|
+
this.rowTotals[flatRowKey].push(record);
|
214
|
+
}
|
215
|
+
} else if (!rowKey.length && colKey.length) {
|
216
|
+
if (!this.colTotals[flatColKey]) {
|
217
|
+
this.colTotals[flatColKey] = getColAggregator(colKey.slice());
|
218
|
+
this.colTotals[flatColKey].push(record);
|
219
|
+
}
|
220
|
+
} else {
|
261
221
|
if (!this.tree[flatRowKey]) {
|
262
222
|
this.tree[flatRowKey] = {};
|
263
223
|
}
|
264
|
-
|
265
|
-
|
266
|
-
results1 = [];
|
267
|
-
for (j = l = 0, ref1 = n; 0 <= ref1 ? l <= ref1 : l >= ref1; j = 0 <= ref1 ? ++l : --l) {
|
268
|
-
fColKey = colKey.slice(0, j + 1);
|
269
|
-
flatColKey = fColKey.join(delim);
|
270
|
-
if (!this.tree[flatRowKey][flatColKey]) {
|
271
|
-
this.tree[flatRowKey][flatColKey] = this.aggregator(this, fRowKey, fColKey);
|
272
|
-
}
|
273
|
-
results1.push(this.tree[flatRowKey][flatColKey].push(record));
|
274
|
-
}
|
275
|
-
return results1;
|
276
|
-
}).call(this));
|
224
|
+
this.tree[flatRowKey][flatColKey] = this.aggregator(this, rowKey, colKey);
|
225
|
+
this.tree[flatRowKey][flatColKey].push(record);
|
277
226
|
}
|
278
|
-
return results;
|
279
227
|
};
|
280
228
|
|
281
229
|
DRPivotData.prototype.getAggregator = function(rowKey, colKey) {
|
@@ -149,7 +149,6 @@ const CHART_LEGEND_DEFAULT_LABEL = 'Legend (Series)';
|
|
149
149
|
|
150
150
|
const FEATURES = {
|
151
151
|
ENABLE_NEW_WIDGET_VALUE_FORMATTING: 'enable_new_widget_value_formatting',
|
152
|
-
ENABLE_SERVER_TOTALS_CALCULATION: 'enable_server_totals_calculation',
|
153
152
|
FORMAT_AXIS: 'use_default_table_format_for_axis',
|
154
153
|
FORMAT_DATES_AS_OTHER_AXIS_TYPES: 'format_dates_as_other_axis_types',
|
155
154
|
MULTIPLE_DIMENSION_TAGS: 'multiple_dimension_tags',
|
@@ -198,7 +197,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
198
197
|
}
|
199
198
|
lodash.assign(highchartsRenderer, HIGHCHARTS_CONSTANTS);
|
200
199
|
|
201
|
-
highchartsRenderer.useTotalsCalculation = false;
|
202
200
|
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
203
201
|
let disableAnimation = false;
|
204
202
|
|
@@ -207,7 +205,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
207
205
|
}
|
208
206
|
|
209
207
|
if (!!lodash.get(document, 'ReportHippo.user')) {
|
210
|
-
highchartsRenderer.useTotalsCalculation = highchartsRenderer.hasFeature(FEATURES.ENABLE_SERVER_TOTALS_CALCULATION);
|
211
208
|
disableAnimation = document.ReportHippo.user.organization && document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.disable_animation
|
212
209
|
highchartsRenderer.enabledNewWidgetValueFormatting = highchartsRenderer.hasFeature(FEATURES.ENABLE_NEW_WIDGET_VALUE_FORMATTING);
|
213
210
|
highchartsRenderer.isSortingOnBackendEnabled = highchartsRenderer.hasFeature(FEATURES.ENABLE_SERVER_WIDGET_DATA_SORTING);
|
@@ -1138,8 +1135,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1138
1135
|
has_delta = true;
|
1139
1136
|
}
|
1140
1137
|
|
1141
|
-
|
1142
|
-
|
1138
|
+
lodash.forEach([col_n_keys, row_n_keys], keysArray => {
|
1139
|
+
if (keysArray && !keysArray.length) {
|
1140
|
+
keysArray.push([]);
|
1141
|
+
}
|
1142
|
+
});
|
1143
1143
|
|
1144
1144
|
var i = 0;
|
1145
1145
|
var variat_serias = null;
|
@@ -2425,10 +2425,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2425
2425
|
}
|
2426
2426
|
var uniqueVals = kpioptions.value.value == "Unique";
|
2427
2427
|
|
2428
|
-
if (!pivotData.colKeys.length) {
|
2429
|
-
pivotData.colKeys.push([]);
|
2430
|
-
}
|
2431
|
-
|
2432
2428
|
let temp_series = highchartsRenderer.ptCreateBasicLineSeries(pivotData, null, true, uniqueVals, null, opts, chartOptions);
|
2433
2429
|
|
2434
2430
|
var total = [];
|
@@ -3916,10 +3912,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3916
3912
|
this.ignoreValue = true;
|
3917
3913
|
}
|
3918
3914
|
|
3919
|
-
if (
|
3915
|
+
if (!isNaN(parseFloat(record[attr]))) {
|
3920
3916
|
return this.sum = parseFloat(record[attr]);
|
3921
|
-
} else if (!isNaN(parseFloat(record[attr]))) {
|
3922
|
-
return this.sum += parseFloat(record[attr]);
|
3923
3917
|
}
|
3924
3918
|
},
|
3925
3919
|
value: function () {
|
@@ -4074,11 +4068,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4074
4068
|
this.ignoreValue = true;
|
4075
4069
|
}
|
4076
4070
|
|
4077
|
-
|
4078
|
-
return this.sum = val;
|
4079
|
-
} else {
|
4080
|
-
return this.sum += val;
|
4081
|
-
}
|
4071
|
+
return this.sum = val;
|
4082
4072
|
} else {
|
4083
4073
|
return this.sum = NaN;
|
4084
4074
|
}
|
@@ -4166,11 +4156,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4166
4156
|
if (highchartsRenderer.ignoreIfCalculatedValue(data, rowKey, colKey, record, calculated_info.associated_fields, render_options, is_graph)) {
|
4167
4157
|
this.ignoreValue = true;
|
4168
4158
|
}
|
4169
|
-
|
4170
|
-
|
4171
|
-
} else {
|
4172
|
-
return this.val = Math.min(x, (ref = this.val) != null ? ref : x);
|
4173
|
-
}
|
4159
|
+
|
4160
|
+
return this.val = x;
|
4174
4161
|
}
|
4175
4162
|
},
|
4176
4163
|
value: function () {
|
@@ -4257,11 +4244,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4257
4244
|
this.ignoreValue = true;
|
4258
4245
|
}
|
4259
4246
|
|
4260
|
-
|
4261
|
-
return this.val = x;
|
4262
|
-
} else {
|
4263
|
-
return this.val = Math.max(x, (ref = this.val) != null ? ref : x);
|
4264
|
-
}
|
4247
|
+
return this.val = x;
|
4265
4248
|
}
|
4266
4249
|
},
|
4267
4250
|
value: function () {
|
@@ -4349,12 +4332,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4349
4332
|
this.ignoreValue = true;
|
4350
4333
|
}
|
4351
4334
|
|
4352
|
-
|
4353
|
-
if (highchartsRenderer.useTotalsCalculation) {
|
4354
|
-
this.sum = parseFloat(x);
|
4355
|
-
} else {
|
4356
|
-
this.sum += parseFloat(x);
|
4357
|
-
}
|
4335
|
+
this.sum = parseFloat(x);
|
4358
4336
|
|
4359
4337
|
return this.len++;
|
4360
4338
|
}
|
@@ -4363,10 +4341,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4363
4341
|
if (this.ignoreValue) {
|
4364
4342
|
return null;
|
4365
4343
|
}
|
4366
|
-
|
4367
|
-
return this.sum;
|
4368
|
-
}
|
4369
|
-
return this.sum / this.len;
|
4344
|
+
return this.sum;
|
4370
4345
|
},
|
4371
4346
|
format: function (x, only_formats) {
|
4372
4347
|
if (x == null || x == undefined)
|
@@ -8956,20 +8931,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8956
8931
|
return res;
|
8957
8932
|
};
|
8958
8933
|
|
8959
|
-
highchartsRenderer.setNewFieldNames = function (res) {
|
8960
|
-
if (highchartsRenderer.useTotalsCalculation) {
|
8961
|
-
return res;
|
8962
|
-
}
|
8963
|
-
|
8964
|
-
if (res && res[0] && res[0]['DR_Values']) {
|
8965
|
-
lodash.forEach(res, function (item) {
|
8966
|
-
item['DR_Values'] = highchartsRenderer.getFieldName(item['DR_Values']);
|
8967
|
-
});
|
8968
|
-
}
|
8969
|
-
|
8970
|
-
return res;
|
8971
|
-
};
|
8972
|
-
|
8973
8934
|
highchartsRenderer.replaceSortingKeysWithMappedValues = function(keys, invertedDateStringMap, widgetFields) {
|
8974
8935
|
if (!keys || !invertedDateStringMap) {
|
8975
8936
|
return;
|
@@ -9230,8 +9191,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9230
9191
|
let res = highchartsRenderer.updateSelectedOverrideValues(widget_obj, override_values, row_data);
|
9231
9192
|
res = highchartsRenderer.convertUniqueDateValues(widget_obj, templates, res);
|
9232
9193
|
|
9233
|
-
res = highchartsRenderer.setNewFieldNames(res);
|
9234
|
-
|
9235
9194
|
if (widget_obj.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH) {
|
9236
9195
|
res = highchartsRenderer.addTotalsToWalkthroughRowData(widget_obj, res);
|
9237
9196
|
}
|
@@ -9758,8 +9717,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9758
9717
|
// TODO: remove it when fixed on BE side
|
9759
9718
|
highchartsRenderer.fixIncompatibleCalculatedValuesTotals = function(widget, res) {
|
9760
9719
|
|
9761
|
-
// if it is
|
9762
|
-
if (!
|
9720
|
+
// if it is empty response - just return unmodified
|
9721
|
+
if (!lodash.get(res, 'length')) return res;
|
9763
9722
|
|
9764
9723
|
const calculatedValuesInValsCount = lodash.filter(
|
9765
9724
|
widget.calculated_values, calcVal => lodash.some(widget.vals, { field: calcVal.field })
|
package/src/pivottable.js
CHANGED
@@ -22,10 +22,7 @@ let initPivotTable = function($, window, document) {
|
|
22
22
|
}
|
23
23
|
return x1 + x2;
|
24
24
|
};
|
25
|
-
|
26
|
-
if (document.ReportHippo && document.ReportHippo && document.ReportHippo.user) {
|
27
|
-
useTotalsCalculation = _.includes(document.ReportHippo.user.features, 'enable_server_totals_calculation');
|
28
|
-
}
|
25
|
+
|
29
26
|
numberFormat = function(opts) {
|
30
27
|
var defaults;
|
31
28
|
defaults = {
|
@@ -715,7 +712,7 @@ let initPivotTable = function($, window, document) {
|
|
715
712
|
PivotData.forEachRecord(this.input, this.derivedAttributes, (function(_this) {
|
716
713
|
return function(record) {
|
717
714
|
if (_this.filter(record)) {
|
718
|
-
return _this.processRecord(record
|
715
|
+
return _this.processRecord(record);
|
719
716
|
}
|
720
717
|
};
|
721
718
|
})(this));
|
@@ -1969,15 +1969,7 @@ describe('highcharts_renderer', () => {
|
|
1969
1969
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
1970
1970
|
});
|
1971
1971
|
|
1972
|
-
it('Value should be a
|
1973
|
-
highchartsRenderer.useTotalsCalculation = false;
|
1974
|
-
aggregatorObject.push({Profit: 10});
|
1975
|
-
aggregatorObject.push({Profit: 20});
|
1976
|
-
expect(aggregatorObject.sum).toEqual(30);
|
1977
|
-
});
|
1978
|
-
|
1979
|
-
it('Value should be a last record value when server calculation enabled', () => {
|
1980
|
-
highchartsRenderer.useTotalsCalculation = true;
|
1972
|
+
it('Value should be a last record value', () => {
|
1981
1973
|
aggregatorObject.push({Profit: 10});
|
1982
1974
|
aggregatorObject.push({Profit: 20});
|
1983
1975
|
expect(aggregatorObject.sum).toEqual(20);
|
@@ -2178,15 +2170,7 @@ describe('highcharts_renderer', () => {
|
|
2178
2170
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
2179
2171
|
});
|
2180
2172
|
|
2181
|
-
it('Value should be a
|
2182
|
-
highchartsRenderer.useTotalsCalculation = false;
|
2183
|
-
aggregatorObject.push({Profit: 10});
|
2184
|
-
aggregatorObject.push({Profit: 20});
|
2185
|
-
expect(aggregatorObject.sum).toEqual(30);
|
2186
|
-
});
|
2187
|
-
|
2188
|
-
it('Value should be a last record value when server calculation enabled', () => {
|
2189
|
-
highchartsRenderer.useTotalsCalculation = true;
|
2173
|
+
it('Value should be a last record value', () => {
|
2190
2174
|
aggregatorObject.push({Profit: 10});
|
2191
2175
|
aggregatorObject.push({Profit: 20});
|
2192
2176
|
expect(aggregatorObject.sum).toEqual(20);
|
@@ -2379,13 +2363,6 @@ describe('highcharts_renderer', () => {
|
|
2379
2363
|
expect(aggregatorObject.formated_values).toEqual(['$123.12', 456.456, 789.789]);
|
2380
2364
|
});
|
2381
2365
|
|
2382
|
-
// it('Value should be a sum of records when server calculation disabled', () => {
|
2383
|
-
// highchartsRenderer.useTotalsCalculation = false;
|
2384
|
-
// aggregatorObject.push({Profit: 10});
|
2385
|
-
// aggregatorObject.push({Profit: 20});
|
2386
|
-
// expect(aggregatorObject.sum).toEqual(30);
|
2387
|
-
// });
|
2388
|
-
|
2389
2366
|
it('Value must be ignored if calculated totals disabled', () => {
|
2390
2367
|
const options = {
|
2391
2368
|
chartOptions: {
|
@@ -2541,16 +2518,7 @@ describe('highcharts_renderer', () => {
|
|
2541
2518
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
2542
2519
|
});
|
2543
2520
|
|
2544
|
-
it('Value should be a
|
2545
|
-
highchartsRenderer.useTotalsCalculation = false;
|
2546
|
-
aggregatorObject.push({Profit: 10});
|
2547
|
-
aggregatorObject.push({Profit: 20});
|
2548
|
-
expect(aggregatorObject.sum).toEqual(30);
|
2549
|
-
expect(aggregatorObject.len).toEqual(2);
|
2550
|
-
});
|
2551
|
-
|
2552
|
-
it('Value should be a last record value when server calculation enabled', () => {
|
2553
|
-
highchartsRenderer.useTotalsCalculation = true;
|
2521
|
+
it('Value should be a last record value', () => {
|
2554
2522
|
aggregatorObject.push({Profit: 20});
|
2555
2523
|
aggregatorObject.push({Profit: 10});
|
2556
2524
|
expect(aggregatorObject.sum).toEqual(10);
|
@@ -2615,17 +2583,10 @@ describe('highcharts_renderer', () => {
|
|
2615
2583
|
expect(aggregatorObject.value()).toBe(null);
|
2616
2584
|
});
|
2617
2585
|
|
2618
|
-
it('Should return sum
|
2619
|
-
highchartsRenderer.useTotalsCalculation = true;
|
2586
|
+
it('Should return sum', () => {
|
2620
2587
|
aggregatorObject.ignoreValue = false;
|
2621
2588
|
expect(aggregatorObject.value()).toBe(20);
|
2622
2589
|
});
|
2623
|
-
|
2624
|
-
it('Should return average if server calculation disabled', () => {
|
2625
|
-
highchartsRenderer.useTotalsCalculation = false;
|
2626
|
-
aggregatorObject.ignoreValue = false;
|
2627
|
-
expect(aggregatorObject.value()).toBe(5);
|
2628
|
-
});
|
2629
2590
|
});
|
2630
2591
|
|
2631
2592
|
describe('Format method', () => {
|
@@ -2761,15 +2722,7 @@ describe('highcharts_renderer', () => {
|
|
2761
2722
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
2762
2723
|
});
|
2763
2724
|
|
2764
|
-
it('Value should be a
|
2765
|
-
highchartsRenderer.useTotalsCalculation = false;
|
2766
|
-
aggregatorObject.push({Profit: 10});
|
2767
|
-
aggregatorObject.push({Profit: 20});
|
2768
|
-
expect(aggregatorObject.val).toEqual(10);
|
2769
|
-
});
|
2770
|
-
|
2771
|
-
it('Value should be a last record value when server calculation enabled', () => {
|
2772
|
-
highchartsRenderer.useTotalsCalculation = true;
|
2725
|
+
it('Value should be a last record value', () => {
|
2773
2726
|
aggregatorObject.push({Profit: 10});
|
2774
2727
|
aggregatorObject.push({Profit: 20});
|
2775
2728
|
expect(aggregatorObject.val).toEqual(20);
|
@@ -2971,15 +2924,7 @@ describe('highcharts_renderer', () => {
|
|
2971
2924
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
2972
2925
|
});
|
2973
2926
|
|
2974
|
-
it('Value should be a
|
2975
|
-
highchartsRenderer.useTotalsCalculation = false;
|
2976
|
-
aggregatorObject.push({Profit: 20});
|
2977
|
-
aggregatorObject.push({Profit: 10});
|
2978
|
-
expect(aggregatorObject.val).toEqual(20);
|
2979
|
-
});
|
2980
|
-
|
2981
|
-
it('Value should be a last record value when server calculation enabled', () => {
|
2982
|
-
highchartsRenderer.useTotalsCalculation = true;
|
2927
|
+
it('Value should be a last record value', () => {
|
2983
2928
|
aggregatorObject.push({Profit: 20});
|
2984
2929
|
aggregatorObject.push({Profit: 10});
|
2985
2930
|
expect(aggregatorObject.val).toEqual(10);
|
@@ -4473,44 +4418,6 @@ describe('highcharts_renderer', () => {
|
|
4473
4418
|
});
|
4474
4419
|
});
|
4475
4420
|
|
4476
|
-
describe('function setNewFieldNames', () => {
|
4477
|
-
beforeEach(() => {
|
4478
|
-
highchartsRenderer.useTotalsCalculation = false;
|
4479
|
-
});
|
4480
|
-
|
4481
|
-
it('should return the input if useTotalsCalculation is true', () => {
|
4482
|
-
const res = [{ DR_Values: 'value1' }, { DR_Values: 'value2' }];
|
4483
|
-
highchartsRenderer.useTotalsCalculation = true;
|
4484
|
-
const result = highchartsRenderer.setNewFieldNames(res);
|
4485
|
-
|
4486
|
-
expect(result).toEqual(res);
|
4487
|
-
});
|
4488
|
-
|
4489
|
-
it('should update DR_Values field names', () => {
|
4490
|
-
const res = [{ DR_Values: 'DR_Values' }, { DR_Values: 'value2' }];
|
4491
|
-
const expected = [{ DR_Values: 'Values' }, { DR_Values: 'value2' }];
|
4492
|
-
const result = highchartsRenderer.setNewFieldNames(res);
|
4493
|
-
|
4494
|
-
expect(result).toEqual(expected);
|
4495
|
-
});
|
4496
|
-
|
4497
|
-
it('should handle empty input', () => {
|
4498
|
-
const res = null;
|
4499
|
-
const expected = null;
|
4500
|
-
const result = highchartsRenderer.setNewFieldNames(res);
|
4501
|
-
|
4502
|
-
expect(result).toEqual(expected);
|
4503
|
-
});
|
4504
|
-
|
4505
|
-
it('should handle empty DR_Values array in input', () => {
|
4506
|
-
const res = [{}];
|
4507
|
-
const expected = [{ DR_Values: undefined }];
|
4508
|
-
const result = highchartsRenderer.setNewFieldNames(res);
|
4509
|
-
|
4510
|
-
expect(result).toEqual(expected);
|
4511
|
-
});
|
4512
|
-
});
|
4513
|
-
|
4514
4421
|
describe('function getOptionsForLegends', () => {
|
4515
4422
|
const rowAttrsLength = 1;
|
4516
4423
|
let additionOptions;
|
@@ -6313,10 +6220,11 @@ describe('highcharts_renderer', () => {
|
|
6313
6220
|
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData);
|
6314
6221
|
expect(csvJson).toEqual(
|
6315
6222
|
[
|
6316
|
-
[1651363200, 1652400000, 1653177600, 1653955200, '
|
6317
|
-
[
|
6223
|
+
[ 1651363200, 1652400000, 1653177600, 1653955200, 'Totals' ],
|
6224
|
+
[ undefined, undefined, undefined, undefined, 'Totals' ],
|
6318
6225
|
[],
|
6319
|
-
[1, 1, 1, 1, 2
|
6226
|
+
[ 1, 1, 1, 1, 2 ],
|
6227
|
+
[ 1, 1, 1, 1, 2 ]
|
6320
6228
|
]
|
6321
6229
|
);
|
6322
6230
|
});
|