@datarailsshared/dr_renderer 1.2.332 → 1.2.334

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.332",
3
+ "version": "1.2.334",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -3484,11 +3484,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3484
3484
  return "";
3485
3485
  },
3486
3486
  style: lodash.merge(
3487
- highchartsRenderer.getDataLabelsStyle(additionOptions),
3487
+ LABEL_DEFAULT_OPTIONS.style,
3488
3488
  {
3489
- fontWeight: 'normal',
3490
- color: (highchartsRenderer.highcharts_theme && highchartsRenderer.highcharts_theme.textColor) || 'gray'
3491
- }
3489
+ color: lodash.get(additionOptions, `${ highchartsRenderer.getLabelOptionKey(additionOptions) }.font_color`)
3490
+ || LABEL_DEFAULT_OPTIONS.color,
3491
+ },
3492
+ highchartsRenderer.getDataLabelsStyle(additionOptions),
3492
3493
  ),
3493
3494
  },
3494
3495
  labels: {
@@ -3928,11 +3929,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3928
3929
 
3929
3930
  highchartsRenderer.rhPivotCount = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
3930
3931
  var attr = arg[0];
3931
- // isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
3932
- // in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
3933
- // method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
3934
- const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
3935
-
3936
3932
  return function (data, rowKey, colKey) {
3937
3933
  return {
3938
3934
  sum: 0,
@@ -3992,11 +3988,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3992
3988
  number_format = 'General';
3993
3989
  }
3994
3990
 
3995
- if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
3996
- number_format = this.widget_values_format;
3997
- }
3998
-
3999
- if (isCustomValuesFormat) {
3991
+ if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
4000
3992
  number_format = this.widget_values_format;
4001
3993
  }
4002
3994
 
@@ -4084,11 +4076,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4084
4076
 
4085
4077
  highchartsRenderer.rhPivotAggregatorSum = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4086
4078
  var attr = arg[0];
4087
- // isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
4088
- // in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
4089
- // method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
4090
- const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
4091
-
4092
4079
  return function (data, rowKey, colKey) {
4093
4080
  return {
4094
4081
  sum: 0,
@@ -4160,13 +4147,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4160
4147
  number_format = 'General';
4161
4148
  }
4162
4149
 
4163
- if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
4150
+ if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
4164
4151
  number_format = this.widget_values_format;
4165
4152
  }
4166
4153
 
4167
- if (isCustomValuesFormat) {
4168
- number_format = this.widget_values_format;
4169
- }
4170
4154
  number_format = highchartsRenderer.getCalculatedValueFormat(this.calculated_formats, rowKey, colKey) || number_format;
4171
4155
  var formated_value = highchartsRenderer.formatValue('n', number_format, x)
4172
4156
 
@@ -4184,11 +4168,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4184
4168
 
4185
4169
  highchartsRenderer.rhPivotAggregatorMin = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4186
4170
  var attr = arg[0];
4187
- // isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
4188
- // in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
4189
- // method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
4190
- const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
4191
-
4192
4171
  return function (data, rowKey, colKey) {
4193
4172
  return {
4194
4173
  val: null,
@@ -4258,11 +4237,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4258
4237
  number_format = 'General';
4259
4238
  }
4260
4239
 
4261
- if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
4262
- number_format = this.widget_values_format;
4263
- }
4264
-
4265
- if (isCustomValuesFormat) {
4240
+ if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
4266
4241
  number_format = this.widget_values_format;
4267
4242
  }
4268
4243
 
@@ -4283,11 +4258,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4283
4258
 
4284
4259
  highchartsRenderer.rhPivotAggregatorMax = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4285
4260
  var attr = arg[0];
4286
- // isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
4287
- // in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
4288
- // method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
4289
- const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
4290
-
4291
4261
  return function (data, rowKey, colKey) {
4292
4262
  return {
4293
4263
  val: null,
@@ -4358,11 +4328,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4358
4328
  number_format = 'General';
4359
4329
  }
4360
4330
 
4361
- if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
4362
- number_format = this.widget_values_format;
4363
- }
4364
-
4365
- if (isCustomValuesFormat) {
4331
+ if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
4366
4332
  number_format = this.widget_values_format;
4367
4333
  }
4368
4334
 
@@ -4383,11 +4349,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4383
4349
 
4384
4350
  highchartsRenderer.rhPivotAggregatorAverage = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
4385
4351
  var attr = arg[0];
4386
- // isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
4387
- // in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
4388
- // method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
4389
- const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
4390
-
4391
4352
  return function (data, rowKey, colKey) {
4392
4353
  return {
4393
4354
  sum: 0,
@@ -4465,11 +4426,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4465
4426
  number_format = 'General';
4466
4427
  }
4467
4428
 
4468
- if (this.widget_values_format && !highchartsRenderer.enabledNewWidgetValueFormatting) {
4469
- number_format = this.widget_values_format;
4470
- }
4471
-
4472
- if (isCustomValuesFormat) {
4429
+ if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
4473
4430
  number_format = this.widget_values_format;
4474
4431
  }
4475
4432
 
@@ -9330,6 +9287,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9330
9287
  }
9331
9288
  }
