@datarailsshared/dr_renderer 1.2.321 → 1.2.323-dragons
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 +3 -3
- package/src/highcharts_renderer.js +176 -227
- package/src/pivottable.js +17 -4
- package/tests/highcharts_renderer.test.js +0 -301
package/package.json
CHANGED
package/src/dr_pivottable.js
CHANGED
@@ -199,10 +199,11 @@ let initDRPivotTable = function($, window, document) {
|
|
199
199
|
let flatColKey = colKey.join(delim);
|
200
200
|
|
201
201
|
if (this.keysLength === rowKey.length + colKey.length) {
|
202
|
-
|
202
|
+
const isDrValuesRows = this.rowAttrs.length === 1 && this.rowAttrs[0] === 'DR_Values';
|
203
|
+
if ((!this.isKeysSortingDoneOnBackendSide || isDrValuesRows) && !this.rowKeys.some(rKey => rKey.join(delim) === flatRowKey)) {
|
203
204
|
this.rowKeys.push(rowKey);
|
204
205
|
}
|
205
|
-
if (!this.colKeys.some(cKey => cKey.join(delim) === flatColKey)) {
|
206
|
+
if (!this.isKeysSortingDoneOnBackendSide && !this.colKeys.some(cKey => cKey.join(delim) === flatColKey)) {
|
206
207
|
this.colKeys.push(colKey);
|
207
208
|
}
|
208
209
|
}
|
@@ -234,7 +235,6 @@ let initDRPivotTable = function($, window, document) {
|
|
234
235
|
insight: insight,
|
235
236
|
});
|
236
237
|
}
|
237
|
-
|
238
238
|
return;
|
239
239
|
}
|
240
240
|
|
@@ -139,11 +139,6 @@ const CHART_AXIS_DEFAULT_LABEL = 'Axis (Category)';
|
|
139
139
|
|
140
140
|
const CHART_LEGEND_DEFAULT_LABEL = 'Legend (Series)';
|
141
141
|
|
142
|
-
const FEATURES = {
|
143
|
-
ENABLE_NEW_WIDGET_VALUE_FORMATTING: 'enable_new_widget_value_formatting',
|
144
|
-
ENABLE_SERVER_TOTALS_CALCULATION: 'enable_server_totals_calculation',
|
145
|
-
}
|
146
|
-
|
147
142
|
let getHighchartsRenderer = function ($, document, Highcharts, default_colors, highchartsRenderer,
|
148
143
|
DataFormatter, lodash, moment_lib, isNewAngular) {
|
149
144
|
|
@@ -171,12 +166,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
171
166
|
lodash.assign(highchartsRenderer, HIGHCHARTS_CONSTANTS);
|
172
167
|
|
173
168
|
highchartsRenderer.useTotalsCalculation = false;
|
174
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
175
169
|
let disableAnimation = false;
|
176
170
|
if (document.ReportHippo && document.ReportHippo && document.ReportHippo.user) {
|
177
|
-
highchartsRenderer.useTotalsCalculation = lodash.includes(document.ReportHippo.user.features,
|
171
|
+
highchartsRenderer.useTotalsCalculation = lodash.includes(document.ReportHippo.user.features, 'enable_server_totals_calculation');
|
178
172
|
disableAnimation = document.ReportHippo.user.organization && document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.disable_animation
|
179
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = lodash.includes(document.ReportHippo.user.features, FEATURES.ENABLE_NEW_WIDGET_VALUE_FORMATTING);
|
180
173
|
}
|
181
174
|
|
182
175
|
// fix issue of use tootip.stickOnContact with tooltip.outside , source: https://github.com/highcharts/highcharts/pull/15960
|
@@ -635,7 +628,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
635
628
|
// do nothing
|
636
629
|
}
|
637
630
|
}
|
638
|
-
return $.pivotUtilities.getFormattedNumber(value, null, opts)
|
631
|
+
return $.pivotUtilities.getFormattedNumber(value, null, opts);
|
639
632
|
};
|
640
633
|
return func;
|
641
634
|
};
|
@@ -1157,6 +1150,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1157
1150
|
ob.name = row_n_value.join(highchartsRenderer.delimer)
|
1158
1151
|
.replace(highchartsRenderer.DR_OTHERS_KEY, othersName);
|
1159
1152
|
}
|
1153
|
+
|
1160
1154
|
lodash.forEach(col_n_keys, function (col_n_value, index) {
|
1161
1155
|
var agg = pivotData.getAggregator(row_n_value, col_n_value);
|
1162
1156
|
var val = agg.value();
|
@@ -1398,6 +1392,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1398
1392
|
if (opts.trendLine) {
|
1399
1393
|
const a = ((ySum * squareXSum) - (xSum * xySum)) / ((n * squareXSum) - (xSum * xSum));
|
1400
1394
|
const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
|
1395
|
+
|
1401
1396
|
const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
|
1402
1397
|
trendSeries.className = 'trendSeries';
|
1403
1398
|
trendSeries.name = highchartsRenderer.getTrendSeriesName(trendSeries);
|
@@ -1408,6 +1403,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1408
1403
|
if (colors && colors[i]) {
|
1409
1404
|
trendSeries.color = colors[i];
|
1410
1405
|
}
|
1406
|
+
|
1411
1407
|
trendSerieses.push(trendSeries);
|
1412
1408
|
}
|
1413
1409
|
i++;
|
@@ -1424,6 +1420,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1424
1420
|
}
|
1425
1421
|
|
1426
1422
|
let weights = { line: 2,spline: 3 ,area:-2, areaspline: -1, scatter:4, column: 1 };
|
1423
|
+
|
1427
1424
|
if (opts.comboOptions && lodash.includes(chartType,'combo') && !lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
|
1428
1425
|
chart_series.forEach((series, seriesIndex) => {
|
1429
1426
|
const savedSeriesOption = lodash.find(opts.comboOptions.seriesOptions, {series: series.name});
|
@@ -1510,6 +1507,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1510
1507
|
const chart_series = [];
|
1511
1508
|
const row_n_keys = pivotData.getRowKeys();
|
1512
1509
|
const col_n_keys = pivotData.getColKeys();
|
1510
|
+
const rows_by_cols = pivotData.rowKeysByCols;
|
1513
1511
|
|
1514
1512
|
let resultObject = {
|
1515
1513
|
data: [],
|
@@ -1538,7 +1536,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1538
1536
|
});
|
1539
1537
|
|
1540
1538
|
if (col_index !== col_n_keys.length - 1) {
|
1541
|
-
|
1539
|
+
|
1540
|
+
const rowKeys = rows_by_cols ? rows_by_cols[col_index] : row_n_keys;
|
1541
|
+
lodash.forEach(rowKeys, function (row_n_value) {
|
1542
1542
|
const agg = pivotData.getAggregator(row_n_value, col_n_value);
|
1543
1543
|
let val = agg.value();
|
1544
1544
|
|
@@ -3890,11 +3890,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3890
3890
|
|
3891
3891
|
highchartsRenderer.rhPivotCount = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
3892
3892
|
var attr = arg[0];
|
3893
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
3894
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
3895
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
3896
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
3897
|
-
|
3898
3893
|
return function (data, rowKey, colKey) {
|
3899
3894
|
return {
|
3900
3895
|
sum: 0,
|
@@ -3906,10 +3901,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3906
3901
|
calculated_formats: calculated_info.formats,
|
3907
3902
|
isChangeable: false,
|
3908
3903
|
push: function (record) {
|
3909
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
3910
|
-
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
3911
|
-
}
|
3912
|
-
|
3913
3904
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
3914
3905
|
this.data_types = this.data_types.concat(record['data_types']);
|
3915
3906
|
this.data_types = lodash.uniq(this.data_types);
|
@@ -3954,11 +3945,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3954
3945
|
number_format = 'General';
|
3955
3946
|
}
|
3956
3947
|
|
3957
|
-
if (this.widget_values_format
|
3958
|
-
number_format = this.widget_values_format;
|
3959
|
-
}
|
3960
|
-
|
3961
|
-
if (isCustomValuesFormat) {
|
3948
|
+
if (this.widget_values_format) {
|
3962
3949
|
number_format = this.widget_values_format;
|
3963
3950
|
}
|
3964
3951
|
|
@@ -4046,11 +4033,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4046
4033
|
|
4047
4034
|
highchartsRenderer.rhPivotAggregatorSum = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4048
4035
|
var attr = arg[0];
|
4049
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
4050
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
4051
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
4052
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4053
|
-
|
4054
4036
|
return function (data, rowKey, colKey) {
|
4055
4037
|
return {
|
4056
4038
|
sum: 0,
|
@@ -4071,11 +4053,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4071
4053
|
}
|
4072
4054
|
}
|
4073
4055
|
var val = parseFloat(record[attr]);
|
4074
|
-
|
4075
4056
|
if (!isNaN(val)) {
|
4076
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4077
|
-
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
4078
|
-
}
|
4079
4057
|
|
4080
4058
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
4081
4059
|
this.data_types = this.data_types.concat(record['data_types']);
|
@@ -4122,16 +4100,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4122
4100
|
number_format = 'General';
|
4123
4101
|
}
|
4124
4102
|
|
4125
|
-
if (this.widget_values_format
|
4103
|
+
if (this.widget_values_format) {
|
4126
4104
|
number_format = this.widget_values_format;
|
4127
4105
|
}
|
4128
4106
|
|
4129
|
-
if (isCustomValuesFormat) {
|
4130
|
-
number_format = this.widget_values_format;
|
4131
|
-
}
|
4132
4107
|
number_format = highchartsRenderer.getCalculatedValueFormat(this.calculated_formats, rowKey, colKey) || number_format;
|
4133
|
-
var formated_value = highchartsRenderer.formatValue('n', number_format, x)
|
4134
4108
|
|
4109
|
+
var formated_value = highchartsRenderer.formatValue('n', number_format, x)
|
4135
4110
|
if (formated_value && formated_value.hasOwnProperty('value') && formated_value.value != null) {
|
4136
4111
|
return formated_value.value;
|
4137
4112
|
} else {
|
@@ -4146,11 +4121,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4146
4121
|
|
4147
4122
|
highchartsRenderer.rhPivotAggregatorMin = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4148
4123
|
var attr = arg[0];
|
4149
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
4150
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
4151
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
4152
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4153
|
-
|
4154
4124
|
return function (data, rowKey, colKey) {
|
4155
4125
|
return {
|
4156
4126
|
val: null,
|
@@ -4174,10 +4144,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4174
4144
|
var ref, x;
|
4175
4145
|
x = parseFloat(record[attr]);
|
4176
4146
|
if (!isNaN(x)) {
|
4177
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4178
|
-
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
4179
|
-
}
|
4180
|
-
|
4181
4147
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
4182
4148
|
this.data_types = this.data_types.concat(record['data_types']);
|
4183
4149
|
this.data_types = lodash.uniq(this.data_types);
|
@@ -4220,11 +4186,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4220
4186
|
number_format = 'General';
|
4221
4187
|
}
|
4222
4188
|
|
4223
|
-
if (this.widget_values_format
|
4224
|
-
number_format = this.widget_values_format;
|
4225
|
-
}
|
4226
|
-
|
4227
|
-
if (isCustomValuesFormat) {
|
4189
|
+
if (this.widget_values_format) {
|
4228
4190
|
number_format = this.widget_values_format;
|
4229
4191
|
}
|
4230
4192
|
|
@@ -4245,11 +4207,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4245
4207
|
|
4246
4208
|
highchartsRenderer.rhPivotAggregatorMax = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4247
4209
|
var attr = arg[0];
|
4248
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
4249
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
4250
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
4251
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4252
|
-
|
4253
4210
|
return function (data, rowKey, colKey) {
|
4254
4211
|
return {
|
4255
4212
|
val: null,
|
@@ -4273,10 +4230,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4273
4230
|
var ref, x;
|
4274
4231
|
x = parseFloat(record[attr]);
|
4275
4232
|
if (!isNaN(x)) {
|
4276
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4277
|
-
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
4278
|
-
}
|
4279
|
-
|
4280
4233
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
4281
4234
|
this.data_types = this.data_types.concat(record['data_types']);
|
4282
4235
|
this.data_types = lodash.uniq(this.data_types);
|
@@ -4320,11 +4273,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4320
4273
|
number_format = 'General';
|
4321
4274
|
}
|
4322
4275
|
|
4323
|
-
if (this.widget_values_format
|
4324
|
-
number_format = this.widget_values_format;
|
4325
|
-
}
|
4326
|
-
|
4327
|
-
if (isCustomValuesFormat) {
|
4276
|
+
if (this.widget_values_format) {
|
4328
4277
|
number_format = this.widget_values_format;
|
4329
4278
|
}
|
4330
4279
|
|
@@ -4345,11 +4294,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4345
4294
|
|
4346
4295
|
highchartsRenderer.rhPivotAggregatorAverage = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4347
4296
|
var attr = arg[0];
|
4348
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
4349
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
4350
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
4351
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4352
|
-
|
4353
4297
|
return function (data, rowKey, colKey) {
|
4354
4298
|
return {
|
4355
4299
|
sum: 0,
|
@@ -4374,10 +4318,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4374
4318
|
var ref, x;
|
4375
4319
|
x = parseFloat(record[attr]);
|
4376
4320
|
if (!isNaN(x)) {
|
4377
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4378
|
-
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
4379
|
-
}
|
4380
|
-
|
4381
4321
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
4382
4322
|
this.data_types = this.data_types.concat(record['data_types']);
|
4383
4323
|
this.data_types = lodash.uniq(this.data_types);
|
@@ -4427,11 +4367,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4427
4367
|
number_format = 'General';
|
4428
4368
|
}
|
4429
4369
|
|
4430
|
-
if (this.widget_values_format
|
4431
|
-
number_format = this.widget_values_format;
|
4432
|
-
}
|
4433
|
-
|
4434
|
-
if (isCustomValuesFormat) {
|
4370
|
+
if (this.widget_values_format) {
|
4435
4371
|
number_format = this.widget_values_format;
|
4436
4372
|
}
|
4437
4373
|
|
@@ -4778,17 +4714,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4778
4714
|
opts.rendererOptions.onlyOptions = true;
|
4779
4715
|
}
|
4780
4716
|
|
4781
|
-
|
4782
|
-
lodash.
|
4783
|
-
|
4784
|
-
|
4785
|
-
|
4786
|
-
|
4787
|
-
|
4788
|
-
|
4789
|
-
|
4790
|
-
|
4791
|
-
|
4717
|
+
if (!highchartsRenderer.isSortingOnBackendEnabled()) {
|
4718
|
+
const sortByValueSettings = lodash.filter(
|
4719
|
+
lodash.get(widget, 'options.sortingFields', []),
|
4720
|
+
sortingField => lodash.includes(['field_values', 'variance'], lodash.get(sortingField, 'sorting.sort_by'))
|
4721
|
+
);
|
4722
|
+
|
4723
|
+
if (sortByValueSettings.length) {
|
4724
|
+
pivotData.sortByValueAttrs = lodash.map(sortByValueSettings, fieldSorting => fieldSorting.name);
|
4725
|
+
let new_sorting_function = highchartsRenderer.generateSortingFunctionByValues(sortByValueSettings, pivotData, opts, widget);
|
4726
|
+
opts.sorters = new_sorting_function;
|
4727
|
+
optsFiltered.sorters = new_sorting_function;
|
4728
|
+
pivotData.sorters = new_sorting_function;
|
4729
|
+
}
|
4792
4730
|
}
|
4793
4731
|
|
4794
4732
|
result = opts.renderer(pivotData, opts.rendererOptions);
|
@@ -4842,6 +4780,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4842
4780
|
rows: lodash.map(pivotOptions.legendArray, 'name'),
|
4843
4781
|
rendererOptions: widget.options,
|
4844
4782
|
dateValuesDictionary: pivotOptions ? pivotOptions.dateValuesDictionary : null,
|
4783
|
+
keysObject: pivotOptions ? pivotOptions.keysObject : null,
|
4845
4784
|
};
|
4846
4785
|
|
4847
4786
|
if (!subopts.rendererOptions) {
|
@@ -8710,6 +8649,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8710
8649
|
};
|
8711
8650
|
|
8712
8651
|
highchartsRenderer.getWidgetDataSorters = function (res, widget, defaultDateFormat) {
|
8652
|
+
let sorters;
|
8653
|
+
|
8713
8654
|
if ($.pivotUtilities && !$.pivotUtilities.additionalFieldsList) {
|
8714
8655
|
$.pivotUtilities.additionalFieldsList = [
|
8715
8656
|
{key: 'DR_Average', name: 'DR_Average'},
|
@@ -8717,32 +8658,20 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8717
8658
|
];
|
8718
8659
|
}
|
8719
8660
|
|
8720
|
-
|
8661
|
+
let datesFields = [];
|
8721
8662
|
datesFields = lodash.filter(widget.rows, element => element.type == 'Date');
|
8722
8663
|
datesFields = datesFields.concat(lodash.filter(widget.cols, element => element.type == 'Date'));
|
8723
|
-
|
8724
|
-
const isCustomSorting = widget.options.sortingFields && Array.isArray(widget.options.sortingFields) && widget.options.sortingFields.length > 0;
|
8725
|
-
if (isCustomSorting) {
|
8726
|
-
lodash.forEach(datesFields, function (field) {
|
8727
|
-
const fieldToSort = lodash.find(
|
8728
|
-
widget.options.sortingFields, element => element.id === field.id && lodash.get(element, 'sorting.sort_by') === 'field_items'
|
8729
|
-
);
|
8730
|
-
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
8731
|
-
});
|
8732
|
-
}
|
8733
|
-
|
8734
8664
|
datesFields = lodash.map(datesFields, function (row) {
|
8735
8665
|
return { "format": highchartsRenderer.getDateFieldFormat(widget, row), "name": row.name, "type": row.type, "values": [], "sorting": row.sorting } //'MMM - yyyy' format
|
8736
8666
|
});
|
8737
8667
|
|
8738
|
-
var data = res;
|
8739
|
-
|
8740
8668
|
lodash.forEach(datesFields, function (row) {
|
8741
8669
|
row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
|
8742
8670
|
});
|
8743
8671
|
|
8744
8672
|
if (datesFields.length > 0) {
|
8745
|
-
|
8673
|
+
const invertedDateStringMap = {};
|
8674
|
+
lodash.forEach(res, function (element) {
|
8746
8675
|
for (var i in datesFields) {
|
8747
8676
|
if (element.hasOwnProperty(datesFields[i].name)) {
|
8748
8677
|
datesFields[i].values.push(element[datesFields[i].name]);
|
@@ -8755,125 +8684,156 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8755
8684
|
widget.pivot.dateValuesDictionary = {}
|
8756
8685
|
}
|
8757
8686
|
widget.pivot.dateValuesDictionary[dateStringValue] = element[datesFields[i].name];
|
8687
|
+
invertedDateStringMap[element[datesFields[i].name]] = dateStringValue;
|
8758
8688
|
}
|
8759
8689
|
element[datesFields[i].name] = dateStringValue;
|
8760
8690
|
}
|
8761
8691
|
}
|
8762
8692
|
});
|
8693
|
+
|
8694
|
+
if (highchartsRenderer.isSortingOnBackendEnabled()) {
|
8695
|
+
lodash.forEach(['col_keys', 'row_keys'], (keysListName, index) => {
|
8696
|
+
const widgetFields = index ? widget.rows : widget.cols;
|
8697
|
+
const uniqueFormattedKeysList = [];
|
8698
|
+
lodash.forEach(widget.pivot.keysObject[keysListName], subKeysList => {
|
8699
|
+
lodash.forEach(subKeysList, (key, index) => {
|
8700
|
+
if (widgetFields[index].type === 'Date') {
|
8701
|
+
subKeysList[index] = invertedDateStringMap[key] || key;
|
8702
|
+
}
|
8703
|
+
});
|
8704
|
+
if (!lodash.find(uniqueFormattedKeysList, formattedSubKeys => lodash.isEqual(formattedSubKeys, subKeysList))) {
|
8705
|
+
uniqueFormattedKeysList.push(subKeysList);
|
8706
|
+
}
|
8707
|
+
});
|
8708
|
+
widget.pivot.keysObject[keysListName] = uniqueFormattedKeysList;
|
8709
|
+
});
|
8710
|
+
}
|
8763
8711
|
}
|
8764
|
-
lodash.forEach(datesFields, function (row) {
|
8765
|
-
row.values = lodash.uniq(row.values);
|
8766
8712
|
|
8767
|
-
|
8768
|
-
|
8769
|
-
|
8770
|
-
|
8771
|
-
|
8713
|
+
if (!highchartsRenderer.isSortingOnBackendEnabled()) {
|
8714
|
+
const isCustomSorting = widget.options.sortingFields && Array.isArray(widget.options.sortingFields) && widget.options.sortingFields.length > 0;
|
8715
|
+
if (isCustomSorting) {
|
8716
|
+
lodash.forEach(datesFields, function (field) {
|
8717
|
+
const fieldToSort = lodash.find(
|
8718
|
+
widget.options.sortingFields, element => element.id === field.id && lodash.get(element, 'sorting.sort_by') === 'field_items'
|
8719
|
+
);
|
8720
|
+
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
8721
|
+
});
|
8722
|
+
}
|
8723
|
+
|
8724
|
+
lodash.forEach(datesFields, function (row) {
|
8725
|
+
row.values = lodash.uniq(row.values);
|
8726
|
+
|
8727
|
+
const isTimestampDateField = row.type === 'Date' && lodash.some(row.values, value => typeof value ==='number');
|
8728
|
+
if (isTimestampDateField) {
|
8729
|
+
const nullValueIndex = row.values.indexOf(NULL_VALUE);
|
8730
|
+
if (~nullValueIndex) {
|
8731
|
+
row.values.splice(nullValueIndex, 1);
|
8732
|
+
}
|
8733
|
+
row.values = row.values.sort((a, b) => a - b);
|
8734
|
+
if (~nullValueIndex) {
|
8735
|
+
row.values.push(NULL_VALUE);
|
8736
|
+
}
|
8737
|
+
} else {
|
8738
|
+
row.values = row.values.sort();
|
8772
8739
|
}
|
8773
|
-
|
8774
|
-
if (
|
8775
|
-
row.values.
|
8740
|
+
|
8741
|
+
if (row.sorting && row.sorting.type == "largestToSmallest") {
|
8742
|
+
row.values = lodash.reverse(row.values);
|
8776
8743
|
}
|
8777
|
-
|
8778
|
-
row.values = row.values
|
8779
|
-
|
8744
|
+
delete row.sorting;
|
8745
|
+
row.values = lodash.map(row.values, function (val) {
|
8746
|
+
return highchartsRenderer.returnRawDataValue(row.type, val, row.format, row.name, row.val_not_convert) + "";
|
8747
|
+
})
|
8748
|
+
|
8749
|
+
});
|
8780
8750
|
|
8781
|
-
|
8782
|
-
|
8751
|
+
/* date string */
|
8752
|
+
var rowsAndCols = [];
|
8753
|
+
rowsAndCols = widget.rows.concat(widget.cols);
|
8754
|
+
|
8755
|
+
if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
|
8756
|
+
|
8757
|
+
// if it is breakdown widget - redefine sorting according to breakdown_options
|
8758
|
+
// TODO: remove this when BE sort will be implemented
|
8759
|
+
lodash.forEach(rowsAndCols, function (field) {
|
8760
|
+
const waterfallFieldType = field.id === widget.cols[0].id ? 'totals' : 'breakdown';
|
8761
|
+
field.sorting = {
|
8762
|
+
type: 'CustomOrder',
|
8763
|
+
values: lodash.map(
|
8764
|
+
widget.options.breakdown_options.values[waterfallFieldType],
|
8765
|
+
value => value.key
|
8766
|
+
),
|
8767
|
+
};
|
8768
|
+
});
|
8769
|
+
} else if (isCustomSorting) {
|
8770
|
+
lodash.forEach(rowsAndCols, function (field) {
|
8771
|
+
const fieldToSort = lodash.find(
|
8772
|
+
widget.options.sortingFields, element => element.id === field.id && lodash.get(element, 'sorting.sort_by') === 'field_items'
|
8773
|
+
);
|
8774
|
+
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
8775
|
+
});
|
8783
8776
|
}
|
8784
|
-
delete row.sorting;
|
8785
|
-
row.values = lodash.map(row.values, function (val) {
|
8786
|
-
return highchartsRenderer.returnRawDataValue(row.type, val, row.format, row.name, row.val_not_convert) + "";
|
8787
|
-
})
|
8788
|
-
|
8789
|
-
});
|
8790
|
-
|
8791
|
-
/* date string */
|
8792
|
-
var rowsAndCols = [];
|
8793
|
-
rowsAndCols = widget.rows.concat(widget.cols);
|
8794
8777
|
|
8795
|
-
if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
|
8796
|
-
|
8797
|
-
// if it is breakdown widget - redefine sorting according to breakdown_options
|
8798
|
-
// TODO: remove this when BE sort will be implemented
|
8799
|
-
lodash.forEach(rowsAndCols, function (field) {
|
8800
|
-
const waterfallFieldType = field.id === widget.cols[0].id ? 'totals' : 'breakdown';
|
8801
|
-
field.sorting = {
|
8802
|
-
type: 'CustomOrder',
|
8803
|
-
values: lodash.map(
|
8804
|
-
widget.options.breakdown_options.values[waterfallFieldType],
|
8805
|
-
value => value.key
|
8806
|
-
),
|
8807
|
-
};
|
8808
|
-
});
|
8809
|
-
} else if (isCustomSorting) {
|
8810
8778
|
lodash.forEach(rowsAndCols, function (field) {
|
8811
|
-
|
8812
|
-
|
8813
|
-
|
8814
|
-
|
8815
|
-
|
8816
|
-
|
8817
|
-
|
8818
|
-
|
8819
|
-
|
8820
|
-
|
8821
|
-
|
8822
|
-
|
8823
|
-
|
8824
|
-
|
8779
|
+
if (field.sorting && (field.sorting.type == "DateString" || field.sorting.type == "largestToSmallest")) {
|
8780
|
+
var find_field = lodash.find(datesFields, {name: field.name});
|
8781
|
+
if (find_field) {
|
8782
|
+
if (find_field.type != 'Date')
|
8783
|
+
find_field.sorting = field.sorting;
|
8784
|
+
} else {
|
8785
|
+
datesFields.push({
|
8786
|
+
"format": field.format,
|
8787
|
+
"name": field.name,
|
8788
|
+
"type": field.type,
|
8789
|
+
"values": [],
|
8790
|
+
"sorting": field.sorting,
|
8791
|
+
});
|
8792
|
+
}
|
8793
|
+
} else if (field.sorting && field.sorting.type == "CustomOrder" && field.sorting.values) {
|
8825
8794
|
datesFields.push({
|
8826
8795
|
"format": field.format,
|
8827
8796
|
"name": field.name,
|
8828
8797
|
"type": field.type,
|
8829
|
-
"values":
|
8830
|
-
"sorting": field.sorting,
|
8798
|
+
"values": field.sorting.values
|
8831
8799
|
});
|
8832
8800
|
}
|
8833
|
-
}
|
8834
|
-
datesFields.push({
|
8835
|
-
"format": field.format,
|
8836
|
-
"name": field.name,
|
8837
|
-
"type": field.type,
|
8838
|
-
"values": field.sorting.values
|
8839
|
-
});
|
8840
|
-
}
|
8841
|
-
});
|
8842
|
-
|
8843
|
-
if (widget.vals && widget.vals.length > 1) {
|
8844
|
-
datesFields.push({name: "DR_Values", values: lodash.map(widget.vals, 'name')});
|
8845
|
-
}
|
8801
|
+
});
|
8846
8802
|
|
8847
|
-
|
8848
|
-
|
8849
|
-
// TODO: Remove. sortingValues looks like lagacy which is not in use neither in webclient nor in renderer
|
8850
|
-
if (widget.options && widget.options.sortingValues) {
|
8851
|
-
var field = lodash.find(datesFields, {name: widget.options.sortingValues.field});
|
8852
|
-
if (field) {
|
8853
|
-
field.values = widget.options.sortingValues.values;
|
8854
|
-
field.sorting = null;
|
8855
|
-
} else {
|
8856
|
-
datesFields.push({
|
8857
|
-
name: widget.options.sortingValues.field,
|
8858
|
-
values: widget.options.sortingValues.values
|
8859
|
-
});
|
8803
|
+
if (widget.vals && widget.vals.length > 1) {
|
8804
|
+
datesFields.push({name: "DR_Values", values: lodash.map(widget.vals, 'name')});
|
8860
8805
|
}
|
8861
|
-
|
8862
|
-
|
8863
|
-
|
8864
|
-
|
8865
|
-
if (
|
8866
|
-
|
8867
|
-
|
8868
|
-
|
8869
|
-
|
8870
|
-
return $.pivotUtilities.largeToSmallSortByAbsolute;
|
8871
|
-
|
8872
|
-
return $.pivotUtilities.largeToSmallSort;
|
8806
|
+
|
8807
|
+
/****** END *******/
|
8808
|
+
|
8809
|
+
// TODO: Remove. sortingValues looks like lagacy which is not in use neither in webclient nor in renderer
|
8810
|
+
if (widget.options && widget.options.sortingValues) {
|
8811
|
+
var field = lodash.find(datesFields, {name: widget.options.sortingValues.field});
|
8812
|
+
if (field) {
|
8813
|
+
field.values = widget.options.sortingValues.values;
|
8814
|
+
field.sorting = null;
|
8873
8815
|
} else {
|
8874
|
-
|
8816
|
+
datesFields.push({
|
8817
|
+
name: widget.options.sortingValues.field,
|
8818
|
+
values: widget.options.sortingValues.values
|
8819
|
+
});
|
8875
8820
|
}
|
8876
|
-
|
8821
|
+
}
|
8822
|
+
sorters = function (attr) {
|
8823
|
+
var field = lodash.find(datesFields, {name: attr});
|
8824
|
+
if (field)
|
8825
|
+
if (field.sorting && field.sorting.type == "DateString") {
|
8826
|
+
return $.pivotUtilities.sortDateStrings(field.sorting.month_order);
|
8827
|
+
} else if (field.sorting && field.sorting.type == "largestToSmallest") {
|
8828
|
+
if (field.sorting.is_absolute)
|
8829
|
+
return $.pivotUtilities.largeToSmallSortByAbsolute;
|
8830
|
+
|
8831
|
+
return $.pivotUtilities.largeToSmallSort;
|
8832
|
+
} else {
|
8833
|
+
return $.pivotUtilities.sortAs(field.values);
|
8834
|
+
}
|
8835
|
+
};
|
8836
|
+
}
|
8877
8837
|
|
8878
8838
|
return sorters;
|
8879
8839
|
};
|
@@ -8893,6 +8853,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8893
8853
|
|
8894
8854
|
//highchartsRenderer.getGraphOptions(scope.data, override_values, res, scope.dataModel.templatesWithOutData, scope.openDrillDownList, drillDownFunction)
|
8895
8855
|
highchartsRenderer.getGraphOptions = function (widget_obj, override_values, row_data, templates, openDrillDownListFunction, drillDownFunction) {
|
8856
|
+
|
8857
|
+
let keysObject;
|
8858
|
+
if (highchartsRenderer.isSortingOnBackendEnabled()) {
|
8859
|
+
keysObject = row_data.pop();
|
8860
|
+
}
|
8861
|
+
|
8896
8862
|
let res = highchartsRenderer.updateSelectedOverrideValues(widget_obj, override_values, row_data);
|
8897
8863
|
res = highchartsRenderer.convertUniqueDateValues(widget_obj, templates, res);
|
8898
8864
|
|
@@ -8904,6 +8870,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8904
8870
|
|
8905
8871
|
let pivot = {};
|
8906
8872
|
|
8873
|
+
if (highchartsRenderer.isSortingOnBackendEnabled()) {
|
8874
|
+
pivot.keysObject = keysObject;
|
8875
|
+
}
|
8876
|
+
|
8907
8877
|
let templateNoData = lodash.find(templates, {id: widget_obj.template_id});
|
8908
8878
|
if (templateNoData) {
|
8909
8879
|
|
@@ -8940,6 +8910,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8940
8910
|
subopts.onlyOptions = true;
|
8941
8911
|
}
|
8942
8912
|
|
8913
|
+
subopts.keysObject = keysObject;
|
8914
|
+
|
8943
8915
|
let hc_options = highchartsRenderer.rhPivotView(res, subopts, is_table, widget_obj);
|
8944
8916
|
|
8945
8917
|
return hc_options;
|
@@ -9267,31 +9239,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9267
9239
|
}
|
9268
9240
|
}
|
9269
9241
|
|
9270
|
-
highchartsRenderer.
|
9271
|
-
|
9272
|
-
let formats = [];
|
9273
|
-
if (render_options && render_options.comboOptions && render_options.comboOptions.seriesOptions) {
|
9274
|
-
isSecondaryAxis = lodash.some(render_options.comboOptions.seriesOptions, series => series.secondaryAxis);
|
9275
|
-
formats = lodash.map(render_options.comboOptions.seriesOptions, series => series.format);
|
9276
|
-
}
|
9277
|
-
const isCustomFormat = !lodash.includes(formats, widget_values_format);
|
9278
|
-
|
9279
|
-
return { isSecondaryAxis, isCustomFormat }
|
9280
|
-
}
|
9281
|
-
|
9282
|
-
highchartsRenderer.getRecordFormats = function(render_options, recordName) {
|
9283
|
-
let formats = [];
|
9284
|
-
if (render_options && render_options.comboOptions && render_options.comboOptions.seriesOptions) {
|
9285
|
-
formats = render_options.comboOptions.seriesOptions
|
9286
|
-
.filter(series => series.series === recordName)
|
9287
|
-
.map(series => series.format);
|
9288
|
-
}
|
9289
|
-
return formats;
|
9290
|
-
}
|
9291
|
-
|
9292
|
-
highchartsRenderer.isCustomValuesFormat = function (render_options, widget_values_format) {
|
9293
|
-
const { isSecondaryAxis, isCustomFormat } = highchartsRenderer.checkFormats(render_options, widget_values_format);
|
9294
|
-
return highchartsRenderer.enabledNewWidgetValueFormatting && (isCustomFormat || !isSecondaryAxis);
|
9242
|
+
highchartsRenderer.isSortingOnBackendEnabled = function() {
|
9243
|
+
return lodash.includes(lodash.get(document, 'ReportHippo.user.features'), 'enable_server_widget_data_sorting');
|
9295
9244
|
}
|
9296
9245
|
|
9297
9246
|
return highchartsRenderer;
|
package/src/pivottable.js
CHANGED
@@ -686,8 +686,17 @@ let initPivotTable = function($, window, document) {
|
|
686
686
|
});
|
687
687
|
this.tree = {};
|
688
688
|
this.insights = [];
|
689
|
-
|
690
|
-
this.
|
689
|
+
|
690
|
+
this.isKeysSortingDoneOnBackendSide = opts.keysObject && typeof opts.keysObject === 'object';
|
691
|
+
if (this.isKeysSortingDoneOnBackendSide) {
|
692
|
+
this.rowKeys = opts.keysObject.row_keys;
|
693
|
+
this.colKeys = opts.keysObject.col_keys;
|
694
|
+
// TODO: add also for breakdown sort object when BE story is ready.
|
695
|
+
} else {
|
696
|
+
this.rowKeys = [];
|
697
|
+
this.colKeys = [];
|
698
|
+
}
|
699
|
+
|
691
700
|
this.rowTotals = {};
|
692
701
|
this.colTotals = {};
|
693
702
|
this.allTotal = this.aggregator(this, [], []);
|
@@ -852,12 +861,16 @@ let initPivotTable = function($, window, document) {
|
|
852
861
|
};
|
853
862
|
|
854
863
|
PivotData.prototype.getColKeys = function() {
|
855
|
-
this.
|
864
|
+
if (!this.isKeysSortingDoneOnBackendSide) {
|
865
|
+
this.sortKeys();
|
866
|
+
}
|
856
867
|
return this.colKeys;
|
857
868
|
};
|
858
869
|
|
859
870
|
PivotData.prototype.getRowKeys = function() {
|
860
|
-
this.
|
871
|
+
if (!this.isKeysSortingDoneOnBackendSide) {
|
872
|
+
this.sortKeys();
|
873
|
+
}
|
861
874
|
return this.rowKeys;
|
862
875
|
};
|
863
876
|
|
@@ -483,7 +483,6 @@ describe('highcharts_renderer', () => {
|
|
483
483
|
let opts;
|
484
484
|
|
485
485
|
beforeEach(() => {
|
486
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
487
486
|
funcContext = { y: '12345.678' };
|
488
487
|
opts = {}
|
489
488
|
});
|
@@ -1736,7 +1735,6 @@ describe('highcharts_renderer', () => {
|
|
1736
1735
|
});
|
1737
1736
|
|
1738
1737
|
it('Formats must be filled and uniq', () => {
|
1739
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
1740
1738
|
aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
|
1741
1739
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
1742
1740
|
});
|
@@ -1783,21 +1781,6 @@ describe('highcharts_renderer', () => {
|
|
1783
1781
|
aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
|
1784
1782
|
expect(aggregatorObject.ignoreValue).toBe(true);
|
1785
1783
|
});
|
1786
|
-
|
1787
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions', () => {
|
1788
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
1789
|
-
const options = {
|
1790
|
-
comboOptions: {
|
1791
|
-
seriesOptions: [
|
1792
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
1793
|
-
]
|
1794
|
-
}
|
1795
|
-
}
|
1796
|
-
aggregator = highchartsRenderer.rhPivotAggregatorSum(arg, widget_values_format, is_graph, options, calculated_info);
|
1797
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
1798
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
1799
|
-
expect(aggregatorObject.formats).toEqual(['\"$\"#,###.###']);
|
1800
|
-
});
|
1801
1784
|
});
|
1802
1785
|
|
1803
1786
|
describe('Value method', () => {
|
@@ -1848,22 +1831,6 @@ describe('highcharts_renderer', () => {
|
|
1848
1831
|
aggregatorObject = aggregator({}, ['Region average'], '');
|
1849
1832
|
expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
|
1850
1833
|
});
|
1851
|
-
|
1852
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions and widget_value_format to equal first seriesOptions format', () => {
|
1853
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
1854
|
-
widget_values_format = '\"$\"#,###.###';
|
1855
|
-
const options = {
|
1856
|
-
comboOptions: {
|
1857
|
-
seriesOptions: [
|
1858
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
1859
|
-
]
|
1860
|
-
}
|
1861
|
-
}
|
1862
|
-
aggregator = highchartsRenderer.rhPivotAggregatorSum(arg, widget_values_format, is_graph, options, calculated_info);
|
1863
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
1864
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
1865
|
-
expect(aggregatorObject.format(1123.45678, false)).toBe('$1,123.457');
|
1866
|
-
});
|
1867
1834
|
});
|
1868
1835
|
});
|
1869
1836
|
|
@@ -1945,7 +1912,6 @@ describe('highcharts_renderer', () => {
|
|
1945
1912
|
});
|
1946
1913
|
|
1947
1914
|
it('Formats must be filled and uniq', () => {
|
1948
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
1949
1915
|
aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
|
1950
1916
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
1951
1917
|
});
|
@@ -1992,21 +1958,6 @@ describe('highcharts_renderer', () => {
|
|
1992
1958
|
aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
|
1993
1959
|
expect(aggregatorObject.ignoreValue).toBe(true);
|
1994
1960
|
});
|
1995
|
-
|
1996
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions', () => {
|
1997
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
1998
|
-
const options = {
|
1999
|
-
comboOptions: {
|
2000
|
-
seriesOptions: [
|
2001
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
2002
|
-
]
|
2003
|
-
}
|
2004
|
-
}
|
2005
|
-
aggregator = highchartsRenderer.rhPivotCount(arg, widget_values_format, is_graph, options, calculated_info);
|
2006
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
2007
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
2008
|
-
expect(aggregatorObject.formats).toEqual(['\"$\"#,###.###']);
|
2009
|
-
});
|
2010
1961
|
});
|
2011
1962
|
|
2012
1963
|
describe('Value method', () => {
|
@@ -2057,22 +2008,6 @@ describe('highcharts_renderer', () => {
|
|
2057
2008
|
aggregatorObject = aggregator({}, ['Region average'], '');
|
2058
2009
|
expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
|
2059
2010
|
});
|
2060
|
-
|
2061
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions and widget_value_format to equal first seriesOptions format', () => {
|
2062
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
2063
|
-
widget_values_format = '\"$\"#,###.###';
|
2064
|
-
const options = {
|
2065
|
-
comboOptions: {
|
2066
|
-
seriesOptions: [
|
2067
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
2068
|
-
]
|
2069
|
-
}
|
2070
|
-
}
|
2071
|
-
aggregator = highchartsRenderer.rhPivotCount(arg, widget_values_format, is_graph, options, calculated_info);
|
2072
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
2073
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
2074
|
-
expect(aggregatorObject.format(1123.45678, false)).toBe('$1,123.457');
|
2075
|
-
});
|
2076
2011
|
});
|
2077
2012
|
});
|
2078
2013
|
|
@@ -2308,7 +2243,6 @@ describe('highcharts_renderer', () => {
|
|
2308
2243
|
});
|
2309
2244
|
|
2310
2245
|
it('Formats must be filled and uniq', () => {
|
2311
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
2312
2246
|
aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
|
2313
2247
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
2314
2248
|
});
|
@@ -2357,21 +2291,6 @@ describe('highcharts_renderer', () => {
|
|
2357
2291
|
aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
|
2358
2292
|
expect(aggregatorObject.ignoreValue).toBe(true);
|
2359
2293
|
});
|
2360
|
-
|
2361
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions', () => {
|
2362
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
2363
|
-
const options = {
|
2364
|
-
comboOptions: {
|
2365
|
-
seriesOptions: [
|
2366
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
2367
|
-
]
|
2368
|
-
}
|
2369
|
-
}
|
2370
|
-
aggregator = highchartsRenderer.rhPivotAggregatorAverage(arg, widget_values_format, is_graph, options, calculated_info);
|
2371
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
2372
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
2373
|
-
expect(aggregatorObject.formats).toEqual(['\"$\"#,###.###']);
|
2374
|
-
});
|
2375
2294
|
});
|
2376
2295
|
|
2377
2296
|
describe('Value method', () => {
|
@@ -2431,22 +2350,6 @@ describe('highcharts_renderer', () => {
|
|
2431
2350
|
aggregatorObject = aggregator({}, ['Region average'], '');
|
2432
2351
|
expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
|
2433
2352
|
});
|
2434
|
-
|
2435
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions and widget_value_format to equal first seriesOptions format', () => {
|
2436
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
2437
|
-
widget_values_format = '\"$\"#,###.###';
|
2438
|
-
const options = {
|
2439
|
-
comboOptions: {
|
2440
|
-
seriesOptions: [
|
2441
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
2442
|
-
]
|
2443
|
-
}
|
2444
|
-
}
|
2445
|
-
aggregator = highchartsRenderer.rhPivotAggregatorAverage(arg, widget_values_format, is_graph, options, calculated_info);
|
2446
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
2447
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
2448
|
-
expect(aggregatorObject.format(1123.45678, false)).toBe('$1,123.457');
|
2449
|
-
});
|
2450
2353
|
});
|
2451
2354
|
});
|
2452
2355
|
|
@@ -2528,7 +2431,6 @@ describe('highcharts_renderer', () => {
|
|
2528
2431
|
});
|
2529
2432
|
|
2530
2433
|
it('Formats must be filled and uniq', () => {
|
2531
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
2532
2434
|
aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
|
2533
2435
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
2534
2436
|
});
|
@@ -2575,21 +2477,6 @@ describe('highcharts_renderer', () => {
|
|
2575
2477
|
aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
|
2576
2478
|
expect(aggregatorObject.ignoreValue).toBe(true);
|
2577
2479
|
});
|
2578
|
-
|
2579
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions', () => {
|
2580
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
2581
|
-
const options = {
|
2582
|
-
comboOptions: {
|
2583
|
-
seriesOptions: [
|
2584
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
2585
|
-
]
|
2586
|
-
}
|
2587
|
-
}
|
2588
|
-
aggregator = highchartsRenderer.rhPivotAggregatorMin(arg, widget_values_format, is_graph, options, calculated_info);
|
2589
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
2590
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
2591
|
-
expect(aggregatorObject.formats).toEqual(['\"$\"#,###.###']);
|
2592
|
-
});
|
2593
2480
|
});
|
2594
2481
|
|
2595
2482
|
describe('Value method', () => {
|
@@ -2641,22 +2528,6 @@ describe('highcharts_renderer', () => {
|
|
2641
2528
|
aggregatorObject = aggregator({}, ['Region average'], '');
|
2642
2529
|
expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
|
2643
2530
|
});
|
2644
|
-
|
2645
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions and widget_value_format to equal first seriesOptions format', () => {
|
2646
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
2647
|
-
widget_values_format = '\"$\"#,###.###';
|
2648
|
-
const options = {
|
2649
|
-
comboOptions: {
|
2650
|
-
seriesOptions: [
|
2651
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
2652
|
-
]
|
2653
|
-
}
|
2654
|
-
}
|
2655
|
-
aggregator = highchartsRenderer.rhPivotAggregatorMin(arg, widget_values_format, is_graph, options, calculated_info);
|
2656
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
2657
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
2658
|
-
expect(aggregatorObject.format(1123.45678, false)).toBe('$1,123.457');
|
2659
|
-
});
|
2660
2531
|
});
|
2661
2532
|
});
|
2662
2533
|
|
@@ -2738,7 +2609,6 @@ describe('highcharts_renderer', () => {
|
|
2738
2609
|
});
|
2739
2610
|
|
2740
2611
|
it('Formats must be filled and uniq', () => {
|
2741
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
2742
2612
|
aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
|
2743
2613
|
expect(aggregatorObject.formats).toEqual(['####', '#,###']);
|
2744
2614
|
});
|
@@ -2785,21 +2655,6 @@ describe('highcharts_renderer', () => {
|
|
2785
2655
|
aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
|
2786
2656
|
expect(aggregatorObject.ignoreValue).toBe(true);
|
2787
2657
|
});
|
2788
|
-
|
2789
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions', () => {
|
2790
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
2791
|
-
const options = {
|
2792
|
-
comboOptions: {
|
2793
|
-
seriesOptions: [
|
2794
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
2795
|
-
]
|
2796
|
-
}
|
2797
|
-
}
|
2798
|
-
aggregator = highchartsRenderer.rhPivotAggregatorMax(arg, widget_values_format, is_graph, options, calculated_info);
|
2799
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
2800
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
2801
|
-
expect(aggregatorObject.formats).toEqual(['\"$\"#,###.###']);
|
2802
|
-
});
|
2803
2658
|
});
|
2804
2659
|
|
2805
2660
|
describe('Value method', () => {
|
@@ -2851,22 +2706,6 @@ describe('highcharts_renderer', () => {
|
|
2851
2706
|
aggregatorObject = aggregator({}, ['Region average'], '');
|
2852
2707
|
expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
|
2853
2708
|
});
|
2854
|
-
|
2855
|
-
it('if FF enabledNewWidgetValueFormatting is and some of secondaryAxis is true widget values format must be from seriesOptions and widget_value_format to equal first seriesOptions format', () => {
|
2856
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
2857
|
-
widget_values_format = '\"$\"#,###.###';
|
2858
|
-
const options = {
|
2859
|
-
comboOptions: {
|
2860
|
-
seriesOptions: [
|
2861
|
-
{series: 'Profit', format: '\"$\"#,###.###' , secondaryAxis: true},
|
2862
|
-
]
|
2863
|
-
}
|
2864
|
-
}
|
2865
|
-
aggregator = highchartsRenderer.rhPivotAggregatorMax(arg, widget_values_format, is_graph, options, calculated_info);
|
2866
|
-
aggregatorObject = aggregator({}, ['Profit'], '');
|
2867
|
-
aggregatorObject.push({ DR_Values: 'Profit', Profit: 123 });
|
2868
|
-
expect(aggregatorObject.format(1123.45678, false)).toBe('$1,123.457');
|
2869
|
-
});
|
2870
2709
|
});
|
2871
2710
|
});
|
2872
2711
|
});
|
@@ -4452,144 +4291,4 @@ describe('highcharts_renderer', () => {
|
|
4452
4291
|
expect(highchartsRenderer.getTrendSeriesName(series)).toBe(expectedName);
|
4453
4292
|
});
|
4454
4293
|
});
|
4455
|
-
|
4456
|
-
describe('function checkFormats', () => {
|
4457
|
-
it('should correctly detect if any series is on secondary axis', () => {
|
4458
|
-
const render_options = {
|
4459
|
-
comboOptions: {
|
4460
|
-
seriesOptions: [
|
4461
|
-
{ secondaryAxis: false },
|
4462
|
-
{ secondaryAxis: true },
|
4463
|
-
{ secondaryAxis: false },
|
4464
|
-
],
|
4465
|
-
},
|
4466
|
-
};
|
4467
|
-
const widget_values_format = '#,###';
|
4468
|
-
const result = highchartsRenderer.checkFormats(render_options, widget_values_format);
|
4469
|
-
expect(result.isSecondaryAxis).toBe(true);
|
4470
|
-
});
|
4471
|
-
|
4472
|
-
it('should correctly detect if all series are on primary axis', () => {
|
4473
|
-
const render_options = {
|
4474
|
-
comboOptions: {
|
4475
|
-
seriesOptions: [
|
4476
|
-
{ secondaryAxis: false },
|
4477
|
-
{ secondaryAxis: false },
|
4478
|
-
{ secondaryAxis: false },
|
4479
|
-
],
|
4480
|
-
},
|
4481
|
-
};
|
4482
|
-
const widget_values_format = '#,###';
|
4483
|
-
const result = highchartsRenderer.checkFormats(render_options, widget_values_format);
|
4484
|
-
expect(result.isSecondaryAxis).toBe(false);
|
4485
|
-
});
|
4486
|
-
|
4487
|
-
it('should correctly detect if the given format is custom', () => {
|
4488
|
-
const render_options = {
|
4489
|
-
comboOptions: {
|
4490
|
-
seriesOptions: [
|
4491
|
-
{ format: '#,###' },
|
4492
|
-
{ format: '#,###' },
|
4493
|
-
{ format: '#,###' },
|
4494
|
-
],
|
4495
|
-
},
|
4496
|
-
};
|
4497
|
-
const widget_values_format = '$#,###.###';
|
4498
|
-
const result = highchartsRenderer.checkFormats(render_options, widget_values_format);
|
4499
|
-
expect(result.isCustomFormat).toBe(true);
|
4500
|
-
});
|
4501
|
-
|
4502
|
-
it('should correctly detect if the given format is not custom', () => {
|
4503
|
-
const render_options = {
|
4504
|
-
comboOptions: {
|
4505
|
-
seriesOptions: [
|
4506
|
-
{ format: '$#,###' },
|
4507
|
-
{ format: '$#,###.#' },
|
4508
|
-
{ format: '$#,###.##' },
|
4509
|
-
],
|
4510
|
-
},
|
4511
|
-
};
|
4512
|
-
const widget_values_format = '$#,###';
|
4513
|
-
const result = highchartsRenderer.checkFormats(render_options, widget_values_format);
|
4514
|
-
expect(result.isCustomFormat).toBe(false);
|
4515
|
-
});
|
4516
|
-
});
|
4517
|
-
|
4518
|
-
describe('function isCustomValuesFormat', () => {
|
4519
|
-
const render_options = {
|
4520
|
-
comboOptions: {
|
4521
|
-
seriesOptions: [
|
4522
|
-
{ series: 'Profit', format: '#,###', secondaryAxis: false },
|
4523
|
-
{ series: 'Sales', format: '#,###', secondaryAxis: true },
|
4524
|
-
]
|
4525
|
-
}
|
4526
|
-
};
|
4527
|
-
|
4528
|
-
it('should return true if new widget value formatting is enabled and the format is custom or there is no secondary axis', () => {
|
4529
|
-
const widget_values_format = '$####.##';
|
4530
|
-
|
4531
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
4532
|
-
|
4533
|
-
const expectedValue = true;
|
4534
|
-
|
4535
|
-
const result = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4536
|
-
|
4537
|
-
expect(result).toEqual(expectedValue);
|
4538
|
-
});
|
4539
|
-
|
4540
|
-
it('should return false if new widget value formatting is disabled', () => {
|
4541
|
-
const widget_values_format = '#,###';
|
4542
|
-
|
4543
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
4544
|
-
|
4545
|
-
const expectedValue = false;
|
4546
|
-
|
4547
|
-
const result = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4548
|
-
|
4549
|
-
expect(result).toEqual(expectedValue);
|
4550
|
-
});
|
4551
|
-
|
4552
|
-
it('should return false if the format is not custom and there is a secondary axis', () => {
|
4553
|
-
const widget_values_format = '#,###';
|
4554
|
-
|
4555
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = true;
|
4556
|
-
|
4557
|
-
const expectedValue = false;
|
4558
|
-
|
4559
|
-
const result = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4560
|
-
|
4561
|
-
expect(result).toEqual(expectedValue);
|
4562
|
-
});
|
4563
|
-
});
|
4564
|
-
|
4565
|
-
describe('getRecordFormats', () => {
|
4566
|
-
const render_options = {
|
4567
|
-
comboOptions: {
|
4568
|
-
seriesOptions: [
|
4569
|
-
{ series: 'Profit', format: '$####.#', secondaryAxis: false },
|
4570
|
-
{ series: 'Sales', format: '$####.##', secondaryAxis: true },
|
4571
|
-
]
|
4572
|
-
}
|
4573
|
-
};
|
4574
|
-
|
4575
|
-
it('should return an array of formats for the given record name', () => {
|
4576
|
-
const recordName = 'Profit';
|
4577
|
-
|
4578
|
-
const expectedValue = ['$####.#'];
|
4579
|
-
|
4580
|
-
const result = highchartsRenderer.getRecordFormats(render_options, recordName);
|
4581
|
-
|
4582
|
-
expect(result).toEqual(expectedValue);
|
4583
|
-
});
|
4584
|
-
|
4585
|
-
it('should return an empty array if there are no matching records', () => {
|
4586
|
-
const recordName = 'Any';
|
4587
|
-
|
4588
|
-
const expectedValue = [];
|
4589
|
-
|
4590
|
-
const result = highchartsRenderer.getRecordFormats(render_options, recordName);
|
4591
|
-
|
4592
|
-
expect(result).toEqual(expectedValue);
|
4593
|
-
});
|
4594
|
-
});
|
4595
4294
|
});
|