@datarailsshared/dr_renderer 1.2.333 → 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 +1 -1
- package/src/highcharts_renderer.js +16 -51
- package/tests/highcharts_renderer.test.js +45 -24
package/package.json
CHANGED
@@ -3929,11 +3929,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3929
3929
|
|
3930
3930
|
highchartsRenderer.rhPivotCount = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
3931
3931
|
var attr = arg[0];
|
3932
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
3933
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
3934
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
3935
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
3936
|
-
|
3937
3932
|
return function (data, rowKey, colKey) {
|
3938
3933
|
return {
|
3939
3934
|
sum: 0,
|
@@ -3993,11 +3988,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3993
3988
|
number_format = 'General';
|
3994
3989
|
}
|
3995
3990
|
|
3996
|
-
if (this.widget_values_format &&
|
3997
|
-
number_format = this.widget_values_format;
|
3998
|
-
}
|
3999
|
-
|
4000
|
-
if (isCustomValuesFormat) {
|
3991
|
+
if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
|
4001
3992
|
number_format = this.widget_values_format;
|
4002
3993
|
}
|
4003
3994
|
|
@@ -4085,11 +4076,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4085
4076
|
|
4086
4077
|
highchartsRenderer.rhPivotAggregatorSum = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4087
4078
|
var attr = arg[0];
|
4088
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
4089
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
4090
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
4091
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4092
|
-
|
4093
4079
|
return function (data, rowKey, colKey) {
|
4094
4080
|
return {
|
4095
4081
|
sum: 0,
|
@@ -4161,13 +4147,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4161
4147
|
number_format = 'General';
|
4162
4148
|
}
|
4163
4149
|
|
4164
|
-
if (this.widget_values_format &&
|
4150
|
+
if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
|
4165
4151
|
number_format = this.widget_values_format;
|
4166
4152
|
}
|
4167
4153
|
|
4168
|
-
if (isCustomValuesFormat) {
|
4169
|
-
number_format = this.widget_values_format;
|
4170
|
-
}
|
4171
4154
|
number_format = highchartsRenderer.getCalculatedValueFormat(this.calculated_formats, rowKey, colKey) || number_format;
|
4172
4155
|
var formated_value = highchartsRenderer.formatValue('n', number_format, x)
|
4173
4156
|
|
@@ -4185,11 +4168,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4185
4168
|
|
4186
4169
|
highchartsRenderer.rhPivotAggregatorMin = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4187
4170
|
var attr = arg[0];
|
4188
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
4189
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
4190
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
4191
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4192
|
-
|
4193
4171
|
return function (data, rowKey, colKey) {
|
4194
4172
|
return {
|
4195
4173
|
val: null,
|
@@ -4259,11 +4237,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4259
4237
|
number_format = 'General';
|
4260
4238
|
}
|
4261
4239
|
|
4262
|
-
if (this.widget_values_format &&
|
4263
|
-
number_format = this.widget_values_format;
|
4264
|
-
}
|
4265
|
-
|
4266
|
-
if (isCustomValuesFormat) {
|
4240
|
+
if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
|
4267
4241
|
number_format = this.widget_values_format;
|
4268
4242
|
}
|
4269
4243
|
|
@@ -4284,11 +4258,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4284
4258
|
|
4285
4259
|
highchartsRenderer.rhPivotAggregatorMax = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4286
4260
|
var attr = arg[0];
|
4287
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
4288
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
4289
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
4290
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4291
|
-
|
4292
4261
|
return function (data, rowKey, colKey) {
|
4293
4262
|
return {
|
4294
4263
|
val: null,
|
@@ -4359,11 +4328,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4359
4328
|
number_format = 'General';
|
4360
4329
|
}
|
4361
4330
|
|
4362
|
-
if (this.widget_values_format &&
|
4363
|
-
number_format = this.widget_values_format;
|
4364
|
-
}
|
4365
|
-
|
4366
|
-
if (isCustomValuesFormat) {
|
4331
|
+
if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
|
4367
4332
|
number_format = this.widget_values_format;
|
4368
4333
|
}
|
4369
4334
|
|
@@ -4384,11 +4349,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4384
4349
|
|
4385
4350
|
highchartsRenderer.rhPivotAggregatorAverage = function (arg, widget_values_format, is_graph, render_options, calculated_info) {
|
4386
4351
|
var attr = arg[0];
|
4387
|
-
// isCustomValues format need for check in case when customer apply SecondaryAxis and one of them is true
|
4388
|
-
// in that case we take formats from seriesOptions and apply those format to each one of them their format from the table
|
4389
|
-
// method isCustomValuesFormat check if format was added custom format by self or it's a default format from table
|
4390
|
-
const isCustomValuesFormat = highchartsRenderer.isCustomValuesFormat(render_options, widget_values_format);
|
4391
|
-
|
4392
4352
|
return function (data, rowKey, colKey) {
|
4393
4353
|
return {
|
4394
4354
|
sum: 0,
|
@@ -4466,11 +4426,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4466
4426
|
number_format = 'General';
|
4467
4427
|
}
|
4468
4428
|
|
4469
|
-
if (this.widget_values_format &&
|
4470
|
-
number_format = this.widget_values_format;
|
4471
|
-
}
|
4472
|
-
|
4473
|
-
if (isCustomValuesFormat) {
|
4429
|
+
if (this.widget_values_format && highchartsRenderer.isUsingWidgetValuesFormat(data, render_options, widget_values_format)) {
|
4474
4430
|
number_format = this.widget_values_format;
|
4475
4431
|
}
|
4476
4432
|
|
@@ -9331,6 +9287,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9331
9287
|
}
|
9332
9288
|
}
|
9333
9289
|
|
9290
|
+
// Check if chart has multiple values
|
9291
|
+
highchartsRenderer.isChartWithMultiValues = function(pivotData) {
|
9292
|
+
return lodash.get(pivotData, 'rowAttrs[0]') === 'DR_Values';
|
9293
|
+
}
|
9294
|
+
|
9334
9295
|
highchartsRenderer.checkFormats = function(render_options, widget_values_format) {
|
9335
9296
|
let isSecondaryAxis = false;
|
9336
9297
|
let formats = [];
|
@@ -9353,9 +9314,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9353
9314
|
return formats;
|
9354
9315
|
}
|
9355
9316
|
|
9356
|
-
|
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) {
|
9357
9322
|
const { isSecondaryAxis, isCustomFormat } = highchartsRenderer.checkFormats(render_options, widget_values_format);
|
9358
|
-
return highchartsRenderer.enabledNewWidgetValueFormatting
|
9323
|
+
return !highchartsRenderer.enabledNewWidgetValueFormatting || !highchartsRenderer.isChartWithMultiValues(pivotData) || !isSecondaryAxis || isCustomFormat;
|
9359
9324
|
}
|
9360
9325
|
|
9361
9326
|
highchartsRenderer.isFormattingAxis = function () {
|
@@ -4741,8 +4741,18 @@ describe('highcharts_renderer', () => {
|
|
4741
4741
|
});
|
4742
4742
|
});
|
4743
4743
|
|
4744
|
-
describe('function
|
4745
|
-
|
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
|
4755
|
-
const
|
4756
|
-
|
4757
|
-
highchartsRenderer.enabledNewWidgetValueFormatting =
|
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
|
-
|
4769
|
+
const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptions, widgetValuesFormat);
|
4770
|
+
expect(result).toEqual(true);
|
4764
4771
|
});
|
4765
4772
|
|
4766
|
-
it('should return
|
4767
|
-
const
|
4768
|
-
|
4769
|
-
highchartsRenderer.enabledNewWidgetValueFormatting =
|
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
|
4778
|
+
const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptions, widgetValuesFormat);
|
4779
|
+
expect(result).toEqual(true);
|
4780
|
+
});
|
4772
4781
|
|
4773
|
-
|
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
|
-
|
4789
|
+
const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptionsNoSecondary, widgetValuesFormat);
|
4790
|
+
expect(result).toEqual(true);
|
4776
4791
|
});
|
4777
4792
|
|
4778
|
-
it('should return
|
4779
|
-
const
|
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
|
4798
|
+
const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptions, widgetValuesFormat);
|
4799
|
+
expect(result).toEqual(true);
|
4800
|
+
});
|
4784
4801
|
|
4785
|
-
|
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
|
-
|
4807
|
+
const result = highchartsRenderer.isUsingWidgetValuesFormat(pivotData, renderOptions, widgetValuesFormat);
|
4808
|
+
expect(result).toEqual(false);
|
4788
4809
|
});
|
4789
4810
|
});
|
4790
4811
|
|