@datarailsshared/dr_renderer 1.4.118 → 1.4.128

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.4.118",
3
+ "version": "1.4.128",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -709,7 +709,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
709
709
 
710
710
  if (is_drill_down_pie && (highchartsRenderer.selfStartsWith(series_name, "Series ") || isChartWithMultiValues)) {
711
711
  rows = [];
712
- cols = pivotData.getColKeys()[0];
712
+
713
+ if (isChartWithMultiValues) {
714
+ cols = pivotData.getColKeys()[0];
715
+ }
713
716
  }
714
717
 
715
718
  if (pivotData.rowAttrs.length == 0
@@ -872,7 +875,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
872
875
 
873
876
  if (is_drill_down_pie && (highchartsRenderer.selfStartsWith(series_name,"Series ") || isChartWithMultiValues)) {
874
877
  rows = [];
875
- cols = pivotData.getColKeys()[0];
878
+
879
+ if (isChartWithMultiValues) {
880
+ cols = pivotData.getColKeys()[0];
881
+ }
876
882
  }
877
883
 
878
884
  if (pivotData.rowAttrs.length == 0
@@ -31,7 +31,7 @@ function isAbsoluteValue(formula) {
31
31
  if (!formula)
32
32
  return false;
33
33
 
34
- return lodash.includes(formula.replace(/\s+/g, ''), 'x2-x1');
34
+ return !lodash.includes(formula.replace(/\s+/g, ''), '/');
35
35
  };
36
36
 
37
37
  module.exports = {
@@ -648,15 +648,17 @@ describe('highcharts_renderer', () => {
648
648
  funcContext.y = 500;
649
649
  });
650
650
 
651
- it('should handle drill-down pie when series name starts with "Series "', () => {
651
+ it('should handle drill-down pie when series name starts with "Series " and chart does not have multi values', () => {
652
652
  highchartsRenderer.selfStartsWith.and.returnValue(true);
653
653
  highchartsRenderer.getSeriesNameInFormatterContext.and.returnValue('Series 1');
654
+ highchartsRenderer.isChartWithMultiValues.and.returnValue(false);
654
655
 
655
656
  opts = { chartOptions: {} };
656
657
  let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts, true);
657
658
  let result = fn.call(funcContext);
658
659
 
659
660
  expect(highchartsRenderer.selfStartsWith).toHaveBeenCalledWith('Series 1', 'Series ');
661
+ expect(highchartsRenderer.isChartWithMultiValues).toHaveBeenCalledWith(mockPivotData);
660
662
  expect(result).toBe('500');
661
663
  });
662
664
 
@@ -9,7 +9,8 @@ describe('Function getAggregatorPercentageValueIfRequired', () => {
9
9
  chartOptions: {
10
10
  delta_column: {
11
11
  name: 'Variance',
12
- formula: 'x2-x1'
12
+ formula: 'x2-x1',
13
+ is_percentage: false
13
14
  }
14
15
  }
15
16
  };
@@ -17,7 +18,7 @@ describe('Function getAggregatorPercentageValueIfRequired', () => {
17
18
  colKey = ['SomeCol'];
18
19
  });
19
20
 
20
- it('should return percentage string when all conditions are met', () => {
21
+ it('should return percentage string when secondaryAxisSettings.is_percentage is true but delta_column.is_percentage is false', () => {
21
22
  const data = {
22
23
  rowKeys: ['Variance'],
23
24
  getAggregator: jest.fn(() => ({
@@ -28,6 +29,19 @@ describe('Function getAggregatorPercentageValueIfRequired', () => {
28
29
  expect(result).toBe('25%');
29
30
  });
30
31
 
32
+ it('should return percentage string when secondaryAxisSettings.is_percentage is false but delta_column.is_percentage is true', () => {
33
+ const data = {
34
+ rowKeys: ['Variance'],
35
+ getAggregator: jest.fn(() => ({
36
+ value: () => 200
37
+ }))
38
+ };
39
+ render_options.comboOptions.secondaryAxisSettings.is_percentage = false;
40
+ render_options.chartOptions.delta_column.is_percentage = true;
41
+ const result = getAggregatorPercentageValueIfRequired(50, render_options, data, rowKey, colKey);
42
+ expect(result).toBe('25%');
43
+ });
44
+
31
45
  it('should return null if is_percentage is false', () => {
32
46
  const data = {
33
47
  rowKeys: ['Variance'],
@@ -111,20 +125,19 @@ describe('Function isAbsoluteValue', () => {
111
125
  expect(isAbsoluteValue(null)).toBe(false);
112
126
  });
113
127
 
114
- it('should return false if formula does not contain "x2-x1"', () => {
115
- expect(isAbsoluteValue('x2 + x1')).toBe(false);
116
- expect(isAbsoluteValue('x1-x2')).toBe(false);
117
- expect(isAbsoluteValue('')).toBe(false);
128
+ it('should return false if formula contains "/"', () => {
129
+ expect(isAbsoluteValue('/')).toBe(false);
130
+ expect(isAbsoluteValue(' / ')).toBe(false);
118
131
  });
119
132
 
120
- it('should return true if formula contains "x2-x1"', () => {
133
+ it('should return true if formula does not contain "/"', () => {
121
134
  expect(isAbsoluteValue('x2-x1')).toBe(true);
122
- expect(isAbsoluteValue(' x2 - x1 ')).toBe(true);
135
+ expect(isAbsoluteValue(' x1 - x2 ')).toBe(true);
123
136
  expect(isAbsoluteValue('some text x2-x1 more text')).toBe(true);
124
137
  });
125
138
 
126
139
  it('should ignore spaces in formula', () => {
127
140
  expect(isAbsoluteValue('x2 - x1')).toBe(true);
128
- expect(isAbsoluteValue(' x2 - x1 ')).toBe(true);
141
+ expect(isAbsoluteValue(' x1 - x2 ')).toBe(true);
129
142
  });
130
143
  });