@datarailsshared/dr_renderer 1.2.317-rocket → 1.2.320

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.2.317-rocket",
3
+ "version": "1.2.320",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -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, 'enable_server_totals_calculation');
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
  };
@@ -3883,6 +3890,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3883
3890
 
3884
3891
  highchartsRenderer.rhPivotCount = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
3885
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
+
3886
3898
  return function (data, rowKey, colKey) {
3887
3899
  return {
3888
3900
  sum: 0,
@@ -3894,6 +3906,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3894
3906
  calculated_formats: calculated_info.formats,
3895
3907
  isChangeable: false,
3896
3908
  push: function (record) {
3909
+ if (highchartsRenderer.enabledNewWidgetValueFormatting) {
3910
+ record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
3911
+ }
3912
+
3897
3913
  if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
3898
3914
  this.data_types = this.data_types.concat(record['data_types']);
3899
3915
  this.data_types = lodash.uniq(this.data_types);
@@ -3938,7 +3954,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3938
3954
  number_format = 'General';
3939
3955
  }
3940
3956
 
3941
- 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) {
3942
3962
  number_format = this.widget_values_format;
3943
3963
  }
3944
3964
 
@@ -4026,6 +4046,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4026
4046
 
4027
4047
  highchartsRenderer.rhPivotAggregatorSum = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4028
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
+
4029
4054
  return function (data, rowKey, colKey) {
4030
4055
  return {
4031
4056
  sum: 0,
@@ -4046,7 +4071,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4046
4071
  }
4047
4072
  }
4048
4073
  var val = parseFloat(record[attr]);
4074
+
4049
4075
  if (!isNaN(val)) {
4076
+ if (highchartsRenderer.enabledNewWidgetValueFormatting) {
4077
+ record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
4078
+ }
4050
4079
 
4051
4080
  if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
4052
4081
  this.data_types = this.data_types.concat(record['data_types']);
@@ -4093,13 +4122,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4093
4122
  number_format = 'General';
4094
4123
  }
4095
4124
 
4096
- if (this.widget_values_format) {
4125
+ if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
4097
4126
  number_format = this.widget_values_format;
4098
4127
  }
4099
4128
 
4129
+ if (isCustomValuesFormat) {
4130
+ number_format = this.widget_values_format;
4131
+ }
4100
4132
  number_format = highchartsRenderer.getCalculatedValueFormat(this.calculated_formats, rowKey, colKey) || number_format;
4101
-
4102
4133
  var formated_value = highchartsRenderer.formatValue('n', number_format, x)
4134
+
4103
4135
  if (formated_value && formated_value.hasOwnProperty('value') && formated_value.value != null) {
4104
4136
  return formated_value.value;
4105
4137
  } else {
@@ -4114,6 +4146,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4114
4146
 
4115
4147
  highchartsRenderer.rhPivotAggregatorMin = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4116
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
+
4117
4154
  return function (data, rowKey, colKey) {
4118
4155
  return {
4119
4156
  val: null,
@@ -4137,6 +4174,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4137
4174
  var ref, x;
4138
4175
  x = parseFloat(record[attr]);
4139
4176
  if (!isNaN(x)) {
4177
+ if (highchartsRenderer.enabledNewWidgetValueFormatting) {
4178
+ record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
4179
+ }
4180
+
4140
4181
  if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
4141
4182
  this.data_types = this.data_types.concat(record['data_types']);
4142
4183
  this.data_types = lodash.uniq(this.data_types);
@@ -4179,7 +4220,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4179
4220
  number_format = 'General';
4180
4221
  }
4181
4222
 
4182
- 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) {
4183
4228
  number_format = this.widget_values_format;
4184
4229
  }
4185
4230
 
@@ -4200,6 +4245,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4200
4245
 
4201
4246
  highchartsRenderer.rhPivotAggregatorMax = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4202
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
+
4203
4253
  return function (data, rowKey, colKey) {
4204
4254
  return {
4205
4255
  val: null,
@@ -4223,6 +4273,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4223
4273
  var ref, x;
4224
4274
  x = parseFloat(record[attr]);
4225
4275
  if (!isNaN(x)) {
4276
+ if (highchartsRenderer.enabledNewWidgetValueFormatting) {
4277
+ record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
4278
+ }
4279
+
4226
4280
  if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
4227
4281
  this.data_types = this.data_types.concat(record['data_types']);
4228
4282
  this.data_types = lodash.uniq(this.data_types);
@@ -4266,7 +4320,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4266
4320
  number_format = 'General';
4267
4321
  }
4268
4322
 
4269
- 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) {
4270
4328
  number_format = this.widget_values_format;
4271
4329
  }
4272
4330
 
@@ -4287,6 +4345,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4287
4345
 
4288
4346
  highchartsRenderer.rhPivotAggregatorAverage = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4289
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
+
4290
4353
  return function (data, rowKey, colKey) {
4291
4354
  return {
4292
4355
  sum: 0,
@@ -4311,6 +4374,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4311
4374
  var ref, x;
4312
4375
  x = parseFloat(record[attr]);
4313
4376
  if (!isNaN(x)) {
4377
+ if (highchartsRenderer.enabledNewWidgetValueFormatting) {
4378
+ record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
4379
+ }
4380
+
4314
4381
  if (record.hasOwnProperty('data_types') && $.isArray(record['data_types'])) {
4315
4382
  this.data_types = this.data_types.concat(record['data_types']);
4316
4383
  this.data_types = lodash.uniq(this.data_types);
@@ -4360,7 +4427,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4360
4427
  number_format = 'General';
4361
4428
  }
4362
4429
 
4363
- 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) {
4364
4435
  number_format = this.widget_values_format;
4365
4436
  }
4366
4437
 
@@ -9196,6 +9267,25 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9196
9267
  }
9197
9268
  }
9198
9269
 
9270
+ highchartsRenderer.checkFormats = function(render_options, widget_values_format) {
9271
+ const isSecondaryAxis = lodash.some(render_options.comboOptions?.seriesOptions, series => series?.secondaryAxis);
9272
+ const formats = lodash.map(render_options.comboOptions?.seriesOptions, series => series.format);
9273
+ const isCustomFormat = !lodash.includes(formats, widget_values_format);
9274
+
9275
+ return { isSecondaryAxis, isCustomFormat }
9276
+ }
9277
+
9278
+ highchartsRenderer.getRecordFormats = function(render_options, recordName) {
9279
+ return render_options?.comboOptions?.seriesOptions
9280
+ .filter(series => series.series === recordName)
9281
+ .map(series => series.format);
9282
+ }
9283
+
9284
+ highchartsRenderer.isCustomValuesFormat = function (render_options, widget_values_format) {
9285
+ const { isSecondaryAxis, isCustomFormat } = highchartsRenderer.checkFormats(render_options, widget_values_format);
9286
+ return highchartsRenderer.enabledNewWidgetValueFormatting && (isCustomFormat || !isSecondaryAxis);
9287
+ }
9288
+
9199
9289
  return highchartsRenderer;
9200
9290
  };
9201
9291
 
@@ -483,6 +483,7 @@ describe('highcharts_renderer', () => {
483
483
  let opts;
484
484
 
485
485
  beforeEach(() => {
486
+ highchartsRenderer.enabledNewWidgetValueFormatting = false;
486
487
  funcContext = { y: '12345.678' };
487
488
  opts = {}
488
489
  });
@@ -1735,6 +1736,7 @@ describe('highcharts_renderer', () => {
1735
1736
  });
1736
1737
 
1737
1738
  it('Formats must be filled and uniq', () => {
1739
+ highchartsRenderer.enabledNewWidgetValueFormatting = false;
1738
1740
  aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
1739
1741
  expect(aggregatorObject.formats).toEqual(['####', '#,###']);
1740
1742
  });
@@ -1781,6 +1783,21 @@ describe('highcharts_renderer', () => {
1781
1783
  aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
1782
1784
  expect(aggregatorObject.ignoreValue).toBe(true);
1783
1785
  });
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
+ });
1784
1801
  });
1785
1802
 
1786
1803
  describe('Value method', () => {
@@ -1831,6 +1848,22 @@ describe('highcharts_renderer', () => {
1831
1848
  aggregatorObject = aggregator({}, ['Region average'], '');
1832
1849
  expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
1833
1850
  });
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
+ });
1834
1867
  });
