@datarailsshared/dr_renderer 1.5.88 → 1.5.90
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-renderer-helpers.js +0 -6
- package/src/dr_pivottable.js +1 -192
- package/src/highcharts_renderer.js +13 -354
- package/src/pivottable.js +7 -653
- package/tests/dr-renderer-helpers.test.js +0 -32
- package/tests/highcharts_renderer.test.js +116 -244
|
@@ -2052,13 +2052,10 @@ describe('highcharts_renderer', () => {
|
|
|
2052
2052
|
|
|
2053
2053
|
it('should take old row data on second time', () => {
|
|
2054
2054
|
const rowData = { rowData: '123' };
|
|
2055
|
-
const sorters = { sorters: '123' };
|
|
2056
2055
|
highchartsRenderer.addTemplateDataToWidgetOptions(template, widget, false);
|
|
2057
2056
|
widget.pivot.rowData = rowData;
|
|
2058
|
-
widget.pivot.sorters = sorters;
|
|
2059
2057
|
highchartsRenderer.addTemplateDataToWidgetOptions(template, widget, false);
|
|
2060
2058
|
expect(widget.pivot.rowData).toBe(rowData);
|
|
2061
|
-
expect(widget.pivot.sorters).toBe(sorters);
|
|
2062
2059
|
});
|
|
2063
2060
|
});
|
|
2064
2061
|
|
|
@@ -3702,7 +3699,7 @@ describe('highcharts_renderer', () => {
|
|
|
3702
3699
|
expect(highchartsRenderer.getCommonChartOptions(additionalOptions)).toEqual(expected);
|
|
3703
3700
|
});
|
|
3704
3701
|
});
|
|
3705
|
-
|
|
3702
|
+
|
|
3706
3703
|
describe('function getDataLabelsStyle', () => {
|
|
3707
3704
|
it('returns default style if additionalOptions is empty', () => {
|
|
3708
3705
|
const additionalOptions = {};
|
|
@@ -3839,7 +3836,7 @@ describe('highcharts_renderer', () => {
|
|
|
3839
3836
|
expect(result).toEqual(expected);
|
|
3840
3837
|
});
|
|
3841
3838
|
});
|
|
3842
|
-
|
|
3839
|
+
|
|
3843
3840
|
describe('function getLabelOptionKey', () => {
|
|
3844
3841
|
it('should return null if additionalOptions is not defined', () => {
|
|
3845
3842
|
const result = highchartsRenderer.getLabelOptionKey(undefined);
|
|
@@ -3876,7 +3873,7 @@ describe('highcharts_renderer', () => {
|
|
|
3876
3873
|
expect(result).toBe('label_option1');
|
|
3877
3874
|
});
|
|
3878
3875
|
});
|
|
3879
|
-
|
|
3876
|
+
|
|
3880
3877
|
describe('function getDefaultValueForSubOptions', () => {
|
|
3881
3878
|
const suboptions = {
|
|
3882
3879
|
option1: {
|
|
@@ -3988,7 +3985,7 @@ describe('highcharts_renderer', () => {
|
|
|
3988
3985
|
expect(result.value1).not.toBe(suboptions.option3.elements[0].default_value);
|
|
3989
3986
|
});
|
|
3990
3987
|
});
|
|
3991
|
-
|
|
3988
|
+
|
|
3992
3989
|
describe('function getChartAxisLabel', () => {
|
|
3993
3990
|
it('should return default value', () => {
|
|
3994
3991
|
expect(highchartsRenderer.getChartAxisLabel('invalidType')).toBe('Axis (Category)')
|
|
@@ -4352,7 +4349,7 @@ describe('highcharts_renderer', () => {
|
|
|
4352
4349
|
expect(() => highchartsRenderer.parseOptionsToObject(str)).toThrow();
|
|
4353
4350
|
});
|
|
4354
4351
|
});
|
|
4355
|
-
|
|
4352
|
+
|
|
4356
4353
|
describe('function isDate', () => {
|
|
4357
4354
|
it('returns true for valid date string', () => {
|
|
4358
4355
|
expect(highchartsRenderer.isDate('2022-01-01')).toBe(true);
|
|
@@ -4745,7 +4742,7 @@ describe('highcharts_renderer', () => {
|
|
|
4745
4742
|
describe('function transformRowsAndColsForBreakdown', () => {
|
|
4746
4743
|
let point;
|
|
4747
4744
|
let opts;
|
|
4748
|
-
|
|
4745
|
+
|
|
4749
4746
|
beforeEach(() => {
|
|
4750
4747
|
point = {
|
|
4751
4748
|
options: {},
|
|
@@ -5089,6 +5086,10 @@ describe('highcharts_renderer', () => {
|
|
|
5089
5086
|
});
|
|
5090
5087
|
|
|
5091
5088
|
describe('formatting Dates', () => {
|
|
5089
|
+
afterEach(() => {
|
|
5090
|
+
lodash.set(document, 'ReportHippo.user.features', []);
|
|
5091
|
+
});
|
|
5092
|
+
|
|
5092
5093
|
it('should return formatted multivalue colKey as array (format_dates_as_other_axis_types is ON)', () => {
|
|
5093
5094
|
lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types']);
|
|
5094
5095
|
const initialKey = [1687277052, 1687277052];
|
|
@@ -5136,6 +5137,29 @@ describe('highcharts_renderer', () => {
|
|
|
5136
5137
|
const formattedKey = highchartsRenderer.getFormattedKey(initialKeyAlreadyFormatted, pivotData, type);
|
|
5137
5138
|
expect(formattedKey).toEqual(initialKeyAlreadyFormatted);
|
|
5138
5139
|
});
|
|
5140
|
+
|
|
5141
|
+
it('should return NOT formatted value when type is Date but value is not a valid moment date', () => {
|
|
5142
|
+
lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types']);
|
|
5143
|
+
const initialKey = ['Some Text Value', 'Another Text'];
|
|
5144
|
+
const pivotData = {
|
|
5145
|
+
colFormats: [{ type: 'Date' }, { type: 'Date' }],
|
|
5146
|
+
isFormattingAxisLabels: true,
|
|
5147
|
+
};
|
|
5148
|
+
const type = 'colFormats';
|
|
5149
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
|
5150
|
+
expect(formattedKey).toEqual(initialKey);
|
|
5151
|
+
});
|
|
5152
|
+
|
|
5153
|
+
it('should return formatted value when type is Date and value is a valid moment date (format_dates_as_other_axis_types is OFF)', () => {
|
|
5154
|
+
const initialKey = ['Feb-24', 'Jan-24'];
|
|
5155
|
+
const pivotData = {
|
|
5156
|
+
colFormats: [{ type: 'Date' }, { type: 'Date' }],
|
|
5157
|
+
isFormattingAxisLabels: true,
|
|
5158
|
+
};
|
|
5159
|
+
const type = 'colFormats';
|
|
5160
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
|
5161
|
+
expect(formattedKey).toEqual(initialKey);
|
|
5162
|
+
});
|
|
5139
5163
|
});
|
|
5140
5164
|
});
|
|
5141
5165
|
|
|
@@ -5285,7 +5309,7 @@ describe('highcharts_renderer', () => {
|
|
|
5285
5309
|
describe('Function getSeriesNameInFormatterContext', () => {
|
|
5286
5310
|
|
|
5287
5311
|
const name1 = 'test series name';
|
|
5288
|
-
const name2 = 'test series name 2';
|
|
5312
|
+
const name2 = 'test series name 2';
|
|
5289
5313
|
|
|
5290
5314
|
const pivotData = {
|
|
5291
5315
|
isFormattingAxisLabels: true,
|
|
@@ -5316,7 +5340,7 @@ describe('highcharts_renderer', () => {
|
|
|
5316
5340
|
describe('Function getColsInFormatterContext', () => {
|
|
5317
5341
|
|
|
5318
5342
|
const name1 = 'test series name 1';
|
|
5319
|
-
const name2 = 'test series name 2';
|
|
5343
|
+
const name2 = 'test series name 2';
|
|
5320
5344
|
const name3 = 'test series name 3';
|
|
5321
5345
|
const pivotData = {
|
|
5322
5346
|
isFormattingAxisLabels: true,
|
|
@@ -5368,170 +5392,6 @@ describe('highcharts_renderer', () => {
|
|
|
5368
5392
|
});
|
|
5369
5393
|
|
|
5370
5394
|
|
|
5371
|
-
describe('Function replaceSortingKeysWithMappedValues', () => {
|
|
5372
|
-
it('should replace sorting keys with mapped values for Date fields', () => {
|
|
5373
|
-
const keysObject = {
|
|
5374
|
-
col_keys: [
|
|
5375
|
-
[1640995200],
|
|
5376
|
-
[1648684800],
|
|
5377
|
-
[1667174400]
|
|
5378
|
-
],
|
|
5379
|
-
row_keys: [],
|
|
5380
|
-
row_keys_by_cols: [
|
|
5381
|
-
[
|
|
5382
|
-
["Other Income"],
|
|
5383
|
-
["Other Expense"],
|
|
5384
|
-
["Income"],
|
|
5385
|
-
["Expenses"],
|
|
5386
|
-
["Cost of Goods Sold"]
|
|
5387
|
-
]
|
|
5388
|
-
]
|
|
5389
|
-
};
|
|
5390
|
-
const invertedDateStringMap = {
|
|
5391
|
-
1640995200: '2022-01-01',
|
|
5392
|
-
1648684800: '2022-03-29',
|
|
5393
|
-
1667174400: '2023-03-01'
|
|
5394
|
-
};
|
|
5395
|
-
const widget = {
|
|
5396
|
-
cols: [{ type: 'Date' }],
|
|
5397
|
-
rows: [{ type: 'NotDate' }],
|
|
5398
|
-
pivot: {
|
|
5399
|
-
keysObject: keysObject
|
|
5400
|
-
}
|
|
5401
|
-
};
|
|
5402
|
-
|
|
5403
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.col_keys, invertedDateStringMap, widget.cols);
|
|
5404
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.row_keys, invertedDateStringMap, widget.rows);
|
|
5405
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.row_keys_by_cols, invertedDateStringMap, widget.rows);
|
|
5406
|
-
|
|
5407
|
-
expect(keysObject).toEqual({
|
|
5408
|
-
col_keys: [
|
|
5409
|
-
['2022-01-01'],
|
|
5410
|
-
['2022-03-29'],
|
|
5411
|
-
['2023-03-01']
|
|
5412
|
-
],
|
|
5413
|
-
row_keys: [],
|
|
5414
|
-
row_keys_by_cols: [
|
|
5415
|
-
[
|
|
5416
|
-
['Other Income'],
|
|
5417
|
-
['Other Expense'],
|
|
5418
|
-
['Income'],
|
|
5419
|
-
['Expenses'],
|
|
5420
|
-
['Cost of Goods Sold']
|
|
5421
|
-
]
|
|
5422
|
-
]
|
|
5423
|
-
});
|
|
5424
|
-
});
|
|
5425
|
-
|
|
5426
|
-
it('should not replace sorting keys for non-Date fields', () => {
|
|
5427
|
-
const keysObject = {
|
|
5428
|
-
col_keys: [
|
|
5429
|
-
[1640995200],
|
|
5430
|
-
[1648684800],
|
|
5431
|
-
[1667174400]
|
|
5432
|
-
],
|
|
5433
|
-
row_keys: [],
|
|
5434
|
-
row_keys_by_cols: [
|
|
5435
|
-
[
|
|
5436
|
-
["Other Income"],
|
|
5437
|
-
["Other Expense"],
|
|
5438
|
-
["Income"],
|
|
5439
|
-
["Expenses"],
|
|
5440
|
-
["Cost of Goods Sold"]
|
|
5441
|
-
]
|
|
5442
|
-
]
|
|
5443
|
-
};
|
|
5444
|
-
const invertedDateStringMap = {
|
|
5445
|
-
1640995200: '2022-01-01',
|
|
5446
|
-
1648684800: '2022-03-29',
|
|
5447
|
-
1667174400: '2023-03-01'
|
|
5448
|
-
};
|
|
5449
|
-
const widget = {
|
|
5450
|
-
cols: [{ type: 'NotDate' }],
|
|
5451
|
-
rows: [{ type: 'NotDate' }],
|
|
5452
|
-
pivot: {
|
|
5453
|
-
keysObject: keysObject
|
|
5454
|
-
}
|
|
5455
|
-
};
|
|
5456
|
-
|
|
5457
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.col_keys, invertedDateStringMap, widget.cols);
|
|
5458
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.row_keys, invertedDateStringMap, widget.rows);
|
|
5459
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.row_keys_by_cols, invertedDateStringMap, widget.rows);
|
|
5460
|
-
|
|
5461
|
-
expect(keysObject).toEqual({
|
|
5462
|
-
col_keys: [
|
|
5463
|
-
[1640995200],
|
|
5464
|
-
[1648684800],
|
|
5465
|
-
[1667174400]
|
|
5466
|
-
],
|
|
5467
|
-
row_keys: [],
|
|
5468
|
-
row_keys_by_cols: [
|
|
5469
|
-
[
|
|
5470
|
-
["Other Income"],
|
|
5471
|
-
["Other Expense"],
|
|
5472
|
-
["Income"],
|
|
5473
|
-
["Expenses"],
|
|
5474
|
-
["Cost of Goods Sold"]
|
|
5475
|
-
]
|
|
5476
|
-
]
|
|
5477
|
-
});
|
|
5478
|
-
});
|
|
5479
|
-
|
|
5480
|
-
it('should handle null or undefined keysObject', () => {
|
|
5481
|
-
const invertedDateStringMap = {
|
|
5482
|
-
1640995200: '2022-01-01',
|
|
5483
|
-
1648684800: '2022-03-29',
|
|
5484
|
-
1667174400: '2023-03-01'
|
|
5485
|
-
};
|
|
5486
|
-
const widget = {
|
|
5487
|
-
cols: [{ type: 'Date' }],
|
|
5488
|
-
rows: [{ type: 'NotDate' }],
|
|
5489
|
-
pivot: {
|
|
5490
|
-
keysObject: null
|
|
5491
|
-
}
|
|
5492
|
-
};
|
|
5493
|
-
|
|
5494
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.cols);
|
|
5495
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.rows);
|
|
5496
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.rows);
|
|
5497
|
-
});
|
|
5498
|
-
|
|
5499
|
-
// This test was added to cover an edge case where multiple Date fields have the same date values
|
|
5500
|
-
// but require different formatting based on their individual field settings
|
|
5501
|
-
// Fixes the issue - https://datarailsteam.atlassian.net/browse/DR-37813
|
|
5502
|
-
// Will be removed once "format_dates_as_other_axis_types" FF is deleted
|
|
5503
|
-
it('should reformat dates when widget fields have same dates, but different formats', () => {
|
|
5504
|
-
const keysObject = {
|
|
5505
|
-
col_keys: [
|
|
5506
|
-
[1648684800, 1648684800, 1648684800],
|
|
5507
|
-
],
|
|
5508
|
-
row_keys: [],
|
|
5509
|
-
row_keys_by_cols: [],
|
|
5510
|
-
};
|
|
5511
|
-
|
|
5512
|
-
const invertedDateStringMap = {
|
|
5513
|
-
1648684800: '03/31/2022',
|
|
5514
|
-
};
|
|
5515
|
-
|
|
5516
|
-
const widget = {
|
|
5517
|
-
cols: [
|
|
5518
|
-
{ type: 'Date', format: null }, // Default format MM/DD/YYYY
|
|
5519
|
-
{ type: 'Date', format: 'MM-DD-YYYY' },
|
|
5520
|
-
{ type: 'Date', format: 'DD/MM/YYYY' },
|
|
5521
|
-
],
|
|
5522
|
-
rows: [],
|
|
5523
|
-
pivot: { keysObject },
|
|
5524
|
-
};
|
|
5525
|
-
|
|
5526
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.col_keys, invertedDateStringMap, widget.cols);
|
|
5527
|
-
|
|
5528
|
-
expect(keysObject.col_keys[0][0]).toBe('03/31/2022');
|
|
5529
|
-
expect(keysObject.col_keys[0][1]).toBe('03-31-2022');
|
|
5530
|
-
expect(keysObject.col_keys[0][2]).toBe('31/03/2022');
|
|
5531
|
-
});
|
|
5532
|
-
});
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
5395
|
describe('Functions getAggregatedSortingObjects', () => {
|
|
5536
5396
|
|
|
5537
5397
|
const simpleRowData = [{ someField1: 'someValue1' }, { someField2: 'someValue2' }];
|
|
@@ -5559,7 +5419,7 @@ describe('highcharts_renderer', () => {
|
|
|
5559
5419
|
it(testCase.description, () => {
|
|
5560
5420
|
const rowData = lodash.concat(simpleRowData, testCase.expectedObj ? lodash.clone(testCase.expectedObj) : []);
|
|
5561
5421
|
const sortObj = highchartsRenderer.getAggregatedSortingObjects(rowData);
|
|
5562
|
-
|
|
5422
|
+
|
|
5563
5423
|
expect(rowData).toEqual(simpleRowData);
|
|
5564
5424
|
expect(sortObj).toEqual(testCase.expectedObj);
|
|
5565
5425
|
});
|
|
@@ -5635,7 +5495,7 @@ describe('highcharts_renderer', () => {
|
|
|
5635
5495
|
getAggregator: (rows, cols) => {
|
|
5636
5496
|
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
|
5637
5497
|
const agg = aggregator({}, '', '');
|
|
5638
|
-
|
|
5498
|
+
|
|
5639
5499
|
if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, ['row 1'])) {
|
|
5640
5500
|
agg.sum = 12345;
|
|
5641
5501
|
} else if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, [])) {
|
|
@@ -5660,7 +5520,7 @@ describe('highcharts_renderer', () => {
|
|
|
5660
5520
|
getRowKeys: () => [['row 1'], ['row 2'], ['row 3']],
|
|
5661
5521
|
rowAttrs: ['row 1'],
|
|
5662
5522
|
};
|
|
5663
|
-
|
|
5523
|
+
|
|
5664
5524
|
optsMock = {
|
|
5665
5525
|
total_value_options: {
|
|
5666
5526
|
filter_options: {
|
|
@@ -5675,7 +5535,7 @@ describe('highcharts_renderer', () => {
|
|
|
5675
5535
|
},
|
|
5676
5536
|
},
|
|
5677
5537
|
};
|
|
5678
|
-
|
|
5538
|
+
|
|
5679
5539
|
displayTooltipContext = {
|
|
5680
5540
|
series: {
|
|
5681
5541
|
options: {
|
|
@@ -5734,7 +5594,7 @@ describe('highcharts_renderer', () => {
|
|
|
5734
5594
|
const tooltipFunction =
|
|
5735
5595
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5736
5596
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5737
|
-
|
|
5597
|
+
|
|
5738
5598
|
expect(tooltipHtml).toEqual(
|
|
5739
5599
|
'<br/><span style="font-weight: bold; color: green;">\u200Erow 1</span>: <span>\u200E$12,345.00</span>'
|
|
5740
5600
|
);
|
|
@@ -5746,7 +5606,7 @@ describe('highcharts_renderer', () => {
|
|
|
5746
5606
|
const tooltipFunction =
|
|
5747
5607
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5748
5608
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5749
|
-
|
|
5609
|
+
|
|
5750
5610
|
expect(tooltipHtml).toEqual(
|
|
5751
5611
|
`<span style="font-weight: bold;">
|
|
5752
5612
|
col 1
|
|
@@ -5761,7 +5621,7 @@ describe('highcharts_renderer', () => {
|
|
|
5761
5621
|
const tooltipFunction =
|
|
5762
5622
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5763
5623
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5764
|
-
|
|
5624
|
+
|
|
5765
5625
|
expect(tooltipHtml).toEqual(
|
|
5766
5626
|
`<span style="font-weight: bold;">
|
|
5767
5627
|
col 1
|
|
@@ -5777,7 +5637,7 @@ describe('highcharts_renderer', () => {
|
|
|
5777
5637
|
const tooltipFunction =
|
|
5778
5638
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5779
5639
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5780
|
-
|
|
5640
|
+
|
|
5781
5641
|
expect(tooltipHtml).toEqual(
|
|
5782
5642
|
`<span style="font-weight: bold;">
|
|
5783
5643
|
col 1
|
|
@@ -5797,7 +5657,7 @@ describe('highcharts_renderer', () => {
|
|
|
5797
5657
|
const tooltipFunction =
|
|
5798
5658
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5799
5659
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5800
|
-
|
|
5660
|
+
|
|
5801
5661
|
expect(tooltipHtml).toEqual(
|
|
5802
5662
|
`<span style="font-weight: bold;">
|
|
5803
5663
|
col 1
|
|
@@ -5813,7 +5673,7 @@ describe('highcharts_renderer', () => {
|
|
|
5813
5673
|
const tooltipFunction =
|
|
5814
5674
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5815
5675
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5816
|
-
|
|
5676
|
+
|
|
5817
5677
|
expect(tooltipHtml).toEqual(
|
|
5818
5678
|
`<span style="font-weight: bold;">
|
|
5819
5679
|
col 1,col 2
|
|
@@ -5828,7 +5688,7 @@ describe('highcharts_renderer', () => {
|
|
|
5828
5688
|
const tooltipFunction =
|
|
5829
5689
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5830
5690
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5831
|
-
|
|
5691
|
+
|
|
5832
5692
|
expect(tooltipHtml).toEqual(
|
|
5833
5693
|
`<span style="font-weight: bold;">
|
|
5834
5694
|
col 1
|
|
@@ -5842,7 +5702,7 @@ describe('highcharts_renderer', () => {
|
|
|
5842
5702
|
const tooltipFunction =
|
|
5843
5703
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5844
5704
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5845
|
-
|
|
5705
|
+
|
|
5846
5706
|
expect(tooltipHtml).toEqual(
|
|
5847
5707
|
`<span style="font-weight: bold;">
|
|
5848
5708
|
${ othersName }
|
|
@@ -5872,7 +5732,7 @@ describe('highcharts_renderer', () => {
|
|
|
5872
5732
|
const tooltipFunction =
|
|
5873
5733
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5874
5734
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5875
|
-
|
|
5735
|
+
|
|
5876
5736
|
expect(tooltipHtml).toEqual(
|
|
5877
5737
|
`<span style="font-weight: bold;">
|
|
5878
5738
|
row 1 :
|
|
@@ -5902,7 +5762,7 @@ describe('highcharts_renderer', () => {
|
|
|
5902
5762
|
const tooltipFunction =
|
|
5903
5763
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5904
5764
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5905
|
-
|
|
5765
|
+
|
|
5906
5766
|
expect(tooltipHtml).toEqual(
|
|
5907
5767
|
`<span style="font-weight: bold;">
|
|
5908
5768
|
col 1 :
|
|
@@ -5934,7 +5794,7 @@ describe('highcharts_renderer', () => {
|
|
|
5934
5794
|
const tooltipFunction =
|
|
5935
5795
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5936
5796
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5937
|
-
|
|
5797
|
+
|
|
5938
5798
|
expect(tooltipHtml).toEqual(
|
|
5939
5799
|
`<span style="font-weight: bold;">
|
|
5940
5800
|
Total 1
|
|
@@ -5959,7 +5819,7 @@ describe('highcharts_renderer', () => {
|
|
|
5959
5819
|
const tooltipFunction =
|
|
5960
5820
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5961
5821
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5962
|
-
|
|
5822
|
+
|
|
5963
5823
|
expect(tooltipHtml).toEqual('<span>\u200E$123,450.00</span>');
|
|
5964
5824
|
});
|
|
5965
5825
|
|
|
@@ -5979,7 +5839,7 @@ describe('highcharts_renderer', () => {
|
|
|
5979
5839
|
const tooltipFunction =
|
|
5980
5840
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5981
5841
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5982
|
-
|
|
5842
|
+
|
|
5983
5843
|
expect(tooltipHtml).toEqual(`<span style="font-weight: bold;">
|
|
5984
5844
|
col 1
|
|
5985
5845
|
</span><br/><span style="font-weight: bold; color: green;">\u200ETrend Line</span>: <span>\u200E$55,555.00</span>`
|
|
@@ -6152,6 +6012,14 @@ describe('highcharts_renderer', () => {
|
|
|
6152
6012
|
describe('Function tableCSVExportRenderer', () => {
|
|
6153
6013
|
window._ = lodash;
|
|
6154
6014
|
|
|
6015
|
+
beforeEach(() => {
|
|
6016
|
+
lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types']);
|
|
6017
|
+
});
|
|
6018
|
+
|
|
6019
|
+
afterEach(() => {
|
|
6020
|
+
lodash.set(document, 'ReportHippo.user.features', []);
|
|
6021
|
+
});
|
|
6022
|
+
|
|
6155
6023
|
it('should create csv json object representation based on pivot data (only cols)', () => {
|
|
6156
6024
|
const chartOptions = {
|
|
6157
6025
|
table_options: {
|
|
@@ -6199,13 +6067,15 @@ describe('highcharts_renderer', () => {
|
|
|
6199
6067
|
}
|
|
6200
6068
|
];
|
|
6201
6069
|
const subOptions = {
|
|
6202
|
-
"sorters": () => null,
|
|
6203
|
-
"sortByValueAttrs": [],
|
|
6204
6070
|
"cols": [
|
|
6205
6071
|
"Date",
|
|
6206
6072
|
"Payment Date"
|
|
6207
6073
|
],
|
|
6208
6074
|
"rows": [],
|
|
6075
|
+
"keysObject": {
|
|
6076
|
+
"row_keys": [[]],
|
|
6077
|
+
"col_keys": [[1651363200], [1652400000], [1653177600], [1653955200]],
|
|
6078
|
+
},
|
|
6209
6079
|
"colFormats": [
|
|
6210
6080
|
{
|
|
6211
6081
|
"type": "Date",
|
|
@@ -6226,7 +6096,7 @@ describe('highcharts_renderer', () => {
|
|
|
6226
6096
|
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6227
6097
|
expect(csvJson).toEqual(
|
|
6228
6098
|
[
|
|
6229
|
-
[
|
|
6099
|
+
[ '05/01/2022', '05/13/2022', '05/22/2022', '05/31/2022', 'Totals' ],
|
|
6230
6100
|
[ undefined, undefined, undefined, undefined, 'Totals' ],
|
|
6231
6101
|
[],
|
|
6232
6102
|
[ 1, 1, 1, 1, 2 ],
|
|
@@ -6296,10 +6166,12 @@ describe('highcharts_renderer', () => {
|
|
|
6296
6166
|
}
|
|
6297
6167
|
];
|
|
6298
6168
|
const subOptions = {
|
|
6299
|
-
"sorters": () => null,
|
|
6300
|
-
"sortByValueAttrs": [],
|
|
6301
6169
|
"cols": ["Date"],
|
|
6302
6170
|
"rows": ["Type"],
|
|
6171
|
+
"keysObject": {
|
|
6172
|
+
"row_keys": [["Food"], ["Technology"]],
|
|
6173
|
+
"col_keys": [[1653177600], [1653955200]],
|
|
6174
|
+
},
|
|
6303
6175
|
"colFormats": [
|
|
6304
6176
|
{
|
|
6305
6177
|
"type": "Date",
|
|
@@ -6317,7 +6189,7 @@ describe('highcharts_renderer', () => {
|
|
|
6317
6189
|
"rendererOptions": {
|
|
6318
6190
|
},
|
|
6319
6191
|
};
|
|
6320
|
-
|
|
6192
|
+
|
|
6321
6193
|
it('should create csv json object representation based on pivot data, with totals', () => {
|
|
6322
6194
|
const chartOptions = {
|
|
6323
6195
|
table_options: {
|
|
@@ -6329,7 +6201,7 @@ describe('highcharts_renderer', () => {
|
|
|
6329
6201
|
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6330
6202
|
expect(csvJson).toEqual(
|
|
6331
6203
|
[
|
|
6332
|
-
["Date",
|
|
6204
|
+
["Date", "05/22/2022", "05/31/2022", "Totals"],
|
|
6333
6205
|
["Type"],
|
|
6334
6206
|
["Food", 1, 1, 1],
|
|
6335
6207
|
["Technology", 1, 1, 1],
|
|
@@ -6337,7 +6209,7 @@ describe('highcharts_renderer', () => {
|
|
|
6337
6209
|
]
|
|
6338
6210
|
);
|
|
6339
6211
|
});
|
|
6340
|
-
|
|
6212
|
+
|
|
6341
6213
|
it('should create csv json object representation based on pivot data, without col totals', () => {
|
|
6342
6214
|
const chartOptions = {
|
|
6343
6215
|
table_options: {
|
|
@@ -6348,13 +6220,13 @@ describe('highcharts_renderer', () => {
|
|
|
6348
6220
|
const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
|
|
6349
6221
|
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6350
6222
|
expect(csvJson).toEqual([
|
|
6351
|
-
["Date",
|
|
6223
|
+
["Date", "05/22/2022", "05/31/2022", "Totals"],
|
|
6352
6224
|
["Type"],
|
|
6353
6225
|
["Food", 1, 1, 1],
|
|
6354
6226
|
["Technology", 1, 1, 1]
|
|
6355
6227
|
]);
|
|
6356
6228
|
});
|
|
6357
|
-
|
|
6229
|
+
|
|
6358
6230
|
it('should create csv json object representation based on pivot data, without row totals', () => {
|
|
6359
6231
|
const chartOptions = {
|
|
6360
6232
|
table_options: {
|
|
@@ -6362,18 +6234,18 @@ describe('highcharts_renderer', () => {
|
|
|
6362
6234
|
show_row_total: false,
|
|
6363
6235
|
},
|
|
6364
6236
|
};
|
|
6365
|
-
|
|
6237
|
+
|
|
6366
6238
|
const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
|
|
6367
6239
|
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6368
6240
|
expect(csvJson).toEqual([
|
|
6369
|
-
["Date",
|
|
6241
|
+
["Date", "05/22/2022", "05/31/2022"],
|
|
6370
6242
|
["Type"],
|
|
6371
6243
|
["Food", 1, 1],
|
|
6372
6244
|
["Technology", 1, 1],
|
|
6373
6245
|
["Totals", 1, 1]
|
|
6374
6246
|
]);
|
|
6375
6247
|
});
|
|
6376
|
-
|
|
6248
|
+
|
|
6377
6249
|
it('should create csv json object representation based on pivot data, without col and row totals', () => {
|
|
6378
6250
|
const chartOptions = {
|
|
6379
6251
|
table_options: {
|
|
@@ -6381,11 +6253,11 @@ describe('highcharts_renderer', () => {
|
|
|
6381
6253
|
show_row_total: false,
|
|
6382
6254
|
},
|
|
6383
6255
|
};
|
|
6384
|
-
|
|
6256
|
+
|
|
6385
6257
|
const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
|
|
6386
6258
|
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6387
6259
|
expect(csvJson).toEqual([
|
|
6388
|
-
["Date",
|
|
6260
|
+
["Date", "05/22/2022", "05/31/2022"],
|
|
6389
6261
|
["Type"],
|
|
6390
6262
|
["Food", 1, 1],
|
|
6391
6263
|
["Technology", 1, 1],
|
|
@@ -7303,7 +7175,7 @@ describe('highcharts_renderer', () => {
|
|
|
7303
7175
|
initialName: 'row 2',
|
|
7304
7176
|
name: 'Total'
|
|
7305
7177
|
}];
|
|
7306
|
-
|
|
7178
|
+
|
|
7307
7179
|
it("should mark the series as total", () => {
|
|
7308
7180
|
additionalOptionsMock = {};
|
|
7309
7181
|
opts = {
|
|
@@ -8006,7 +7878,7 @@ describe('highcharts_renderer', () => {
|
|
|
8006
7878
|
// Create dataset that exceeds MAX_ROWS_FOR_SHOW_RESULTS to trigger TooMuchDataError
|
|
8007
7879
|
const largeRowData = new Array(highchartsRenderer.MAX_ROWS_FOR_SHOW_RESULTS + 1)
|
|
8008
7880
|
.fill({ field1: 'value1', field2: 'value2' });
|
|
8009
|
-
|
|
7881
|
+
|
|
8010
7882
|
const options = {
|
|
8011
7883
|
onlyOptions: false,
|
|
8012
7884
|
rendererOptions: {},
|
|
@@ -8022,7 +7894,7 @@ describe('highcharts_renderer', () => {
|
|
|
8022
7894
|
// Create dataset that exceeds MAX_ROWS_FOR_SHOW_RESULTS
|
|
8023
7895
|
const largeRowData = new Array(highchartsRenderer.MAX_ROWS_FOR_SHOW_RESULTS + 1)
|
|
8024
7896
|
.fill({ field1: 'value1', field2: 'value2' });
|
|
8025
|
-
|
|
7897
|
+
|
|
8026
7898
|
const options = {
|
|
8027
7899
|
onlyOptions: true,
|
|
8028
7900
|
rendererOptions: {},
|
|
@@ -8060,7 +7932,7 @@ describe('highcharts_renderer', () => {
|
|
|
8060
7932
|
it('should handle renderer errors correctly', () => {
|
|
8061
7933
|
const rowData = [{ field1: 'value1', field2: 'value2' }];
|
|
8062
7934
|
const genericError = new Error('Renderer failed');
|
|
8063
|
-
|
|
7935
|
+
|
|
8064
7936
|
const options = {
|
|
8065
7937
|
onlyOptions: false,
|
|
8066
7938
|
rendererOptions: {},
|
|
@@ -8078,7 +7950,7 @@ describe('highcharts_renderer', () => {
|
|
|
8078
7950
|
it('should return empty object for renderer errors when onlyOptions is true', () => {
|
|
8079
7951
|
const rowData = [{ field1: 'value1', field2: 'value2' }];
|
|
8080
7952
|
const genericError = new Error('Renderer failed');
|
|
8081
|
-
|
|
7953
|
+
|
|
8082
7954
|
const options = {
|
|
8083
7955
|
onlyOptions: true,
|
|
8084
7956
|
rendererOptions: {},
|
|
@@ -8094,7 +7966,7 @@ describe('highcharts_renderer', () => {
|
|
|
8094
7966
|
it('should re-throw BaseRendererError instances from renderer unchanged', () => {
|
|
8095
7967
|
const rowData = [{ field1: 'value1', field2: 'value2' }];
|
|
8096
7968
|
const originalError = new NoDataError();
|
|
8097
|
-
|
|
7969
|
+
|
|
8098
7970
|
const options = {
|
|
8099
7971
|
onlyOptions: false,
|
|
8100
7972
|
rendererOptions: {},
|
|
@@ -8107,7 +7979,7 @@ describe('highcharts_renderer', () => {
|
|
|
8107
7979
|
expect(() => {
|
|
8108
7980
|
highchartsRenderer.rhPivotView(rowData, options);
|
|
8109
7981
|
}).toThrow(NoDataError);
|
|
8110
|
-
|
|
7982
|
+
|
|
8111
7983
|
expect(() => {
|
|
8112
7984
|
highchartsRenderer.rhPivotView(rowData, options);
|
|
8113
7985
|
}).toThrow(originalError);
|
|
@@ -8115,7 +7987,7 @@ describe('highcharts_renderer', () => {
|
|
|
8115
7987
|
|
|
8116
7988
|
it('should handle null/undefined from renderer as GenericRenderingError', () => {
|
|
8117
7989
|
const rowData = [{ field1: 'value1', field2: 'value2' }];
|
|
8118
|
-
|
|
7990
|
+
|
|
8119
7991
|
// Test null
|
|
8120
7992
|
const nullOptions = {
|
|
8121
7993
|
onlyOptions: false,
|
|
@@ -8269,7 +8141,7 @@ describe('highcharts_renderer', () => {
|
|
|
8269
8141
|
.and.callFake((initialName, pivotData) => `formatted(${ initialName })`);
|
|
8270
8142
|
spyOn(highchartsRenderer, 'isFormattingDatesAsOtherAxisTypes').and.returnValue(true);
|
|
8271
8143
|
});
|
|
8272
|
-
|
|
8144
|
+
|
|
8273
8145
|
it("should create appropriate series for case when only one column field and one total", () => {
|
|
8274
8146
|
const pivotDataMock = lodash.cloneDeep(pivotDataMockForOneFieldAndOneTotal);
|
|
8275
8147
|
|
|
@@ -8322,7 +8194,7 @@ describe('highcharts_renderer', () => {
|
|
|
8322
8194
|
colsForTotal: null,
|
|
8323
8195
|
initialName: "3",
|
|
8324
8196
|
isSum: false,
|
|
8325
|
-
isTotal: false,
|
|
8197
|
+
isTotal: false,
|
|
8326
8198
|
name: "formatted(3)",
|
|
8327
8199
|
totalIndex: undefined,
|
|
8328
8200
|
y: -40
|
|
@@ -8402,7 +8274,7 @@ describe('highcharts_renderer', () => {
|
|
|
8402
8274
|
colsForTotal: null,
|
|
8403
8275
|
initialName: "3",
|
|
8404
8276
|
isSum: false,
|
|
8405
|
-
isTotal: false,
|
|
8277
|
+
isTotal: false,
|
|
8406
8278
|
name: "formatted(3)",
|
|
8407
8279
|
totalIndex: undefined,
|
|
8408
8280
|
y: -40
|
|
@@ -8491,7 +8363,7 @@ describe('highcharts_renderer', () => {
|
|
|
8491
8363
|
colsForTotal: null,
|
|
8492
8364
|
initialName: "2 , 1707389500",
|
|
8493
8365
|
isSum: false,
|
|
8494
|
-
isTotal: false,
|
|
8366
|
+
isTotal: false,
|
|
8495
8367
|
name: "formatted(2 , 1707389500)",
|
|
8496
8368
|
totalIndex: undefined,
|
|
8497
8369
|
y: -40
|
|
@@ -8580,7 +8452,7 @@ describe('highcharts_renderer', () => {
|
|
|
8580
8452
|
colsForTotal: null,
|
|
8581
8453
|
initialName: "2 , 1707389500",
|
|
8582
8454
|
isSum: false,
|
|
8583
|
-
isTotal: false,
|
|
8455
|
+
isTotal: false,
|
|
8584
8456
|
name: "formatted(2 , 1707389500)",
|
|
8585
8457
|
totalIndex: undefined,
|
|
8586
8458
|
y: -40
|
|
@@ -8671,7 +8543,7 @@ describe('highcharts_renderer', () => {
|
|
|
8671
8543
|
colsForTotal: null,
|
|
8672
8544
|
initialName: "2 , 1707389500",
|
|
8673
8545
|
isSum: false,
|
|
8674
|
-
isTotal: false,
|
|
8546
|
+
isTotal: false,
|
|
8675
8547
|
name: "formatted(2 , 1707389500)",
|
|
8676
8548
|
totalIndex: undefined,
|
|
8677
8549
|
y: -40
|
|
@@ -8757,7 +8629,7 @@ describe('highcharts_renderer', () => {
|
|
|
8757
8629
|
colsForTotal: null,
|
|
8758
8630
|
initialName: "2 , 1707389500",
|
|
8759
8631
|
isSum: false,
|
|
8760
|
-
isTotal: false,
|
|
8632
|
+
isTotal: false,
|
|
8761
8633
|
name: "formatted(2 , 1707389500)",
|
|
8762
8634
|
totalIndex: undefined,
|
|
8763
8635
|
y: -40
|
|
@@ -8843,7 +8715,7 @@ describe('highcharts_renderer', () => {
|
|
|
8843
8715
|
colsForTotal: null,
|
|
8844
8716
|
initialName: "2 , 1707389500",
|
|
8845
8717
|
isSum: false,
|
|
8846
|
-
isTotal: false,
|
|
8718
|
+
isTotal: false,
|
|
8847
8719
|
name: "formatted(2 , 1707389500)",
|
|
8848
8720
|
totalIndex: undefined,
|
|
8849
8721
|
y: -40
|
|
@@ -8888,11 +8760,11 @@ describe('highcharts_renderer', () => {
|
|
|
8888
8760
|
.mockReturnValue([{ name: 'Sample Series', data: [1, 2, 3] }]);
|
|
8889
8761
|
jest.spyOn(highchartsRenderer, 'ptCreateElementAndDraw').mockImplementation(() => {});
|
|
8890
8762
|
});
|
|
8891
|
-
|
|
8763
|
+
|
|
8892
8764
|
afterEach(() => {
|
|
8893
8765
|
jest.restoreAllMocks();
|
|
8894
8766
|
});
|
|
8895
|
-
|
|
8767
|
+
|
|
8896
8768
|
it('should call ptCreateElementAndDraw with correct chart options', () => {
|
|
8897
8769
|
const pivotData = {
|
|
8898
8770
|
getColKeys: jest.fn(() => [['Category 1'], ['Category 2']]),
|
|
@@ -8904,7 +8776,7 @@ describe('highcharts_renderer', () => {
|
|
|
8904
8776
|
rows: { 0: { type: 'Date' }, 1: { type: 'Date' } },
|
|
8905
8777
|
cols: { 0: { type: 'Category' }, 1: { type: 'Category' } }
|
|
8906
8778
|
};
|
|
8907
|
-
|
|
8779
|
+
|
|
8908
8780
|
const opts = {
|
|
8909
8781
|
chartOptions: {
|
|
8910
8782
|
label_pie: {
|
|
@@ -8916,11 +8788,11 @@ describe('highcharts_renderer', () => {
|
|
|
8916
8788
|
}
|
|
8917
8789
|
}
|
|
8918
8790
|
};
|
|
8919
|
-
|
|
8791
|
+
|
|
8920
8792
|
const drilldownFunc = jest.fn();
|
|
8921
8793
|
|
|
8922
8794
|
highchartsRenderer.ptRenderPieWithDrillDown(pivotData, opts, drilldownFunc);
|
|
8923
|
-
|
|
8795
|
+
|
|
8924
8796
|
const expectedChartOptions = {
|
|
8925
8797
|
chart: {
|
|
8926
8798
|
type: 'pie',
|
|
@@ -8929,7 +8801,7 @@ describe('highcharts_renderer', () => {
|
|
|
8929
8801
|
drillup: expect.any(Function)
|
|
8930
8802
|
}
|
|
8931
8803
|
},
|
|
8932
|
-
colors: ["#91e7e7", "#f37789", "#ffdc65", "#0e569d", "#bbe0ff", "#57b2ff", "#5ecfb9", "#c7ffda", "#179ab9", "#008aff"],
|
|
8804
|
+
colors: ["#91e7e7", "#f37789", "#ffdc65", "#0e569d", "#bbe0ff", "#57b2ff", "#5ecfb9", "#c7ffda", "#179ab9", "#008aff"],
|
|
8933
8805
|
plotOptions: {
|
|
8934
8806
|
series: {
|
|
8935
8807
|
animation: true,
|
|
@@ -8939,7 +8811,7 @@ describe('highcharts_renderer', () => {
|
|
|
8939
8811
|
enabled: true,
|
|
8940
8812
|
formatter: expect.any(Function),
|
|
8941
8813
|
style: {
|
|
8942
|
-
"fontFamily": "Poppins",
|
|
8814
|
+
"fontFamily": "Poppins",
|
|
8943
8815
|
"fontSize": "11",
|
|
8944
8816
|
"fontWeight": "normal"
|
|
8945
8817
|
}
|
|
@@ -8951,7 +8823,7 @@ describe('highcharts_renderer', () => {
|
|
|
8951
8823
|
headerFormat: '',
|
|
8952
8824
|
pointFormatter: expect.any(Function)
|
|
8953
8825
|
},
|
|
8954
|
-
series: [{ name: 'Sample Series', data: [1, 2, 3] }],
|
|
8826
|
+
series: [{ name: 'Sample Series', data: [1, 2, 3] }],
|
|
8955
8827
|
legend: {
|
|
8956
8828
|
align: "right",
|
|
8957
8829
|
borderWidth: 0,
|
|
@@ -8961,7 +8833,7 @@ describe('highcharts_renderer', () => {
|
|
|
8961
8833
|
verticalAlign: "top",
|
|
8962
8834
|
y: 13
|
|
8963
8835
|
},
|
|
8964
|
-
drilldown: {},
|
|
8836
|
+
drilldown: {},
|
|
8965
8837
|
subtitle: {
|
|
8966
8838
|
align: "center",
|
|
8967
8839
|
style: {
|
|
@@ -8993,7 +8865,7 @@ describe('highcharts_renderer', () => {
|
|
|
8993
8865
|
getRowKeys: jest.fn(() => [['Row 1'], ['Row 2']]),
|
|
8994
8866
|
getAggregator: jest.fn(() => ({ value: jest.fn(() => 100) }))
|
|
8995
8867
|
};
|
|
8996
|
-
|
|
8868
|
+
|
|
8997
8869
|
const opts = {
|
|
8998
8870
|
chartOptions: {
|
|
8999
8871
|
label_pie: { show: true, overlap: true },
|
|
@@ -9002,19 +8874,19 @@ describe('highcharts_renderer', () => {
|
|
|
9002
8874
|
},
|
|
9003
8875
|
drillDownListFunc: jest.fn()
|
|
9004
8876
|
};
|
|
9005
|
-
|
|
8877
|
+
|
|
9006
8878
|
beforeEach(() => {
|
|
9007
8879
|
jest.spyOn(highchartsRenderer, 'ptCreateElementAndDraw').mockImplementation(() => {});
|
|
9008
8880
|
jest.spyOn(highchartsRenderer, 'getFormattedColKey').mockImplementation((name) => `Formatted ${name}`);
|
|
9009
8881
|
});
|
|
9010
|
-
|
|
8882
|
+
|
|
9011
8883
|
afterEach(() => {
|
|
9012
8884
|
jest.restoreAllMocks();
|
|
9013
8885
|
});
|
|
9014
|
-
|
|
8886
|
+
|
|
9015
8887
|
it('should call ptCreateElementAndDraw with correct chart options', () => {
|
|
9016
8888
|
highchartsRenderer.ptRenderBasicPie(pivotData, opts);
|
|
9017
|
-
|
|
8889
|
+
|
|
9018
8890
|
expect(highchartsRenderer.ptCreateElementAndDraw).toHaveBeenCalledWith(
|
|
9019
8891
|
expect.objectContaining({
|
|
9020
8892
|
chart: expect.objectContaining({
|
|
@@ -9469,7 +9341,7 @@ describe('highcharts_renderer', () => {
|
|
|
9469
9341
|
pivotData.getAggregator().value.mockReturnValue(10);
|
|
9470
9342
|
highchartsRenderer.getOthersName.mockReturnValue('Others');
|
|
9471
9343
|
highchartsRenderer.getFormattedColKey.mockReturnValue('FormattedKey');
|
|
9472
|
-
|
|
9344
|
+
|
|
9473
9345
|
const result = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, chartOptions, additionOptions, opts);
|
|
9474
9346
|
expect(result[0].data[0].initialName).toEqual('\u200Eשלום');
|
|
9475
9347
|
});
|
|
@@ -9480,11 +9352,11 @@ describe('highcharts_renderer', () => {
|
|
|
9480
9352
|
pivotData.getAggregator().value.mockReturnValue(10);
|
|
9481
9353
|
highchartsRenderer.getOthersName.mockReturnValue('Others');
|
|
9482
9354
|
highchartsRenderer.getFormattedColKey.mockReturnValue('FormattedKey');
|
|
9483
|
-
|
|
9355
|
+
|
|
9484
9356
|
const result = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, chartOptions, additionOptions, opts);
|
|
9485
9357
|
expect(result[0].data[0].initialName).toEqual('Others');
|
|
9486
9358
|
});
|
|
9487
|
-
|
|
9359
|
+
|
|
9488
9360
|
it('should handle negative values when chart type is not pie', () => {
|
|
9489
9361
|
chartOptions.chart.type = 'notPie';
|
|
9490
9362
|
pivotData.getColKeys.mockReturnValue(['key1']);
|
|
@@ -9492,25 +9364,25 @@ describe('highcharts_renderer', () => {
|
|
|
9492
9364
|
pivotData.getAggregator().value.mockReturnValue(-10);
|
|
9493
9365
|
highchartsRenderer.getOthersName.mockReturnValue('Others');
|
|
9494
9366
|
highchartsRenderer.getFormattedColKey.mockReturnValue('FormattedKey');
|
|
9495
|
-
|
|
9367
|
+
|
|
9496
9368
|
const result = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, chartOptions, additionOptions, opts);
|
|
9497
9369
|
expect(result[0].data[0].y).toEqual(-10);
|
|
9498
9370
|
});
|
|
9499
|
-
|
|
9371
|
+
|
|
9500
9372
|
it('should handle numeric keys', () => {
|
|
9501
9373
|
pivotData.getColKeys.mockReturnValue(['123']);
|
|
9502
9374
|
pivotData.getRowKeys.mockReturnValue(['row1']);
|
|
9503
9375
|
pivotData.getAggregator().value.mockReturnValue(10);
|
|
9504
9376
|
highchartsRenderer.getOthersName.mockReturnValue('Others');
|
|
9505
9377
|
highchartsRenderer.getFormattedColKey.mockReturnValue('FormattedKey');
|
|
9506
|
-
|
|
9378
|
+
|
|
9507
9379
|
const result = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, chartOptions, additionOptions, opts);
|
|
9508
9380
|
expect(result[0].data[0].drilldown).toEqual(123);
|
|
9509
9381
|
});
|
|
9510
9382
|
});
|
|
9511
9383
|
|
|
9512
9384
|
describe('Function getDataLabelsStylesForDrillDown', () => {
|
|
9513
|
-
|
|
9385
|
+
|
|
9514
9386
|
it('should return an object with activeDataLabelStyle containing color from dataLabels', () => {
|
|
9515
9387
|
const mockColor = 'red';
|
|
9516
9388
|
const additionalOptions = {
|