@datarailsshared/dr_renderer 1.2.323-dragons → 1.2.324
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 +230 -181
- package/src/pivottable.js +4 -17
- package/tests/highcharts_renderer.test.js +527 -0
- package/tests/mock/add-in-dynamic-ranges.json +133 -0
- package/tests/mock/add-in-functions.json +412 -0
- package/tests/mock/add-in-tables.json +347 -0
- package/tests/mock/widgets.json +411 -0
@@ -139,6 +139,11 @@ 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
|
+
|
142
147
|
let getHighchartsRenderer = function ($, document, Highcharts, default_colors, highchartsRenderer,
|
143
148
|
DataFormatter, lodash, moment_lib, isNewAngular) {
|
144
149
|
|
@@ -166,10 +171,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
166
171
|
lodash.assign(highchartsRenderer, HIGHCHARTS_CONSTANTS);
|
167
172
|
|
168
173
|
highchartsRenderer.useTotalsCalculation = false;
|
174
|
+
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
169
175
|
let disableAnimation = false;
|
170
176
|
if (document.ReportHippo && document.ReportHippo && document.ReportHippo.user) {
|
171
|
-
highchartsRenderer.useTotalsCalculation = lodash.includes(document.ReportHippo.user.features,
|
177
|
+
highchartsRenderer.useTotalsCalculation = lodash.includes(document.ReportHippo.user.features, FEATURES.ENABLE_SERVER_TOTALS_CALCULATION);
|
172
178
|
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);
|
173
180
|
}
|
174
181
|
|
175
182
|
// fix issue of use tootip.stickOnContact with tooltip.outside , source: https://github.com/highcharts/highcharts/pull/15960
|
@@ -628,7 +635,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
628
635
|
// do nothing
|
629
636
|
}
|
630
637
|
}
|
631
|
-
return $.pivotUtilities.getFormattedNumber(value, null, opts);
|
638
|
+
return $.pivotUtilities.getFormattedNumber(value, null, opts).replace(/\u00A0/g, " ");
|
632
639
|
};
|
633
640
|
return func;
|
634
641
|
};
|
@@ -1150,7 +1157,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1150
1157
|
ob.name = row_n_value.join(highchartsRenderer.delimer)
|
1151
1158
|
.replace(highchartsRenderer.DR_OTHERS_KEY, othersName);
|
1152
1159
|
}
|
1153
|
-
|
1154
1160
|
lodash.forEach(col_n_keys, function (col_n_value, index) {
|
1155
1161
|
var agg = pivotData.getAggregator(row_n_value, col_n_value);
|
1156
1162
|
var val = agg.value();
|
@@ -1392,7 +1398,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1392
1398
|
if (opts.trendLine) {
|
1393
1399
|
const a = ((ySum * squareXSum) - (xSum * xySum)) / ((n * squareXSum) - (xSum * xSum));
|
1394
1400
|
const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
|
1395
|
-
|
1396
1401
|
const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
|
1397
1402
|
trendSeries.className = 'trendSeries';
|
1398
1403
|
trendSeries.name = highchartsRenderer.getTrendSeriesName(trendSeries);
|
@@ -1403,7 +1408,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1403
1408
|
if (colors && colors[i]) {
|
1404
1409
|
trendSeries.color = colors[i];
|
1405
1410
|
}
|
1406
|
-
|
1407
1411
|
trendSerieses.push(trendSeries);
|
1408
1412
|
}
|
1409
1413
|
i++;
|
@@ -1420,7 +1424,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1420
1424
|
}
|
1421
1425
|
|
1422
1426
|
let weights = { line: 2,spline: 3 ,area:-2, areaspline: -1, scatter:4, column: 1 };
|
1423
|
-
|
1424
1427
|
if (opts.comboOptions && lodash.includes(chartType,'combo') && !lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
|
1425
1428
|
chart_series.forEach((series, seriesIndex) => {
|
1426
1429
|
const savedSeriesOption = lodash.find(opts.comboOptions.seriesOptions, {series: series.name});
|
@@ -1507,7 +1510,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1507
1510
|
const chart_series = [];
|
1508
1511
|
const row_n_keys = pivotData.getRowKeys();
|
1509
1512
|
const col_n_keys = pivotData.getColKeys();
|
1510
|
-
const rows_by_cols = pivotData.rowKeysByCols;
|
1511
1513
|
|
1512
1514
|
let resultObject = {
|
1513
1515
|
data: [],
|
@@ -1536,9 +1538,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1536
1538
|
});
|
1537
1539
|
|
1538
1540
|
if (col_index !== col_n_keys.length - 1) {
|
1539
|
-
|
1540
|
-
const rowKeys = rows_by_cols ? rows_by_cols[col_index] : row_n_keys;
|
1541
|
-
lodash.forEach(rowKeys, function (row_n_value) {
|
1541
|
+
lodash.forEach(row_n_keys, 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,6 +3890,11 @@ 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
|
+
|
3893
3898
|
return function (data, rowKey, colKey) {
|
3894
3899
|
return {
|
3895
3900
|
sum: 0,
|
@@ -3901,6 +3906,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3901
3906
|
calculated_formats: calculated_info.formats,
|
3902
3907
|
isChangeable: false,
|
3903
3908
|
push: function (record) {
|
3909
|
+
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
3910
|
+
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
3911
|
+
}
|
3912
|
+
|
3904
3913
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
3905
3914
|
this.data_types = this.data_types.concat(record['data_types']);
|
3906
3915
|
this.data_types = lodash.uniq(this.data_types);
|
@@ -3945,7 +3954,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3945
3954
|
number_format = 'General';
|
3946
3955
|
}
|
3947
3956
|
|
3948
|
-
if (this.widget_values_format) {
|
3957
|
+
if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
|
3958
|
+
number_format = this.widget_values_format;
|
3959
|
+
}
|
3960
|
+
|
3961
|
+
if (isCustomValuesFormat) {
|
3949
3962
|
number_format = this.widget_values_format;
|
3950
3963
|
}
|
3951
3964
|
|
@@ -4033,6 +4046,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4033
4046
|
|
4034
4047
|
highchartsRenderer.rhPivotAggregatorSum = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4035
4048
|
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
|
+
|
4036
4054
|
return function (data, rowKey, colKey) {
|
4037
4055
|
return {
|
4038
4056
|
sum: 0,
|
@@ -4053,7 +4071,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4053
4071
|
}
|
4054
4072
|
}
|
4055
4073
|
var val = parseFloat(record[attr]);
|
4074
|
+
|
4056
4075
|
if (!isNaN(val)) {
|
4076
|
+
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4077
|
+
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
4078
|
+
}
|
4057
4079
|
|
4058
4080
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
4059
4081
|
this.data_types = this.data_types.concat(record['data_types']);
|
@@ -4100,13 +4122,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4100
4122
|
number_format = 'General';
|
4101
4123
|
}
|
4102
4124
|
|
4103
|
-
if (this.widget_values_format) {
|
4125
|
+
if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4104
4126
|
number_format = this.widget_values_format;
|
4105
4127
|
}
|
4106
4128
|
|
4129
|
+
if (isCustomValuesFormat) {
|
4130
|
+
number_format = this.widget_values_format;
|
4131
|
+
}
|
4107
4132
|
number_format = highchartsRenderer.getCalculatedValueFormat(this.calculated_formats, rowKey, colKey) || number_format;
|
4108
|
-
|
4109
4133
|
var formated_value = highchartsRenderer.formatValue('n', number_format, x)
|
4134
|
+
|
4110
4135
|
if (formated_value && formated_value.hasOwnProperty('value') && formated_value.value != null) {
|
4111
4136
|
return formated_value.value;
|
4112
4137
|
} else {
|
@@ -4121,6 +4146,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4121
4146
|
|
4122
4147
|
highchartsRenderer.rhPivotAggregatorMin = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4123
4148
|
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
|
+
|
4124
4154
|
return function (data, rowKey, colKey) {
|
4125
4155
|
return {
|
4126
4156
|
val: null,
|
@@ -4144,6 +4174,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4144
4174
|
var ref, x;
|
4145
4175
|
x = parseFloat(record[attr]);
|
4146
4176
|
if (!isNaN(x)) {
|
4177
|
+
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4178
|
+
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
4179
|
+
}
|
4180
|
+
|
4147
4181
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
4148
4182
|
this.data_types = this.data_types.concat(record['data_types']);
|
4149
4183
|
this.data_types = lodash.uniq(this.data_types);
|
@@ -4186,7 +4220,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4186
4220
|
number_format = 'General';
|
4187
4221
|
}
|
4188
4222
|
|
4189
|
-
if (this.widget_values_format) {
|
4223
|
+
if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4224
|
+
number_format = this.widget_values_format;
|
4225
|
+
}
|
4226
|
+
|
4227
|
+
if (isCustomValuesFormat) {
|
4190
4228
|
number_format = this.widget_values_format;
|
4191
4229
|
}
|
4192
4230
|
|
@@ -4207,6 +4245,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4207
4245
|
|
4208
4246
|
highchartsRenderer.rhPivotAggregatorMax = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4209
4247
|
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
|
+
|
4210
4253
|
return function (data, rowKey, colKey) {
|
4211
4254
|
return {
|
4212
4255
|
val: null,
|
@@ -4230,6 +4273,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4230
4273
|
var ref, x;
|
4231
4274
|
x = parseFloat(record[attr]);
|
4232
4275
|
if (!isNaN(x)) {
|
4276
|
+
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4277
|
+
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
4278
|
+
}
|
4279
|
+
|
4233
4280
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
4234
4281
|
this.data_types = this.data_types.concat(record['data_types']);
|
4235
4282
|
this.data_types = lodash.uniq(this.data_types);
|
@@ -4273,7 +4320,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4273
4320
|
number_format = 'General';
|
4274
4321
|
}
|
4275
4322
|
|
4276
|
-
if (this.widget_values_format) {
|
4323
|
+
if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4324
|
+
number_format = this.widget_values_format;
|
4325
|
+
}
|
4326
|
+
|
4327
|
+
if (isCustomValuesFormat) {
|
4277
4328
|
number_format = this.widget_values_format;
|
4278
4329
|
}
|
4279
4330
|
|
@@ -4294,6 +4345,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4294
4345
|
|
4295
4346
|
highchartsRenderer.rhPivotAggregatorAverage = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4296
4347
|
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
|
+
|
4297
4353
|
return function (data, rowKey, colKey) {
|
4298
4354
|
return {
|
4299
4355
|
sum: 0,
|
@@ -4318,6 +4374,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4318
4374
|
var ref, x;
|
4319
4375
|
x = parseFloat(record[attr]);
|
4320
4376
|
if (!isNaN(x)) {
|
4377
|
+
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4378
|
+
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
4379
|
+
}
|
4380
|
+
|
4321
4381
|
if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
|
4322
4382
|
this.data_types = this.data_types.concat(record['data_types']);
|
4323
4383
|
this.data_types = lodash.uniq(this.data_types);
|
@@ -4367,7 +4427,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4367
4427
|
number_format = 'General';
|
4368
4428
|
}
|
4369
4429
|
|
4370
|
-
if (this.widget_values_format) {
|
4430
|
+
if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
|
4431
|
+
number_format = this.widget_values_format;
|
4432
|
+
}
|
4433
|
+
|
4434
|
+
if (isCustomValuesFormat) {
|
4371
4435
|
number_format = this.widget_values_format;
|
4372
4436
|
}
|
4373
4437
|
|
@@ -4714,19 +4778,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4714
4778
|
opts.rendererOptions.onlyOptions = true;
|
4715
4779
|
}
|
4716
4780
|
|
4717
|
-
|
4718
|
-
|
4719
|
-
|
4720
|
-
|
4721
|
-
|
4722
|
-
|
4723
|
-
|
4724
|
-
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
pivotData.sorters = new_sorting_function;
|
4729
|
-
}
|
4781
|
+
const sortByValueSettings = lodash.filter(
|
4782
|
+
lodash.get(widget, 'options.sortingFields', []),
|
4783
|
+
sortingField => lodash.includes(['field_values', 'variance'], lodash.get(sortingField, 'sorting.sort_by'))
|
4784
|
+
);
|
4785
|
+
|
4786
|
+
if (sortByValueSettings.length) {
|
4787
|
+
pivotData.sortByValueAttrs = lodash.map(sortByValueSettings, fieldSorting => fieldSorting.name);
|
4788
|
+
let new_sorting_function = highchartsRenderer.generateSortingFunctionByValues(sortByValueSettings, pivotData, opts, widget);
|
4789
|
+
opts.sorters = new_sorting_function;
|
4790
|
+
optsFiltered.sorters = new_sorting_function;
|
4791
|
+
pivotData.sorters = new_sorting_function;
|
4730
4792
|
}
|
4731
4793
|
|
4732
4794
|
result = opts.renderer(pivotData, opts.rendererOptions);
|
@@ -4780,7 +4842,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4780
4842
|
rows: lodash.map(pivotOptions.legendArray, 'name'),
|
4781
4843
|
rendererOptions: widget.options,
|
4782
4844
|
dateValuesDictionary: pivotOptions ? pivotOptions.dateValuesDictionary : null,
|
4783
|
-
keysObject: pivotOptions ? pivotOptions.keysObject : null,
|
4784
4845
|
};
|
4785
4846
|
|
4786
4847
|
if (!subopts.rendererOptions) {
|
@@ -5594,21 +5655,20 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
5594
5655
|
|
5595
5656
|
lodash.forEach(functionOptions.filters, function (filterObj) {
|
5596
5657
|
fieldOb = lodash.find(fields, {id: filterObj.field});
|
5597
|
-
if (fieldOb && filterObj.values && filterObj.values.datetype && filterObj.values.datetype
|
5658
|
+
if (fieldOb && filterObj.values && filterObj.values.datetype && filterObj.values.datetype === 'list') {
|
5598
5659
|
filterObj.values = filterObj.values.val
|
5599
|
-
} else if (fieldOb && filterObj.values && filterObj.values.datetype && filterObj.values.datetype
|
5660
|
+
} else if (fieldOb && filterObj.values && filterObj.values.datetype && filterObj.values.datetype !== 'list') {
|
5600
5661
|
fieldOb.values = filterObj.values;
|
5601
5662
|
} else if (fieldOb && filterObj.values && filterObj.values.type === 'advanced') {
|
5602
5663
|
fieldOb.values = filterObj.values;
|
5603
5664
|
}
|
5604
5665
|
|
5605
5666
|
if (fieldOb && filterObj.values && filterObj.values instanceof Array) {
|
5606
|
-
if (filterObj.is_excluded
|
5667
|
+
if (filterObj.is_excluded) {
|
5607
5668
|
fieldOb.excludes = filterObj.values;
|
5608
5669
|
} else {
|
5609
5670
|
fieldOb.includes = filterObj.values;
|
5610
5671
|
}
|
5611
|
-
//includes[fieldOb.name] = highchartsRenderer.getOnlyIncludedOfField(fieldOb);
|
5612
5672
|
}
|
5613
5673
|
if (filterObj.show_in_graph && fieldOb) {
|
5614
5674
|
fieldOb.show_in_graph = filterObj.show_in_graph
|
@@ -5774,7 +5834,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
5774
5834
|
widgetOptions.pivot.legendArray = legendFields;
|
5775
5835
|
widgetOptions.pivot.valuesArray = valuesFields;
|
5776
5836
|
widgetOptions.pivot.filtersArray = filterFields;
|
5777
|
-
//widgetOptions.pivot.filter = filterFn;
|
5778
5837
|
widgetOptions.pivot.filterIncludes = includes;
|
5779
5838
|
widgetOptions.pivot.chartType = widgetOptions.chart_type;
|
5780
5839
|
widgetOptions.pivot.chartOptions = widgetOptions.options;
|
@@ -8649,8 +8708,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8649
8708
|
};
|
8650
8709
|
|
8651
8710
|
highchartsRenderer.getWidgetDataSorters = function (res, widget, defaultDateFormat) {
|
8652
|
-
let sorters;
|
8653
|
-
|
8654
8711
|
if ($.pivotUtilities && !$.pivotUtilities.additionalFieldsList) {
|
8655
8712
|
$.pivotUtilities.additionalFieldsList = [
|
8656
8713
|
{key: 'DR_Average', name: 'DR_Average'},
|
@@ -8658,20 +8715,32 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8658
8715
|
];
|
8659
8716
|
}
|
8660
8717
|
|
8661
|
-
|
8718
|
+
var datesFields = [];
|
8662
8719
|
datesFields = lodash.filter(widget.rows, element => element.type == 'Date');
|
8663
8720
|
datesFields = datesFields.concat(lodash.filter(widget.cols, element => element.type == 'Date'));
|
8721
|
+
|
8722
|
+
const isCustomSorting = widget.options.sortingFields && Array.isArray(widget.options.sortingFields) && widget.options.sortingFields.length > 0;
|
8723
|
+
if (isCustomSorting) {
|
8724
|
+
lodash.forEach(datesFields, function (field) {
|
8725
|
+
const fieldToSort = lodash.find(
|
8726
|
+
widget.options.sortingFields, element => element.id === field.id && lodash.get(element, 'sorting.sort_by') === 'field_items'
|
8727
|
+
);
|
8728
|
+
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
8729
|
+
});
|
8730
|
+
}
|
8731
|
+
|
8664
8732
|
datesFields = lodash.map(datesFields, function (row) {
|
8665
8733
|
return { "format": highchartsRenderer.getDateFieldFormat(widget, row), "name": row.name, "type": row.type, "values": [], "sorting": row.sorting } //'MMM - yyyy' format
|
8666
8734
|
});
|
8667
8735
|
|
8736
|
+
var data = res;
|
8737
|
+
|
8668
8738
|
lodash.forEach(datesFields, function (row) {
|
8669
8739
|
row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
|
8670
8740
|
});
|
8671
8741
|
|
8672
8742
|
if (datesFields.length > 0) {
|
8673
|
-
|
8674
|
-
lodash.forEach(res, function (element) {
|
8743
|
+
lodash.forEach(data, function (element) {
|
8675
8744
|
for (var i in datesFields) {
|
8676
8745
|
if (element.hasOwnProperty(datesFields[i].name)) {
|
8677
8746
|
datesFields[i].values.push(element[datesFields[i].name]);
|
@@ -8684,156 +8753,125 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8684
8753
|
widget.pivot.dateValuesDictionary = {}
|
8685
8754
|
}
|
8686
8755
|
widget.pivot.dateValuesDictionary[dateStringValue] = element[datesFields[i].name];
|
8687
|
-
invertedDateStringMap[element[datesFields[i].name]] = dateStringValue;
|
8688
8756
|
}
|
8689
8757
|
element[datesFields[i].name] = dateStringValue;
|
8690
8758
|
}
|
8691
8759
|
}
|
8692
8760
|
});
|
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
|
-
}
|
8711
8761
|
}
|
8762
|
+
lodash.forEach(datesFields, function (row) {
|
8763
|
+
row.values = lodash.uniq(row.values);
|
8712
8764
|
|
8713
|
-
|
8714
|
-
|
8715
|
-
|
8716
|
-
|
8717
|
-
|
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();
|
8765
|
+
const isTimestampDateField = row.type === 'Date' && lodash.some(row.values, value => typeof value ==='number');
|
8766
|
+
if (isTimestampDateField) {
|
8767
|
+
const nullValueIndex = row.values.indexOf(NULL_VALUE);
|
8768
|
+
if (~nullValueIndex) {
|
8769
|
+
row.values.splice(nullValueIndex, 1);
|
8739
8770
|
}
|
8740
|
-
|
8741
|
-
if (
|
8742
|
-
row.values
|
8771
|
+
row.values = row.values.sort((a, b) => a - b);
|
8772
|
+
if (~nullValueIndex) {
|
8773
|
+
row.values.push(NULL_VALUE);
|
8743
8774
|
}
|
8744
|
-
|
8745
|
-
row.values =
|
8746
|
-
|
8747
|
-
})
|
8748
|
-
|
8749
|
-
});
|
8775
|
+
} else {
|
8776
|
+
row.values = row.values.sort();
|
8777
|
+
}
|
8750
8778
|
|
8751
|
-
|
8752
|
-
|
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
|
-
});
|
8779
|
+
if (row.sorting && row.sorting.type == "largestToSmallest") {
|
8780
|
+
row.values = lodash.reverse(row.values);
|
8776
8781
|
}
|
8782
|
+
delete row.sorting;
|
8783
|
+
row.values = lodash.map(row.values, function (val) {
|
8784
|
+
return highchartsRenderer.returnRawDataValue(row.type, val, row.format, row.name, row.val_not_convert) + "";
|
8785
|
+
})
|
8786
|
+
|
8787
|
+
});
|
8777
8788
|
|
8789
|
+
/* date string */
|
8790
|
+
var rowsAndCols = [];
|
8791
|
+
rowsAndCols = widget.rows.concat(widget.cols);
|
8792
|
+
|
8793
|
+
if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
|
8794
|
+
|
8795
|
+
// if it is breakdown widget - redefine sorting according to breakdown_options
|
8796
|
+
// TODO: remove this when BE sort will be implemented
|
8778
8797
|
lodash.forEach(rowsAndCols, function (field) {
|
8779
|
-
|
8780
|
-
|
8781
|
-
|
8782
|
-
|
8783
|
-
|
8784
|
-
|
8785
|
-
|
8786
|
-
|
8787
|
-
|
8788
|
-
|
8789
|
-
|
8790
|
-
|
8791
|
-
|
8792
|
-
|
8793
|
-
|
8798
|
+
const waterfallFieldType = field.id === widget.cols[0].id ? 'totals' : 'breakdown';
|
8799
|
+
field.sorting = {
|
8800
|
+
type: 'CustomOrder',
|
8801
|
+
values: lodash.map(
|
8802
|
+
widget.options.breakdown_options.values[waterfallFieldType],
|
8803
|
+
value => value.key
|
8804
|
+
),
|
8805
|
+
};
|
8806
|
+
});
|
8807
|
+
} else if (isCustomSorting) {
|
8808
|
+
lodash.forEach(rowsAndCols, function (field) {
|
8809
|
+
const fieldToSort = lodash.find(
|
8810
|
+
widget.options.sortingFields, element => element.id === field.id && lodash.get(element, 'sorting.sort_by') === 'field_items'
|
8811
|
+
);
|
8812
|
+
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
8813
|
+
});
|
8814
|
+
}
|
8815
|
+
|
8816
|
+
lodash.forEach(rowsAndCols, function (field) {
|
8817
|
+
if (field.sorting && (field.sorting.type == "DateString" || field.sorting.type == "largestToSmallest")) {
|
8818
|
+
var find_field = lodash.find(datesFields, {name: field.name});
|
8819
|
+
if (find_field) {
|
8820
|
+
if (find_field.type != 'Date')
|
8821
|
+
find_field.sorting = field.sorting;
|
8822
|
+
} else {
|
8794
8823
|
datesFields.push({
|
8795
8824
|
"format": field.format,
|
8796
8825
|
"name": field.name,
|
8797
8826
|
"type": field.type,
|
8798
|
-
"values":
|
8827
|
+
"values": [],
|
8828
|
+
"sorting": field.sorting,
|
8799
8829
|
});
|
8800
8830
|
}
|
8801
|
-
})
|
8831
|
+
} else if (field.sorting && field.sorting.type == "CustomOrder" && field.sorting.values) {
|
8832
|
+
datesFields.push({
|
8833
|
+
"format": field.format,
|
8834
|
+
"name": field.name,
|
8835
|
+
"type": field.type,
|
8836
|
+
"values": field.sorting.values
|
8837
|
+
});
|
8838
|
+
}
|
8839
|
+
});
|
8802
8840
|
|
8803
|
-
|
8804
|
-
|
8841
|
+
if (widget.vals && widget.vals.length > 1) {
|
8842
|
+
datesFields.push({name: "DR_Values", values: lodash.map(widget.vals, 'name')});
|
8843
|
+
}
|
8844
|
+
|
8845
|
+
/****** END *******/
|
8846
|
+
|
8847
|
+
// TODO: Remove. sortingValues looks like lagacy which is not in use neither in webclient nor in renderer
|
8848
|
+
if (widget.options && widget.options.sortingValues) {
|
8849
|
+
var field = lodash.find(datesFields, {name: widget.options.sortingValues.field});
|
8850
|
+
if (field) {
|
8851
|
+
field.values = widget.options.sortingValues.values;
|
8852
|
+
field.sorting = null;
|
8853
|
+
} else {
|
8854
|
+
datesFields.push({
|
8855
|
+
name: widget.options.sortingValues.field,
|
8856
|
+
values: widget.options.sortingValues.values
|
8857
|
+
});
|
8805
8858
|
}
|
8806
|
-
|
8807
|
-
|
8808
|
-
|
8809
|
-
|
8810
|
-
if (
|
8811
|
-
|
8812
|
-
|
8813
|
-
|
8814
|
-
field.sorting
|
8859
|
+
}
|
8860
|
+
|
8861
|
+
let sorters = function (attr) {
|
8862
|
+
var field = lodash.find(datesFields, {name: attr});
|
8863
|
+
if (field)
|
8864
|
+
if (field.sorting && field.sorting.type == "DateString") {
|
8865
|
+
return $.pivotUtilities.sortDateStrings(field.sorting.month_order);
|
8866
|
+
} else if (field.sorting && field.sorting.type == "largestToSmallest") {
|
8867
|
+
if (field.sorting.is_absolute)
|
8868
|
+
return $.pivotUtilities.largeToSmallSortByAbsolute;
|
8869
|
+
|
8870
|
+
return $.pivotUtilities.largeToSmallSort;
|
8815
8871
|
} else {
|
8816
|
-
|
8817
|
-
name: widget.options.sortingValues.field,
|
8818
|
-
values: widget.options.sortingValues.values
|
8819
|
-
});
|
8872
|
+
return $.pivotUtilities.sortAs(field.values);
|
8820
8873
|
}
|
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
|
-
}
|
8874
|
+
};
|
8837
8875
|
|
8838
8876
|
return sorters;
|
8839
8877
|
};
|
@@ -8853,12 +8891,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8853
8891
|
|
8854
8892
|
//highchartsRenderer.getGraphOptions(scope.data, override_values, res, scope.dataModel.templatesWithOutData, scope.openDrillDownList, drillDownFunction)
|
8855
8893
|
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
|
-
|
8862
8894
|
let res = highchartsRenderer.updateSelectedOverrideValues(widget_obj, override_values, row_data);
|
8863
8895
|
res = highchartsRenderer.convertUniqueDateValues(widget_obj, templates, res);
|
8864
8896
|
|
@@ -8870,10 +8902,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8870
8902
|
|
8871
8903
|
let pivot = {};
|
8872
8904
|
|
8873
|
-
if (highchartsRenderer.isSortingOnBackendEnabled()) {
|
8874
|
-
pivot.keysObject = keysObject;
|
8875
|
-
}
|
8876
|
-
|
8877
8905
|
let templateNoData = lodash.find(templates, {id: widget_obj.template_id});
|
8878
8906
|
if (templateNoData) {
|
8879
8907
|
|
@@ -8910,8 +8938,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8910
8938
|
subopts.onlyOptions = true;
|
8911
8939
|
}
|
8912
8940
|
|
8913
|
-
subopts.keysObject = keysObject;
|
8914
|
-
|
8915
8941
|
let hc_options = highchartsRenderer.rhPivotView(res, subopts, is_table, widget_obj);
|
8916
8942
|
|
8917
8943
|
return hc_options;
|
@@ -9239,8 +9265,31 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9239
9265
|
}
|
9240
9266
|
}
|
9241
9267
|
|
9242
|
-
highchartsRenderer.
|
9243
|
-
|
9268
|
+
highchartsRenderer.checkFormats = function(render_options, widget_values_format) {
|
9269
|
+
let isSecondaryAxis = false;
|
9270
|
+
let formats = [];
|
9271
|
+
if (render_options && render_options.comboOptions && render_options.comboOptions.seriesOptions) {
|
9272
|
+
isSecondaryAxis = lodash.some(render_options.comboOptions.seriesOptions, series => series.secondaryAxis);
|
9273
|
+
formats = lodash.map(render_options.comboOptions.seriesOptions, series => series.format);
|
9274
|
+
}
|
9275
|
+
const isCustomFormat = !lodash.includes(formats, widget_values_format);
|
9276
|
+
|
9277
|
+
return { isSecondaryAxis, isCustomFormat }
|
9278
|
+
}
|
9279
|
+
|
9280
|
+
highchartsRenderer.getRecordFormats = function(render_options, recordName) {
|
9281
|
+
let formats = [];
|
9282
|
+
if (render_options && render_options.comboOptions && render_options.comboOptions.seriesOptions) {
|
9283
|
+
formats = render_options.comboOptions.seriesOptions
|
9284
|
+
.filter(series => series.series === recordName)
|
9285
|
+
.map(series => series.format);
|
9286
|
+
}
|
9287
|
+
return formats;
|
9288
|
+
}
|
9289
|
+
|
9290
|
+
highchartsRenderer.isCustomValuesFormat = function (render_options, widget_values_format) {
|
9291
|
+
const { isSecondaryAxis, isCustomFormat } = highchartsRenderer.checkFormats(render_options, widget_values_format);
|
9292
|
+
return highchartsRenderer.enabledNewWidgetValueFormatting && (isCustomFormat || !isSecondaryAxis);
|
9244
9293
|
}
|
9245
9294
|
|
9246
9295
|
return highchartsRenderer;
|