1835
1868
  });
1836
1869
 
@@ -1912,6 +1945,7 @@ describe('highcharts_renderer', () => {
1912
1945
  });
1913
1946
 
1914
1947
  it('Formats must be filled and uniq', () => {
1948
+ highchartsRenderer.enabledNewWidgetValueFormatting = false;
1915
1949
  aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
1916
1950
  expect(aggregatorObject.formats).toEqual(['####', '#,###']);
1917
1951
  });
@@ -1958,6 +1992,21 @@ describe('highcharts_renderer', () => {
1958
1992
  aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
1959
1993
  expect(aggregatorObject.ignoreValue).toBe(true);
1960
1994
  });
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
+ });
1961
2010
  });
1962
2011
 
1963
2012
  describe('Value method', () => {
@@ -2008,6 +2057,22 @@ describe('highcharts_renderer', () => {
2008
2057
  aggregatorObject = aggregator({}, ['Region average'], '');
2009
2058
  expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
2010
2059
  });
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
+ });
2011
2076
  });
2012
2077
  });
2013
2078
 
@@ -2243,6 +2308,7 @@ describe('highcharts_renderer', () => {
2243
2308
  });
2244
2309
 
2245
2310
  it('Formats must be filled and uniq', () => {
2311
+ highchartsRenderer.enabledNewWidgetValueFormatting = false;
2246
2312
  aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
2247
2313
  expect(aggregatorObject.formats).toEqual(['####', '#,###']);
2248
2314
  });