9332
9289
 
9290
+ // Check if chart has multiple values
9291
+ highchartsRenderer.isChartWithMultiValues = function(pivotData) {
9292
+ return lodash.get(pivotData, 'rowAttrs[0]') === 'DR_Values';
9293
+ }
9294
+
9333
9295
  highchartsRenderer.checkFormats = function(render_options, widget_values_format) {
9334
9296
  let isSecondaryAxis = false;
9335
9297
  let formats = [];
@@ -9352,9 +9314,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9352
9314
  return formats;
9353
9315
  }
9354
9316
 
9355
- highchartsRenderer.isCustomValuesFormat = function (render_options, widget_values_format) {
9317
+ // Will be FALSE when all 4 conditions true: 1. User applies SecondaryAxis 2. Format on 'format editor panel' is same as any Value field table format
9318
+ // 3. Chart has more than one value fields in Values block 4. enable_new_widget_value_formatting is turned ON
9319
+ // In that case we apply for both value fields their format from the table
9320
+ // In all other cases we are applying format from editor panel to both of them (specification: DR-20955)
9321
+ highchartsRenderer.isUsingWidgetValuesFormat = function (pivotData, render_options, widget_values_format) {
9356
9322
  const { isSecondaryAxis, isCustomFormat } = highchartsRenderer.checkFormats(render_options, widget_values_format);
9357
- return highchartsRenderer.enabledNewWidgetValueFormatting && (isCustomFormat || !isSecondaryAxis);
9323
+ return !highchartsRenderer.enabledNewWidgetValueFormatting || !highchartsRenderer.isChartWithMultiValues(pivotData) || !isSecondaryAxis || isCustomFormat;
9358
9324
  }
9359
9325
 
9360
9326
  highchartsRenderer.isFormattingAxis = function () {
@@ -4741,8 +4741,18 @@ describe('highcharts_renderer', () => {
4741
4741
  });
4742
4742
  });
4743
4743
 
