@datarailsshared/dr_renderer 1.5.89 → 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 +12 -353
- package/src/pivottable.js +7 -653
- package/tests/dr-renderer-helpers.test.js +0 -32
- package/tests/highcharts_renderer.test.js +76 -239
|
@@ -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: {},
|
|
@@ -5312,7 +5309,7 @@ describe('highcharts_renderer', () => {
|
|
|
5312
5309
|
describe('Function getSeriesNameInFormatterContext', () => {
|
|
5313
5310
|
|
|
5314
5311
|
const name1 = 'test series name';
|
|
5315
|
-
const name2 = 'test series name 2';
|
|
5312
|
+
const name2 = 'test series name 2';
|
|
5316
5313
|
|
|
5317
5314
|
const pivotData = {
|
|
5318
5315
|
isFormattingAxisLabels: true,
|
|
@@ -5343,7 +5340,7 @@ describe('highcharts_renderer', () => {
|
|
|
5343
5340
|
describe('Function getColsInFormatterContext', () => {
|
|
5344
5341
|
|
|
5345
5342
|
const name1 = 'test series name 1';
|
|
5346
|
-
const name2 = 'test series name 2';
|
|
5343
|
+
const name2 = 'test series name 2';
|
|
5347
5344
|
const name3 = 'test series name 3';
|
|
5348
5345
|
const pivotData = {
|
|
5349
5346
|
isFormattingAxisLabels: true,
|
|
@@ -5395,170 +5392,6 @@ describe('highcharts_renderer', () => {
|
|
|
5395
5392
|
});
|
|
5396
5393
|
|
|
5397
5394
|
|
|
5398
|
-
describe('Function replaceSortingKeysWithMappedValues', () => {
|
|
5399
|
-
it('should replace sorting keys with mapped values for Date fields', () => {
|
|
5400
|
-
const keysObject = {
|
|
5401
|
-
col_keys: [
|
|
5402
|
-
[1640995200],
|
|
5403
|
-
[1648684800],
|
|
5404
|
-
[1667174400]
|
|
5405
|
-
],
|
|
5406
|
-
row_keys: [],
|
|
5407
|
-
row_keys_by_cols: [
|
|
5408
|
-
[
|
|
5409
|
-
["Other Income"],
|
|
5410
|
-
["Other Expense"],
|
|
5411
|
-
["Income"],
|
|
5412
|
-
["Expenses"],
|
|
5413
|
-
["Cost of Goods Sold"]
|
|
5414
|
-
]
|
|
5415
|
-
]
|
|
5416
|
-
};
|
|
5417
|
-
const invertedDateStringMap = {
|
|
5418
|
-
1640995200: '2022-01-01',
|
|
5419
|
-
1648684800: '2022-03-29',
|
|
5420
|
-
1667174400: '2023-03-01'
|
|
5421
|
-
};
|
|
5422
|
-
const widget = {
|
|
5423
|
-
cols: [{ type: 'Date' }],
|
|
5424
|
-
rows: [{ type: 'NotDate' }],
|
|
5425
|
-
pivot: {
|
|
5426
|
-
keysObject: keysObject
|
|
5427
|
-
}
|
|
5428
|
-
};
|
|
5429
|
-
|
|
5430
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.col_keys, invertedDateStringMap, widget.cols);
|
|
5431
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.row_keys, invertedDateStringMap, widget.rows);
|
|
5432
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.row_keys_by_cols, invertedDateStringMap, widget.rows);
|
|
5433
|
-
|
|
5434
|
-
expect(keysObject).toEqual({
|
|
5435
|
-
col_keys: [
|
|
5436
|
-
['2022-01-01'],
|
|
5437
|
-
['2022-03-29'],
|
|
5438
|
-
['2023-03-01']
|
|
5439
|
-
],
|
|
5440
|
-
row_keys: [],
|
|
5441
|
-
row_keys_by_cols: [
|
|
5442
|
-
[
|
|
5443
|
-
['Other Income'],
|
|
5444
|
-
['Other Expense'],
|
|
5445
|
-
['Income'],
|
|
5446
|
-
['Expenses'],
|
|
5447
|
-
['Cost of Goods Sold']
|
|
5448
|
-
]
|
|
5449
|
-
]
|
|
5450
|
-
});
|
|
5451
|
-
});
|
|
5452
|
-
|
|
5453
|
-
it('should not replace sorting keys for non-Date fields', () => {
|
|
5454
|
-
const keysObject = {
|
|
5455
|
-
col_keys: [
|
|
5456
|
-
[1640995200],
|
|
5457
|
-
[1648684800],
|
|
5458
|
-
[1667174400]
|
|
5459
|
-
],
|
|
5460
|
-
row_keys: [],
|
|
5461
|
-
row_keys_by_cols: [
|
|
5462
|
-
[
|
|
5463
|
-
["Other Income"],
|
|
5464
|
-
["Other Expense"],
|
|
5465
|
-
["Income"],
|
|
5466
|
-
["Expenses"],
|
|
5467
|
-
["Cost of Goods Sold"]
|
|
5468
|
-
]
|
|
5469
|
-
]
|
|
5470
|
-
};
|
|
5471
|
-
const invertedDateStringMap = {
|
|
5472
|
-
1640995200: '2022-01-01',
|
|
5473
|
-
1648684800: '2022-03-29',
|
|
5474
|
-
1667174400: '2023-03-01'
|
|
5475
|
-
};
|
|
5476
|
-
const widget = {
|
|
5477
|
-
cols: [{ type: 'NotDate' }],
|
|
5478
|
-
rows: [{ type: 'NotDate' }],
|
|
5479
|
-
pivot: {
|
|
5480
|
-
keysObject: keysObject
|
|
5481
|
-
}
|
|
5482
|
-
};
|
|
5483
|
-
|
|
5484
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.col_keys, invertedDateStringMap, widget.cols);
|
|
5485
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.row_keys, invertedDateStringMap, widget.rows);
|
|
5486
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.row_keys_by_cols, invertedDateStringMap, widget.rows);
|
|
5487
|
-
|
|
5488
|
-
expect(keysObject).toEqual({
|
|
5489
|
-
col_keys: [
|
|
5490
|
-
[1640995200],
|
|
5491
|
-
[1648684800],
|
|
5492
|
-
[1667174400]
|
|
5493
|
-
],
|
|
5494
|
-
row_keys: [],
|
|
5495
|
-
row_keys_by_cols: [
|
|
5496
|
-
[
|
|
5497
|
-
["Other Income"],
|
|
5498
|
-
["Other Expense"],
|
|
5499
|
-
["Income"],
|
|
5500
|
-
["Expenses"],
|
|
5501
|
-
["Cost of Goods Sold"]
|
|
5502
|
-
]
|
|
5503
|
-
]
|
|
5504
|
-
});
|
|
5505
|
-
});
|
|
5506
|
-
|
|
5507
|
-
it('should handle null or undefined keysObject', () => {
|
|
5508
|
-
const invertedDateStringMap = {
|
|
5509
|
-
1640995200: '2022-01-01',
|
|
5510
|
-
1648684800: '2022-03-29',
|
|
5511
|
-
1667174400: '2023-03-01'
|
|
5512
|
-
};
|
|
5513
|
-
const widget = {
|
|
5514
|
-
cols: [{ type: 'Date' }],
|
|
5515
|
-
rows: [{ type: 'NotDate' }],
|
|
5516
|
-
pivot: {
|
|
5517
|
-
keysObject: null
|
|
5518
|
-
}
|
|
5519
|
-
};
|
|
5520
|
-
|
|
5521
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.cols);
|
|
5522
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.rows);
|
|
5523
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.rows);
|
|
5524
|
-
});
|
|
5525
|
-
|
|
5526
|
-
// This test was added to cover an edge case where multiple Date fields have the same date values
|
|
5527
|
-
// but require different formatting based on their individual field settings
|
|
5528
|
-
// Fixes the issue - https://datarailsteam.atlassian.net/browse/DR-37813
|
|
5529
|
-
// Will be removed once "format_dates_as_other_axis_types" FF is deleted
|
|
5530
|
-
it('should reformat dates when widget fields have same dates, but different formats', () => {
|
|
5531
|
-
const keysObject = {
|
|
5532
|
-
col_keys: [
|
|
5533
|
-
[1648684800, 1648684800, 1648684800],
|
|
5534
|
-
],
|
|
5535
|
-
row_keys: [],
|
|
5536
|
-
row_keys_by_cols: [],
|
|
5537
|
-
};
|
|
5538
|
-
|
|
5539
|
-
const invertedDateStringMap = {
|
|
5540
|
-
1648684800: '03/31/2022',
|
|
5541
|
-
};
|
|
5542
|
-
|
|
5543
|
-
const widget = {
|
|
5544
|
-
cols: [
|
|
5545
|
-
{ type: 'Date', format: null }, // Default format MM/DD/YYYY
|
|
5546
|
-
{ type: 'Date', format: 'MM-DD-YYYY' },
|
|
5547
|
-
{ type: 'Date', format: 'DD/MM/YYYY' },
|
|
5548
|
-
],
|
|
5549
|
-
rows: [],
|
|
5550
|
-
pivot: { keysObject },
|
|
5551
|
-
};
|
|
5552
|
-
|
|
5553
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.col_keys, invertedDateStringMap, widget.cols);
|
|
5554
|
-
|
|
5555
|
-
expect(keysObject.col_keys[0][0]).toBe('03/31/2022');
|
|
5556
|
-
expect(keysObject.col_keys[0][1]).toBe('03-31-2022');
|
|
5557
|
-
expect(keysObject.col_keys[0][2]).toBe('31/03/2022');
|
|
5558
|
-
});
|
|
5559
|
-
});
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
5395
|
describe('Functions getAggregatedSortingObjects', () => {
|
|
5563
5396
|
|
|
5564
5397
|
const simpleRowData = [{ someField1: 'someValue1' }, { someField2: 'someValue2' }];
|
|
@@ -5586,7 +5419,7 @@ describe('highcharts_renderer', () => {
|
|
|
5586
5419
|
it(testCase.description, () => {
|
|
5587
5420
|
const rowData = lodash.concat(simpleRowData, testCase.expectedObj ? lodash.clone(testCase.expectedObj) : []);
|
|
5588
5421
|
const sortObj = highchartsRenderer.getAggregatedSortingObjects(rowData);
|
|
5589
|
-
|
|
5422
|
+
|
|
5590
5423
|
expect(rowData).toEqual(simpleRowData);
|
|
5591
5424
|
expect(sortObj).toEqual(testCase.expectedObj);
|
|
5592
5425
|
});
|
|
@@ -5662,7 +5495,7 @@ describe('highcharts_renderer', () => {
|
|
|
5662
5495
|
getAggregator: (rows, cols) => {
|
|
5663
5496
|
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
|
5664
5497
|
const agg = aggregator({}, '', '');
|
|
5665
|
-
|
|
5498
|
+
|
|
5666
5499
|
if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, ['row 1'])) {
|
|
5667
5500
|
agg.sum = 12345;
|
|
5668
5501
|
} else if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, [])) {
|
|
@@ -5687,7 +5520,7 @@ describe('highcharts_renderer', () => {
|
|
|
5687
5520
|
getRowKeys: () => [['row 1'], ['row 2'], ['row 3']],
|
|
5688
5521
|
rowAttrs: ['row 1'],
|
|
5689
5522
|
};
|
|
5690
|
-
|
|
5523
|
+
|
|
5691
5524
|
optsMock = {
|
|
5692
5525
|
total_value_options: {
|
|
5693
5526
|
filter_options: {
|
|
@@ -5702,7 +5535,7 @@ describe('highcharts_renderer', () => {
|
|
|
5702
5535
|
},
|
|
5703
5536
|
},
|
|
5704
5537
|
};
|
|
5705
|
-
|
|
5538
|
+
|
|
5706
5539
|
displayTooltipContext = {
|
|
5707
5540
|
series: {
|
|
5708
5541
|
options: {
|
|
@@ -5761,7 +5594,7 @@ describe('highcharts_renderer', () => {
|
|
|
5761
5594
|
const tooltipFunction =
|
|
5762
5595
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5763
5596
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5764
|
-
|
|
5597
|
+
|
|
5765
5598
|
expect(tooltipHtml).toEqual(
|
|
5766
5599
|
'<br/><span style="font-weight: bold; color: green;">\u200Erow 1</span>: <span>\u200E$12,345.00</span>'
|
|
5767
5600
|
);
|
|
@@ -5773,7 +5606,7 @@ describe('highcharts_renderer', () => {
|
|
|
5773
5606
|
const tooltipFunction =
|
|
5774
5607
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5775
5608
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5776
|
-
|
|
5609
|
+
|
|
5777
5610
|
expect(tooltipHtml).toEqual(
|
|
5778
5611
|
`<span style="font-weight: bold;">
|
|
5779
5612
|
col 1
|
|
@@ -5788,7 +5621,7 @@ describe('highcharts_renderer', () => {
|
|
|
5788
5621
|
const tooltipFunction =
|
|
5789
5622
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5790
5623
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5791
|
-
|
|
5624
|
+
|
|
5792
5625
|
expect(tooltipHtml).toEqual(
|
|
5793
5626
|
`<span style="font-weight: bold;">
|
|
5794
5627
|
col 1
|
|
@@ -5804,7 +5637,7 @@ describe('highcharts_renderer', () => {
|
|
|
5804
5637
|
const tooltipFunction =
|
|
5805
5638
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5806
5639
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5807
|
-
|
|
5640
|
+
|
|
5808
5641
|
expect(tooltipHtml).toEqual(
|
|
5809
5642
|
`<span style="font-weight: bold;">
|
|
5810
5643
|
col 1
|
|
@@ -5824,7 +5657,7 @@ describe('highcharts_renderer', () => {
|
|
|
5824
5657
|
const tooltipFunction =
|
|
5825
5658
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5826
5659
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5827
|
-
|
|
5660
|
+
|
|
5828
5661
|
expect(tooltipHtml).toEqual(
|
|
5829
5662
|
`<span style="font-weight: bold;">
|
|
5830
5663
|
col 1
|
|
@@ -5840,7 +5673,7 @@ describe('highcharts_renderer', () => {
|
|
|
5840
5673
|
const tooltipFunction =
|
|
5841
5674
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5842
5675
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5843
|
-
|
|
5676
|
+
|
|
5844
5677
|
expect(tooltipHtml).toEqual(
|
|
5845
5678
|
`<span style="font-weight: bold;">
|
|
5846
5679
|
col 1,col 2
|
|
@@ -5855,7 +5688,7 @@ describe('highcharts_renderer', () => {
|
|
|
5855
5688
|
const tooltipFunction =
|
|
5856
5689
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5857
5690
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5858
|
-
|
|
5691
|
+
|
|
5859
5692
|
expect(tooltipHtml).toEqual(
|
|
5860
5693
|
`<span style="font-weight: bold;">
|
|
5861
5694
|
col 1
|
|
@@ -5869,7 +5702,7 @@ describe('highcharts_renderer', () => {
|
|
|
5869
5702
|
const tooltipFunction =
|
|
5870
5703
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5871
5704
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5872
|
-
|
|
5705
|
+
|
|
5873
5706
|
expect(tooltipHtml).toEqual(
|
|
5874
5707
|
`<span style="font-weight: bold;">
|
|
5875
5708
|
${ othersName }
|
|
@@ -5899,7 +5732,7 @@ describe('highcharts_renderer', () => {
|
|
|
5899
5732
|
const tooltipFunction =
|
|
5900
5733
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5901
5734
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5902
|
-
|
|
5735
|
+
|
|
5903
5736
|
expect(tooltipHtml).toEqual(
|
|
5904
5737
|
`<span style="font-weight: bold;">
|
|
5905
5738
|
row 1 :
|
|
@@ -5929,7 +5762,7 @@ describe('highcharts_renderer', () => {
|
|
|
5929
5762
|
const tooltipFunction =
|
|
5930
5763
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5931
5764
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5932
|
-
|
|
5765
|
+
|
|
5933
5766
|
expect(tooltipHtml).toEqual(
|
|
5934
5767
|
`<span style="font-weight: bold;">
|
|
5935
5768
|
col 1 :
|
|
@@ -5961,7 +5794,7 @@ describe('highcharts_renderer', () => {
|
|
|
5961
5794
|
const tooltipFunction =
|
|
5962
5795
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5963
5796
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5964
|
-
|
|
5797
|
+
|
|
5965
5798
|
expect(tooltipHtml).toEqual(
|
|
5966
5799
|
`<span style="font-weight: bold;">
|
|
5967
5800
|
Total 1
|
|
@@ -5986,7 +5819,7 @@ describe('highcharts_renderer', () => {
|
|
|
5986
5819
|
const tooltipFunction =
|
|
5987
5820
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
5988
5821
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
5989
|
-
|
|
5822
|
+
|
|
5990
5823
|
expect(tooltipHtml).toEqual('<span>\u200E$123,450.00</span>');
|
|
5991
5824
|
});
|
|
5992
5825
|
|
|
@@ -6006,7 +5839,7 @@ describe('highcharts_renderer', () => {
|
|
|
6006
5839
|
const tooltipFunction =
|
|
6007
5840
|
highchartsRenderer.defaultFormatterToTooltip(pivotDataMock, optsMock, isForDrilldownPie);
|
|
6008
5841
|
const tooltipHtml = tooltipFunction.call(displayTooltipContext);
|
|
6009
|
-
|
|
5842
|
+
|
|
6010
5843
|
expect(tooltipHtml).toEqual(`<span style="font-weight: bold;">
|
|
6011
5844
|
col 1
|
|
6012
5845
|
</span><br/><span style="font-weight: bold; color: green;">\u200ETrend Line</span>: <span>\u200E$55,555.00</span>`
|
|
@@ -6234,13 +6067,15 @@ describe('highcharts_renderer', () => {
|
|
|
6234
6067
|
}
|
|
6235
6068
|
];
|
|
6236
6069
|
const subOptions = {
|
|
6237
|
-
"sorters": () => null,
|
|
6238
|
-
"sortByValueAttrs": [],
|
|
6239
6070
|
"cols": [
|
|
6240
6071
|
"Date",
|
|
6241
6072
|
"Payment Date"
|
|
6242
6073
|
],
|
|
6243
6074
|
"rows": [],
|
|
6075
|
+
"keysObject": {
|
|
6076
|
+
"row_keys": [[]],
|
|
6077
|
+
"col_keys": [[1651363200], [1652400000], [1653177600], [1653955200]],
|
|
6078
|
+
},
|
|
6244
6079
|
"colFormats": [
|
|
6245
6080
|
{
|
|
6246
6081
|
"type": "Date",
|
|
@@ -6331,10 +6166,12 @@ describe('highcharts_renderer', () => {
|
|
|
6331
6166
|
}
|
|
6332
6167
|
];
|
|
6333
6168
|
const subOptions = {
|
|
6334
|
-
"sorters": () => null,
|
|
6335
|
-
"sortByValueAttrs": [],
|
|
6336
6169
|
"cols": ["Date"],
|
|
6337
6170
|
"rows": ["Type"],
|
|
6171
|
+
"keysObject": {
|
|
6172
|
+
"row_keys": [["Food"], ["Technology"]],
|
|
6173
|
+
"col_keys": [[1653177600], [1653955200]],
|
|
6174
|
+
},
|
|
6338
6175
|
"colFormats": [
|
|
6339
6176
|
{
|
|
6340
6177
|
"type": "Date",
|
|
@@ -6352,7 +6189,7 @@ describe('highcharts_renderer', () => {
|
|
|
6352
6189
|
"rendererOptions": {
|
|
6353
6190
|
},
|
|
6354
6191
|
};
|
|
6355
|
-
|
|
6192
|
+
|
|
6356
6193
|
it('should create csv json object representation based on pivot data, with totals', () => {
|
|
6357
6194
|
const chartOptions = {
|
|
6358
6195
|
table_options: {
|
|
@@ -6372,7 +6209,7 @@ describe('highcharts_renderer', () => {
|
|
|
6372
6209
|
]
|
|
6373
6210
|
);
|
|
6374
6211
|
});
|
|
6375
|
-
|
|
6212
|
+
|
|
6376
6213
|
it('should create csv json object representation based on pivot data, without col totals', () => {
|
|
6377
6214
|
const chartOptions = {
|
|
6378
6215
|
table_options: {
|
|
@@ -6389,7 +6226,7 @@ describe('highcharts_renderer', () => {
|
|
|
6389
6226
|
["Technology", 1, 1, 1]
|
|
6390
6227
|
]);
|
|
6391
6228
|
});
|
|
6392
|
-
|
|
6229
|
+
|
|
6393
6230
|
it('should create csv json object representation based on pivot data, without row totals', () => {
|
|
6394
6231
|
const chartOptions = {
|
|
6395
6232
|
table_options: {
|
|
@@ -6397,7 +6234,7 @@ describe('highcharts_renderer', () => {
|
|
|
6397
6234
|
show_row_total: false,
|
|
6398
6235
|
},
|
|
6399
6236
|
};
|
|
6400
|
-
|
|
6237
|
+
|
|
6401
6238
|
const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
|
|
6402
6239
|
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6403
6240
|
expect(csvJson).toEqual([
|
|
@@ -6408,7 +6245,7 @@ describe('highcharts_renderer', () => {
|
|
|
6408
6245
|
["Totals", 1, 1]
|
|
6409
6246
|
]);
|
|
6410
6247
|
});
|
|
6411
|
-
|
|
6248
|
+
|
|
6412
6249
|
it('should create csv json object representation based on pivot data, without col and row totals', () => {
|
|
6413
6250
|
const chartOptions = {
|
|
6414
6251
|
table_options: {
|
|
@@ -6416,7 +6253,7 @@ describe('highcharts_renderer', () => {
|
|
|
6416
6253
|
show_row_total: false,
|
|
6417
6254
|
},
|
|
6418
6255
|
};
|
|
6419
|
-
|
|
6256
|
+
|
|
6420
6257
|
const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
|
|
6421
6258
|
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6422
6259
|
expect(csvJson).toEqual([
|
|
@@ -7338,7 +7175,7 @@ describe('highcharts_renderer', () => {
|
|
|
7338
7175
|
initialName: 'row 2',
|
|
7339
7176
|
name: 'Total'
|
|
7340
7177
|
}];
|
|
7341
|
-
|
|
7178
|
+
|
|
7342
7179
|
it("should mark the series as total", () => {
|
|
7343
7180
|
additionalOptionsMock = {};
|
|
7344
7181
|
opts = {
|
|
@@ -8041,7 +7878,7 @@ describe('highcharts_renderer', () => {
|
|
|
8041
7878
|
// Create dataset that exceeds MAX_ROWS_FOR_SHOW_RESULTS to trigger TooMuchDataError
|
|
8042
7879
|
const largeRowData = new Array(highchartsRenderer.MAX_ROWS_FOR_SHOW_RESULTS + 1)
|
|
8043
7880
|
.fill({ field1: 'value1', field2: 'value2' });
|
|
8044
|
-
|
|
7881
|
+
|
|
8045
7882
|
const options = {
|
|
8046
7883
|
onlyOptions: false,
|
|
8047
7884
|
rendererOptions: {},
|
|
@@ -8057,7 +7894,7 @@ describe('highcharts_renderer', () => {
|
|
|
8057
7894
|
// Create dataset that exceeds MAX_ROWS_FOR_SHOW_RESULTS
|
|
8058
7895
|
const largeRowData = new Array(highchartsRenderer.MAX_ROWS_FOR_SHOW_RESULTS + 1)
|
|
8059
7896
|
.fill({ field1: 'value1', field2: 'value2' });
|
|
8060
|
-
|
|
7897
|
+
|
|
8061
7898
|
const options = {
|
|
8062
7899
|
onlyOptions: true,
|
|
8063
7900
|
rendererOptions: {},
|
|
@@ -8095,7 +7932,7 @@ describe('highcharts_renderer', () => {
|
|
|
8095
7932
|
it('should handle renderer errors correctly', () => {
|
|
8096
7933
|
const rowData = [{ field1: 'value1', field2: 'value2' }];
|
|
8097
7934
|
const genericError = new Error('Renderer failed');
|
|
8098
|
-
|
|
7935
|
+
|
|
8099
7936
|
const options = {
|
|
8100
7937
|
onlyOptions: false,
|
|
8101
7938
|
rendererOptions: {},
|
|
@@ -8113,7 +7950,7 @@ describe('highcharts_renderer', () => {
|
|
|
8113
7950
|
it('should return empty object for renderer errors when onlyOptions is true', () => {
|
|
8114
7951
|
const rowData = [{ field1: 'value1', field2: 'value2' }];
|
|
8115
7952
|
const genericError = new Error('Renderer failed');
|
|
8116
|
-
|
|
7953
|
+
|
|
8117
7954
|
const options = {
|
|
8118
7955
|
onlyOptions: true,
|
|
8119
7956
|
rendererOptions: {},
|
|
@@ -8129,7 +7966,7 @@ describe('highcharts_renderer', () => {
|
|
|
8129
7966
|
it('should re-throw BaseRendererError instances from renderer unchanged', () => {
|
|
8130
7967
|
const rowData = [{ field1: 'value1', field2: 'value2' }];
|
|
8131
7968
|
const originalError = new NoDataError();
|
|
8132
|
-
|
|
7969
|
+
|
|
8133
7970
|
const options = {
|
|
8134
7971
|
onlyOptions: false,
|
|
8135
7972
|
rendererOptions: {},
|
|
@@ -8142,7 +7979,7 @@ describe('highcharts_renderer', () => {
|
|
|
8142
7979
|
expect(() => {
|
|
8143
7980
|
highchartsRenderer.rhPivotView(rowData, options);
|
|
8144
7981
|
}).toThrow(NoDataError);
|
|
8145
|
-
|
|
7982
|
+
|
|
8146
7983
|
expect(() => {
|
|
8147
7984
|
highchartsRenderer.rhPivotView(rowData, options);
|
|
8148
7985
|
}).toThrow(originalError);
|
|
@@ -8150,7 +7987,7 @@ describe('highcharts_renderer', () => {
|
|
|
8150
7987
|
|
|
8151
7988
|
it('should handle null/undefined from renderer as GenericRenderingError', () => {
|
|
8152
7989
|
const rowData = [{ field1: 'value1', field2: 'value2' }];
|
|
8153
|
-
|
|
7990
|
+
|
|
8154
7991
|
// Test null
|
|
8155
7992
|
const nullOptions = {
|
|
8156
7993
|
onlyOptions: false,
|
|
@@ -8304,7 +8141,7 @@ describe('highcharts_renderer', () => {
|
|
|
8304
8141
|
.and.callFake((initialName, pivotData) => `formatted(${ initialName })`);
|
|
8305
8142
|
spyOn(highchartsRenderer, 'isFormattingDatesAsOtherAxisTypes').and.returnValue(true);
|
|
8306
8143
|
});
|
|
8307
|
-
|
|
8144
|
+
|
|
8308
8145
|
it("should create appropriate series for case when only one column field and one total", () => {
|
|
8309
8146
|
const pivotDataMock = lodash.cloneDeep(pivotDataMockForOneFieldAndOneTotal);
|
|
8310
8147
|
|
|
@@ -8357,7 +8194,7 @@ describe('highcharts_renderer', () => {
|
|
|
8357
8194
|
colsForTotal: null,
|
|
8358
8195
|
initialName: "3",
|
|
8359
8196
|
isSum: false,
|
|
8360
|
-
isTotal: false,
|
|
8197
|
+
isTotal: false,
|
|
8361
8198
|
name: "formatted(3)",
|
|
8362
8199
|
totalIndex: undefined,
|
|
8363
8200
|
y: -40
|
|
@@ -8437,7 +8274,7 @@ describe('highcharts_renderer', () => {
|
|
|
8437
8274
|
colsForTotal: null,
|
|
8438
8275
|
initialName: "3",
|
|
8439
8276
|
isSum: false,
|
|
8440
|
-
isTotal: false,
|
|
8277
|
+
isTotal: false,
|
|
8441
8278
|
name: "formatted(3)",
|
|
8442
8279
|
totalIndex: undefined,
|
|
8443
8280
|
y: -40
|
|
@@ -8526,7 +8363,7 @@ describe('highcharts_renderer', () => {
|
|
|
8526
8363
|
colsForTotal: null,
|
|
8527
8364
|
initialName: "2 , 1707389500",
|
|
8528
8365
|
isSum: false,
|
|
8529
|
-
isTotal: false,
|
|
8366
|
+
isTotal: false,
|
|
8530
8367
|
name: "formatted(2 , 1707389500)",
|
|
8531
8368
|
totalIndex: undefined,
|
|
8532
8369
|
y: -40
|
|
@@ -8615,7 +8452,7 @@ describe('highcharts_renderer', () => {
|
|
|
8615
8452
|
colsForTotal: null,
|
|
8616
8453
|
initialName: "2 , 1707389500",
|
|
8617
8454
|
isSum: false,
|
|
8618
|
-
isTotal: false,
|
|
8455
|
+
isTotal: false,
|
|
8619
8456
|
name: "formatted(2 , 1707389500)",
|
|
8620
8457
|
totalIndex: undefined,
|
|
8621
8458
|
y: -40
|
|
@@ -8706,7 +8543,7 @@ describe('highcharts_renderer', () => {
|
|
|
8706
8543
|
colsForTotal: null,
|
|
8707
8544
|
initialName: "2 , 1707389500",
|
|
8708
8545
|
isSum: false,
|
|
8709
|
-
isTotal: false,
|
|
8546
|
+
isTotal: false,
|
|
8710
8547
|
name: "formatted(2 , 1707389500)",
|
|
8711
8548
|
totalIndex: undefined,
|
|
8712
8549
|
y: -40
|
|
@@ -8792,7 +8629,7 @@ describe('highcharts_renderer', () => {
|
|
|
8792
8629
|
colsForTotal: null,
|
|
8793
8630
|
initialName: "2 , 1707389500",
|
|
8794
8631
|
isSum: false,
|
|
8795
|
-
isTotal: false,
|
|
8632
|
+
isTotal: false,
|
|
8796
8633
|
name: "formatted(2 , 1707389500)",
|
|
8797
8634
|
totalIndex: undefined,
|
|
8798
8635
|
y: -40
|
|
@@ -8878,7 +8715,7 @@ describe('highcharts_renderer', () => {
|
|
|
8878
8715
|
colsForTotal: null,
|
|
8879
8716
|
initialName: "2 , 1707389500",
|
|
8880
8717
|
isSum: false,
|
|
8881
|
-
isTotal: false,
|
|
8718
|
+
isTotal: false,
|
|
8882
8719
|
name: "formatted(2 , 1707389500)",
|
|
8883
8720
|
totalIndex: undefined,
|
|
8884
8721
|
y: -40
|
|
@@ -8923,11 +8760,11 @@ describe('highcharts_renderer', () => {
|
|
|
8923
8760
|
.mockReturnValue([{ name: 'Sample Series', data: [1, 2, 3] }]);
|
|
8924
8761
|
jest.spyOn(highchartsRenderer, 'ptCreateElementAndDraw').mockImplementation(() => {});
|
|
8925
8762
|
});
|
|
8926
|
-
|
|
8763
|
+
|
|
8927
8764
|
afterEach(() => {
|
|
8928
8765
|
jest.restoreAllMocks();
|
|
8929
8766
|
});
|
|
8930
|
-
|
|
8767
|
+
|
|
8931
8768
|
it('should call ptCreateElementAndDraw with correct chart options', () => {
|
|
8932
8769
|
const pivotData = {
|
|
8933
8770
|
getColKeys: jest.fn(() => [['Category 1'], ['Category 2']]),
|
|
@@ -8939,7 +8776,7 @@ describe('highcharts_renderer', () => {
|
|
|
8939
8776
|
rows: { 0: { type: 'Date' }, 1: { type: 'Date' } },
|
|
8940
8777
|
cols: { 0: { type: 'Category' }, 1: { type: 'Category' } }
|
|
8941
8778
|
};
|
|
8942
|
-
|
|
8779
|
+
|
|
8943
8780
|
const opts = {
|
|
8944
8781
|
chartOptions: {
|
|
8945
8782
|
label_pie: {
|
|
@@ -8951,11 +8788,11 @@ describe('highcharts_renderer', () => {
|
|
|
8951
8788
|
}
|
|
8952
8789
|
}
|
|
8953
8790
|
};
|
|
8954
|
-
|
|
8791
|
+
|
|
8955
8792
|
const drilldownFunc = jest.fn();
|
|
8956
8793
|
|
|
8957
8794
|
highchartsRenderer.ptRenderPieWithDrillDown(pivotData, opts, drilldownFunc);
|
|
8958
|
-
|
|
8795
|
+
|
|
8959
8796
|
const expectedChartOptions = {
|
|
8960
8797
|
chart: {
|
|
8961
8798
|
type: 'pie',
|
|
@@ -8964,7 +8801,7 @@ describe('highcharts_renderer', () => {
|
|
|
8964
8801
|
drillup: expect.any(Function)
|
|
8965
8802
|
}
|
|
8966
8803
|
},
|
|
8967
|
-
colors: ["#91e7e7", "#f37789", "#ffdc65", "#0e569d", "#bbe0ff", "#57b2ff", "#5ecfb9", "#c7ffda", "#179ab9", "#008aff"],
|
|
8804
|
+
colors: ["#91e7e7", "#f37789", "#ffdc65", "#0e569d", "#bbe0ff", "#57b2ff", "#5ecfb9", "#c7ffda", "#179ab9", "#008aff"],
|
|
8968
8805
|
plotOptions: {
|
|
8969
8806
|
series: {
|
|
8970
8807
|
animation: true,
|
|
@@ -8974,7 +8811,7 @@ describe('highcharts_renderer', () => {
|
|
|
8974
8811
|
enabled: true,
|
|
8975
8812
|
formatter: expect.any(Function),
|
|
8976
8813
|
style: {
|
|
8977
|
-
"fontFamily": "Poppins",
|
|
8814
|
+
"fontFamily": "Poppins",
|
|
8978
8815
|
"fontSize": "11",
|
|
8979
8816
|
"fontWeight": "normal"
|
|
8980
8817
|
}
|
|
@@ -8986,7 +8823,7 @@ describe('highcharts_renderer', () => {
|
|
|
8986
8823
|
headerFormat: '',
|
|
8987
8824
|
pointFormatter: expect.any(Function)
|
|
8988
8825
|
},
|
|
8989
|
-
series: [{ name: 'Sample Series', data: [1, 2, 3] }],
|
|
8826
|
+
series: [{ name: 'Sample Series', data: [1, 2, 3] }],
|
|
8990
8827
|
legend: {
|
|
8991
8828
|
align: "right",
|
|
8992
8829
|
borderWidth: 0,
|
|
@@ -8996,7 +8833,7 @@ describe('highcharts_renderer', () => {
|
|
|
8996
8833
|
verticalAlign: "top",
|
|
8997
8834
|
y: 13
|
|
8998
8835
|
},
|
|
8999
|
-
drilldown: {},
|
|
8836
|
+
drilldown: {},
|
|
9000
8837
|
subtitle: {
|
|
9001
8838
|
align: "center",
|
|
9002
8839
|
style: {
|
|
@@ -9028,7 +8865,7 @@ describe('highcharts_renderer', () => {
|
|
|
9028
8865
|
getRowKeys: jest.fn(() => [['Row 1'], ['Row 2']]),
|
|
9029
8866
|
getAggregator: jest.fn(() => ({ value: jest.fn(() => 100) }))
|
|
9030
8867
|
};
|
|
9031
|
-
|
|
8868
|
+
|
|
9032
8869
|
const opts = {
|
|
9033
8870
|
chartOptions: {
|
|
9034
8871
|
label_pie: { show: true, overlap: true },
|
|
@@ -9037,19 +8874,19 @@ describe('highcharts_renderer', () => {
|
|
|
9037
8874
|
},
|
|
9038
8875
|
drillDownListFunc: jest.fn()
|
|
9039
8876
|
};
|
|
9040
|
-
|
|
8877
|
+
|
|
9041
8878
|
beforeEach(() => {
|
|
9042
8879
|
jest.spyOn(highchartsRenderer, 'ptCreateElementAndDraw').mockImplementation(() => {});
|
|
9043
8880
|
jest.spyOn(highchartsRenderer, 'getFormattedColKey').mockImplementation((name) => `Formatted ${name}`);
|
|
9044
8881
|
});
|
|
9045
|
-
|
|
8882
|
+
|
|
9046
8883
|
afterEach(() => {
|
|
9047
8884
|
jest.restoreAllMocks();
|
|
9048
8885
|
});
|
|
9049
|
-
|
|
8886
|
+
|
|
9050
8887
|
it('should call ptCreateElementAndDraw with correct chart options', () => {
|
|
9051
8888
|
highchartsRenderer.ptRenderBasicPie(pivotData, opts);
|
|
9052
|
-
|
|
8889
|
+
|
|
9053
8890
|
expect(highchartsRenderer.ptCreateElementAndDraw).toHaveBeenCalledWith(
|
|
9054
8891
|
expect.objectContaining({
|
|
9055
8892
|
chart: expect.objectContaining({
|
|
@@ -9504,7 +9341,7 @@ describe('highcharts_renderer', () => {
|
|
|
9504
9341
|
pivotData.getAggregator().value.mockReturnValue(10);
|
|
9505
9342
|
highchartsRenderer.getOthersName.mockReturnValue('Others');
|
|
9506
9343
|
highchartsRenderer.getFormattedColKey.mockReturnValue('FormattedKey');
|
|
9507
|
-
|
|
9344
|
+
|
|
9508
9345
|
const result = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, chartOptions, additionOptions, opts);
|
|
9509
9346
|
expect(result[0].data[0].initialName).toEqual('\u200Eשלום');
|
|
9510
9347
|
});
|
|
@@ -9515,11 +9352,11 @@ describe('highcharts_renderer', () => {
|
|
|
9515
9352
|
pivotData.getAggregator().value.mockReturnValue(10);
|
|
9516
9353
|
highchartsRenderer.getOthersName.mockReturnValue('Others');
|
|
9517
9354
|
highchartsRenderer.getFormattedColKey.mockReturnValue('FormattedKey');
|
|
9518
|
-
|
|
9355
|
+
|
|
9519
9356
|
const result = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, chartOptions, additionOptions, opts);
|
|
9520
9357
|
expect(result[0].data[0].initialName).toEqual('Others');
|
|
9521
9358
|
});
|
|
9522
|
-
|
|
9359
|
+
|
|
9523
9360
|
it('should handle negative values when chart type is not pie', () => {
|
|
9524
9361
|
chartOptions.chart.type = 'notPie';
|
|
9525
9362
|
pivotData.getColKeys.mockReturnValue(['key1']);
|
|
@@ -9527,25 +9364,25 @@ describe('highcharts_renderer', () => {
|
|
|
9527
9364
|
pivotData.getAggregator().value.mockReturnValue(-10);
|
|
9528
9365
|
highchartsRenderer.getOthersName.mockReturnValue('Others');
|
|
9529
9366
|
highchartsRenderer.getFormattedColKey.mockReturnValue('FormattedKey');
|
|
9530
|
-
|
|
9367
|
+
|
|
9531
9368
|
const result = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, chartOptions, additionOptions, opts);
|
|
9532
9369
|
expect(result[0].data[0].y).toEqual(-10);
|
|
9533
9370
|
});
|
|
9534
|
-
|
|
9371
|
+
|
|
9535
9372
|
it('should handle numeric keys', () => {
|
|
9536
9373
|
pivotData.getColKeys.mockReturnValue(['123']);
|
|
9537
9374
|
pivotData.getRowKeys.mockReturnValue(['row1']);
|
|
9538
9375
|
pivotData.getAggregator().value.mockReturnValue(10);
|
|
9539
9376
|
highchartsRenderer.getOthersName.mockReturnValue('Others');
|
|
9540
9377
|
highchartsRenderer.getFormattedColKey.mockReturnValue('FormattedKey');
|
|
9541
|
-
|
|
9378
|
+
|
|
9542
9379
|
const result = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, chartOptions, additionOptions, opts);
|
|
9543
9380
|
expect(result[0].data[0].drilldown).toEqual(123);
|
|
9544
9381
|
});
|
|
9545
9382
|
});
|
|
9546
9383
|
|
|
9547
9384
|
describe('Function getDataLabelsStylesForDrillDown', () => {
|
|
9548
|
-
|
|
9385
|
+
|
|
9549
9386
|
it('should return an object with activeDataLabelStyle containing color from dataLabels', () => {
|
|
9550
9387
|
const mockColor = 'red';
|
|
9551
9388
|
const additionalOptions = {
|