@@ -2291,6 +2357,21 @@ describe('highcharts_renderer', () => {
2291
2357
  aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
2292
2358
  expect(aggregatorObject.ignoreValue).toBe(true);
2293
2359
  });
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
+ });
2294
2375
  });
2295
2376
 
2296
2377
  describe('Value method', () => {
@@ -2350,6 +2431,22 @@ describe('highcharts_renderer', () => {
2350
2431
  aggregatorObject = aggregator({}, ['Region average'], '');
2351
2432
  expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
2352
2433
  });
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
+ });
2353
2450
  });
2354
2451
  });
2355
2452
 
@@ -2431,6 +2528,7 @@ describe('highcharts_renderer', () => {
2431
2528
  });
2432
2529
 
2433
2530
  it('Formats must be filled and uniq', () => {
2531
+ highchartsRenderer.enabledNewWidgetValueFormatting = false;
2434
2532
  aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
2435
2533
  expect(aggregatorObject.formats).toEqual(['####', '#,###']);
2436
2534
  });
@@ -2477,6 +2575,21 @@ describe('highcharts_renderer', () => {
2477
2575
  aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
2478
2576
  expect(aggregatorObject.ignoreValue).toBe(true);
2479
2577
  });
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
+ });
2480
2593
  });
2481
2594
 
2482
2595
  describe('Value method', () => {
@@ -2528,6 +2641,22 @@ describe('highcharts_renderer', () => {
2528
2641
  aggregatorObject = aggregator({}, ['Region average'], '');
2529
2642
  expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
2530
2643
  });
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
+ });
2531
2660
  });
2532
2661
  });
2533
2662
 
@@ -2609,6 +2738,7 @@ describe('highcharts_renderer', () => {
2609
2738
  });
2610
2739
 
2611
2740
  it('Formats must be filled and uniq', () => {
2741
+ highchartsRenderer.enabledNewWidgetValueFormatting = false;
2612
2742
  aggregatorObject.push({Profit: 123, formats: ['####', '####', '#,###']});
2613
2743
  expect(aggregatorObject.formats).toEqual(['####', '#,###']);
2614
2744
  });
@@ -2655,6 +2785,21 @@ describe('highcharts_renderer', () => {
2655
2785
  aggregatorObject.push({Profit: 20, 'Region average': 'Central', Region: 'Region average'});
2656
2786
  expect(aggregatorObject.ignoreValue).toBe(true);
2657
2787
  });
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
+ });
2658
2803
  });
2659
2804
 
2660
2805
  describe('Value method', () => {
@@ -2706,6 +2851,22 @@ describe('highcharts_renderer', () => {
2706
2851
  aggregatorObject = aggregator({}, ['Region average'], '');
2707
2852
  expect(aggregatorObject.format(1123.45678, false)).toBe('112345.68%');
2708
2853
  });
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
+ });
2709
2870
  });
2710
2871
  });
2711
2872
  });
@@ -4291,4 +4452,144 @@ describe('highcharts_renderer', () => {
4291
4452
  expect(highchartsRenderer.getTrendSeriesName(series)).toBe(expectedName);
4292
4453
  });
4293
4454
  });
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
+ });
4294
4595
  });