4744
- describe('function isCustomValuesFormat', () => {
4745
- const render_options = {
4744
+ describe('function isChartWithMultiValues', () => {
4745
+ it('should return true if DR_Values in attributes', () => {
4746
+ expect(highchartsRenderer.isChartWithMultiValues({ rowAttrs: ['DR_Values'] })).toEqual(true);
4747
+ });
4748
+
4749
+ it('should return false if no DR_Values in attributes', () => {
4750
+ expect(highchartsRenderer.isChartWithMultiValues({ rowAttrs: ['Profit'] })).toEqual(false);
4751
+ });
4752
+ });
4753
+
4754
+ describe('function isUsingWidgetValuesFormat', () => {
4755
+ const renderOptions = {
4746
4756
  comboOptions: {
4747
4757
  seriesOptions: [
4748
4758
  { series: 'Profit', format: '#,###', secondaryAxis: false },
@@ -4751,40 +4761,51 @@ describe('highcharts_renderer', () => {
4751
4761
  }
4752
4762
  };
4753
4763
 
4754
- it('should return true if new widget value formatting is enabled and the format is custom or there is no secondary axis', () => {
4755
- const widget_values_format = '$####.##';
4756
-
4757
- highchartsRenderer.enabledNewWidgetValueFormatting = true;
4758
-
4759
- const expectedValue = true;
4760
-
4761
- const result = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
4764
+ it('should return true (enable_new_widget_value_formatting !== true, format is not custom, secondary axis present, >1 value fields)', () => {
4765
+ const widgetValuesFormat = '#,###';
4766
+ const pivotData = { rowAttrs: ['DR_Values'] };
4767
+ highchartsRenderer.enabledNewWidgetValueFormatting = false;
4762
4768
 
4763
- expect(result).toEqual(expectedValue);
4769
+ const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptions, widgetValuesFormat);
4770
+ expect(result).toEqual(true);
4764
4771
  });
4765
4772
 
4766
- it('should return false if new widget value formatting is disabled', () => {
4767
- const widget_values_format = '#,###';
4768
-
4769
- highchartsRenderer.enabledNewWidgetValueFormatting = false;
4773
+ it('should return true (enable_new_widget_value_formatting === true, format is custom, secondary axis present, >1 value fields)', () => {
4774
+ const widgetValuesFormat = '$#,###';
4775
+ const pivotData = { rowAttrs: ['DR_Values'] };
4776
+ highchartsRenderer.enabledNewWidgetValueFormatting = true;
4770
4777
 
4771
- const expectedValue = false;
4778
+ const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptions, widgetValuesFormat);
4779
+ expect(result).toEqual(true);
4780
+ });
4772
4781
 
4773
- const result = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
4782
+ it('should return true (enable_new_widget_value_formatting === true, format is not custom, secondary axis not present, >1 value fields)', () => {
4783
+ const widgetValuesFormat = '#,###';
4784
+ const pivotData = { rowAttrs: ['DR_Values'] };
4785
+ highchartsRenderer.enabledNewWidgetValueFormatting = true;
4786
+ const renderOptionsNoSecondary = lodash.cloneDeep(renderOptions);
4787
+ renderOptionsNoSecondary.comboOptions.seriesOptions[1].secondaryAxis = false;
4774
4788
 
4775
- expect(result).toEqual(expectedValue);
4789
+ const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptionsNoSecondary, widgetValuesFormat);
4790
+ expect(result).toEqual(true);
4776
4791
  });
4777
4792
 
4778
- it('should return false if the format is not custom and there is a secondary axis', () => {
4779
- const widget_values_format = '#,###';
4780
-
4793
+ it('should return true (enable_new_widget_value_formatting === true, format is not custom, secondary axis present, 1 value fields)', () => {
4794
+ const widgetValuesFormat = '#,###';
4795
+ const pivotData = { rowAttrs: ['Profit'] };
4781
4796
  highchartsRenderer.enabledNewWidgetValueFormatting = true;
4782
4797
 
4783
- const expectedValue = false;
4798
+ const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptions, widgetValuesFormat);
4799
+ expect(result).toEqual(true);
4800
+ });
4784
4801
 
4785
- const result = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
4802
+ it('should return false (enable_new_widget_value_formatting === true, format is not custom, secondary axis present, >1 value fields)', () => {
4803
+ const widgetValuesFormat = '#,###';
4804
+ const pivotData = { rowAttrs: ['DR_Values'] };
4805
+ highchartsRenderer.enabledNewWidgetValueFormatting = true;
4786
4806
 
4787
- expect(result).toEqual(expectedValue);
4807
+ const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptions, widgetValuesFormat);
4808
+ expect(result).toEqual(false);
4788
4809
  });
4789
4810
  });
4790
4811