@datarailsshared/dr_renderer 1.2.397 → 1.2.399
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/tests/highcharts_renderer.test.js +987 -10
package/package.json
CHANGED
@@ -6178,7 +6178,7 @@ describe('highcharts_renderer', () => {
|
|
6178
6178
|
describe("Function updateFiltersShowNames", () => {
|
6179
6179
|
|
6180
6180
|
it("should receive array or object", () => {
|
6181
|
-
|
6181
|
+
|
6182
6182
|
const filters = [{
|
6183
6183
|
field: 4030578,
|
6184
6184
|
name: "Month",
|
@@ -6200,13 +6200,13 @@ describe('highcharts_renderer', () => {
|
|
6200
6200
|
override_global_filter: false,
|
6201
6201
|
},
|
6202
6202
|
];
|
6203
|
-
|
6203
|
+
|
6204
6204
|
highchartsRenderer.updateFiltersShowNames(filters);
|
6205
|
-
|
6205
|
+
|
6206
6206
|
expect(filters[0].value_to_show).toEqual("04/30/2023, 03/31/2023, [null]");
|
6207
6207
|
expect(filters[1].value_to_show).toEqual("All");
|
6208
6208
|
});
|
6209
|
-
|
6209
|
+
|
6210
6210
|
it("should receive array or object", () => {
|
6211
6211
|
const filters = [{
|
6212
6212
|
field: 934090,
|
@@ -6236,14 +6236,14 @@ describe('highcharts_renderer', () => {
|
|
6236
6236
|
override_global_filter: false,
|
6237
6237
|
},
|
6238
6238
|
];
|
6239
|
-
|
6239
|
+
|
6240
6240
|
highchartsRenderer.updateFiltersShowNames(filters);
|
6241
|
-
|
6241
|
+
|
6242
6242
|
expect(filters[0].value_to_show).toEqual("Activity");
|
6243
6243
|
expect(filters[1].value_to_show).toEqual("All");
|
6244
6244
|
});
|
6245
6245
|
});
|
6246
|
-
|
6246
|
+
|
6247
6247
|
describe("Function returnRawDataValue", () => {
|
6248
6248
|
const testCases = [{
|
6249
6249
|
name: "Date",
|
@@ -6292,7 +6292,7 @@ describe('highcharts_renderer', () => {
|
|
6292
6292
|
expectedResults: [100, 200, "[null]", "[null]", "Text", 0],
|
6293
6293
|
},
|
6294
6294
|
];
|
6295
|
-
|
6295
|
+
|
6296
6296
|
testCases.forEach((testCase) => {
|
6297
6297
|
describe(`Scenario: ${testCase.name}`, () => {
|
6298
6298
|
testCase.filter.values.forEach((value, index) => {
|
@@ -6304,7 +6304,7 @@ describe('highcharts_renderer', () => {
|
|
6304
6304
|
});
|
6305
6305
|
});
|
6306
6306
|
});
|
6307
|
-
|
6307
|
+
|
6308
6308
|
describe("Function check_values_not_for_convert", () => {
|
6309
6309
|
const testCases = [{
|
6310
6310
|
name: "should return a array when field is series row name equal to field name",
|
@@ -6404,7 +6404,7 @@ describe('highcharts_renderer', () => {
|
|
6404
6404
|
expected: [],
|
6405
6405
|
},
|
6406
6406
|
];
|
6407
|
-
|
6407
|
+
|
6408
6408
|
testCases.forEach(({
|
6409
6409
|
name,
|
6410
6410
|
currentgraph,
|
@@ -6420,4 +6420,981 @@ describe('highcharts_renderer', () => {
|
|
6420
6420
|
});
|
6421
6421
|
});
|
6422
6422
|
});
|
6423
|
+
describe('Function ptCreateColumnSeries', () => {
|
6424
|
+
const format = null;
|
6425
|
+
let pivotDataMock, additionalOptionsMock, colors, onlyNumbers, isUniqueVals, opts, chartOptions, isNotDrillDown, chartType;
|
6426
|
+
beforeEach(() => {
|
6427
|
+
colors = [
|
6428
|
+
"#ff0202",
|
6429
|
+
"#b3060e",
|
6430
|
+
"#70000a"
|
6431
|
+
];
|
6432
|
+
opts = {};
|
6433
|
+
chartOptions = {};
|
6434
|
+
pivotDataMock = {
|
6435
|
+
getAggregator: (rows, cols) => {
|
6436
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
6437
|
+
const agg = aggregator({}, '', '');
|
6438
|
+
|
6439
|
+
if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, ['row 1'])) {
|
6440
|
+
agg.sum = 12345;
|
6441
|
+
} else if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, ['row 2'])) {
|
6442
|
+
agg.sum = 123450;
|
6443
|
+
} else if (lodash.isEqual(cols, ['col 2']) && lodash.isEqual(rows, ['row 1'])) {
|
6444
|
+
agg.sum = 54321;
|
6445
|
+
} else if (lodash.isEqual(cols, ['col 2']) && lodash.isEqual(rows, ['row 2'])) {
|
6446
|
+
agg.sum = 11111;
|
6447
|
+
} else if (lodash.isEqual(cols, [highchartsRenderer.DR_OTHERS_KEY]) && lodash.isEqual(rows, ['row 1'])) {
|
6448
|
+
agg.sum = 99999;
|
6449
|
+
} else if (lodash.isEqual(cols, [highchartsRenderer.DR_OTHERS_KEY]) && lodash.isEqual(rows, ['row 2'])) {
|
6450
|
+
agg.sum = 99991;
|
6451
|
+
}
|
6452
|
+
|
6453
|
+
return agg;
|
6454
|
+
},
|
6455
|
+
getColKeys: () => [['col 1'], ['col 2'], [highchartsRenderer.DR_OTHERS_KEY]],
|
6456
|
+
getRowKeys: () => [['row 1'], ['row 2']],
|
6457
|
+
rowFormats: [],
|
6458
|
+
colFormats: [],
|
6459
|
+
rowAttrs: ['row 1'],
|
6460
|
+
};
|
6461
|
+
});
|
6462
|
+
|
6463
|
+
it('should prepare appropriate chart series, when additional options have delta column \'field\'', ()=> {
|
6464
|
+
additionalOptionsMock = {
|
6465
|
+
delta_column: {
|
6466
|
+
field: 'series',
|
6467
|
+
name: 'row 1',
|
6468
|
+
chart: 'line'
|
6469
|
+
}
|
6470
|
+
};
|
6471
|
+
const value = highchartsRenderer.ptCreateColumnSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, isNotDrillDown, additionalOptionsMock, opts, chartOptions, chartType);
|
6472
|
+
expect(value).toEqual([
|
6473
|
+
{
|
6474
|
+
data: [
|
6475
|
+
{
|
6476
|
+
initialName: 'col 1',
|
6477
|
+
name: 'col 1',
|
6478
|
+
y: 123450,
|
6479
|
+
drilldown: true
|
6480
|
+
},
|
6481
|
+
{
|
6482
|
+
initialName: 'col 2',
|
6483
|
+
name: 'col 2',
|
6484
|
+
y: 11111,
|
6485
|
+
drilldown: true
|
6486
|
+
},
|
6487
|
+
{
|
6488
|
+
initialName: 'Others',
|
6489
|
+
name: 'Others',
|
6490
|
+
y: 99991,
|
6491
|
+
drilldown: true
|
6492
|
+
}
|
6493
|
+
],
|
6494
|
+
initialName: 'row 2',
|
6495
|
+
name: 'row 2',
|
6496
|
+
dataLabels: {
|
6497
|
+
style: {
|
6498
|
+
fontSize: '11',
|
6499
|
+
fontFamily: 'Poppins',
|
6500
|
+
fontWeight: 'normal'
|
6501
|
+
},
|
6502
|
+
color: '#151a41',
|
6503
|
+
allowOverlap: false,
|
6504
|
+
enabled: true,
|
6505
|
+
formatter: expect.any(Function)
|
6506
|
+
},
|
6507
|
+
color: '#b3060e'
|
6508
|
+
},
|
6509
|
+
{
|
6510
|
+
data: [
|
6511
|
+
{
|
6512
|
+
initialName: 'col 1',
|
6513
|
+
name: 'col 1',
|
6514
|
+
y: 12345,
|
6515
|
+
drilldown: true
|
6516
|
+
},
|
6517
|
+
{
|
6518
|
+
initialName: 'col 2',
|
6519
|
+
name: 'col 2',
|
6520
|
+
y: 54321,
|
6521
|
+
drilldown: true
|
6522
|
+
},
|
6523
|
+
{
|
6524
|
+
initialName: 'Others',
|
6525
|
+
name: 'Others',
|
6526
|
+
y: 99999,
|
6527
|
+
drilldown: true
|
6528
|
+
}
|
6529
|
+
],
|
6530
|
+
initialName: 'row 1',
|
6531
|
+
name: 'row 1',
|
6532
|
+
dataLabels: {
|
6533
|
+
style: {
|
6534
|
+
fontSize: '11',
|
6535
|
+
fontFamily: 'Poppins',
|
6536
|
+
fontWeight: 'normal'
|
6537
|
+
},
|
6538
|
+
color: '#151a41',
|
6539
|
+
allowOverlap: false,
|
6540
|
+
enabled: true,
|
6541
|
+
formatter: expect.any(Function)
|
6542
|
+
},
|
6543
|
+
color: '#5ecfb9',
|
6544
|
+
type: 'line',
|
6545
|
+
lineColor: '#5ecfb9',
|
6546
|
+
marker: {
|
6547
|
+
lineColor: '#5ecfb9'
|
6548
|
+
}
|
6549
|
+
}
|
6550
|
+
]);
|
6551
|
+
});
|
6552
|
+
it('should prepare appropriate chart series, when additional options have delta column \'only variant\'', ()=> {
|
6553
|
+
additionalOptionsMock = {
|
6554
|
+
delta_column: {
|
6555
|
+
field: 'series',
|
6556
|
+
only_variant: true,
|
6557
|
+
name: 'row 1',
|
6558
|
+
chart: 'line'
|
6559
|
+
}
|
6560
|
+
};
|
6561
|
+
const value = highchartsRenderer.ptCreateColumnSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, isNotDrillDown, additionalOptionsMock, opts, chartOptions, chartType);
|
6562
|
+
expect(value).toEqual([
|
6563
|
+
{
|
6564
|
+
data: [
|
6565
|
+
{
|
6566
|
+
initialName: 'col 1',
|
6567
|
+
name: 'col 1',
|
6568
|
+
y: 12345,
|
6569
|
+
drilldown: true
|
6570
|
+
},
|
6571
|
+
{
|
6572
|
+
initialName: 'col 2',
|
6573
|
+
name: 'col 2',
|
6574
|
+
y: 54321,
|
6575
|
+
drilldown: true
|
6576
|
+
},
|
6577
|
+
{
|
6578
|
+
initialName: 'Others',
|
6579
|
+
name: 'Others',
|
6580
|
+
y: 99999,
|
6581
|
+
drilldown: true
|
6582
|
+
}
|
6583
|
+
],
|
6584
|
+
initialName: 'row 1',
|
6585
|
+
name: 'row 1',
|
6586
|
+
dataLabels: {
|
6587
|
+
style: {
|
6588
|
+
fontSize: '11',
|
6589
|
+
fontFamily: 'Poppins',
|
6590
|
+
fontWeight: 'normal'
|
6591
|
+
},
|
6592
|
+
color: '#151a41',
|
6593
|
+
allowOverlap: false,
|
6594
|
+
enabled: true,
|
6595
|
+
formatter: expect.any(Function)
|
6596
|
+
},
|
6597
|
+
color: '#5ecfb9',
|
6598
|
+
type: 'line',
|
6599
|
+
lineColor: '#5ecfb9',
|
6600
|
+
marker: {
|
6601
|
+
lineColor: '#5ecfb9'
|
6602
|
+
}
|
6603
|
+
}
|
6604
|
+
]);
|
6605
|
+
});
|
6606
|
+
it('should prepare appropriate chart series, when opts \'total\' configuration is set to true', ()=> {
|
6607
|
+
additionalOptionsMock = {};
|
6608
|
+
opts = {
|
6609
|
+
total: true
|
6610
|
+
};
|
6611
|
+
pivotDataMock.colTotals = {
|
6612
|
+
'col 1': {value: () => 123450},
|
6613
|
+
'col 2': {value: () => 123451},
|
6614
|
+
'DR_Others': {value: () => 123452},
|
6615
|
+
};
|
6616
|
+
const value = highchartsRenderer.ptCreateColumnSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, isNotDrillDown, additionalOptionsMock, opts, chartOptions, chartType);
|
6617
|
+
expect(value).toEqual([
|
6618
|
+
{
|
6619
|
+
color: '#ff0202',
|
6620
|
+
data: [
|
6621
|
+
{
|
6622
|
+
drilldown: true,
|
6623
|
+
initialName: 'col 1',
|
6624
|
+
name: 'col 1',
|
6625
|
+
y: 12345
|
6626
|
+
},
|
6627
|
+
{
|
6628
|
+
drilldown: true,
|
6629
|
+
initialName: 'col 2',
|
6630
|
+
name: 'col 2',
|
6631
|
+
y: 54321
|
6632
|
+
},
|
6633
|
+
{
|
6634
|
+
drilldown: true,
|
6635
|
+
initialName: 'Others',
|
6636
|
+
name: 'Others',
|
6637
|
+
y: 99999
|
6638
|
+
}
|
6639
|
+
],
|
6640
|
+
dataLabels: {
|
6641
|
+
allowOverlap: false,
|
6642
|
+
color: '#151a41',
|
6643
|
+
enabled: true,
|
6644
|
+
formatter: expect.any(Function),
|
6645
|
+
style: {
|
6646
|
+
fontFamily: 'Poppins',
|
6647
|
+
fontSize: '11',
|
6648
|
+
fontWeight: 'normal'
|
6649
|
+
}
|
6650
|
+
},
|
6651
|
+
initialName: 'row 1',
|
6652
|
+
name: 'row 1'
|
6653
|
+
},
|
6654
|
+
{
|
6655
|
+
color: '#b3060e',
|
6656
|
+
data: [
|
6657
|
+
{
|
6658
|
+
drilldown: true,
|
6659
|
+
initialName: 'col 1',
|
6660
|
+
name: 'col 1',
|
6661
|
+
y: 123450
|
6662
|
+
},
|
6663
|
+
{
|
6664
|
+
drilldown: true,
|
6665
|
+
initialName: 'col 2',
|
6666
|
+
name: 'col 2',
|
6667
|
+
y: 11111
|
6668
|
+
},
|
6669
|
+
{
|
6670
|
+
drilldown: true,
|
6671
|
+
initialName: 'Others',
|
6672
|
+
name: 'Others',
|
6673
|
+
y: 99991
|
6674
|
+
}
|
6675
|
+
],
|
6676
|
+
dataLabels: {
|
6677
|
+
allowOverlap: false,
|
6678
|
+
color: '#151a41',
|
6679
|
+
enabled: true,
|
6680
|
+
formatter: expect.any(Function),
|
6681
|
+
style: {
|
6682
|
+
fontFamily: 'Poppins',
|
6683
|
+
fontSize: '11',
|
6684
|
+
fontWeight: 'normal'
|
6685
|
+
}
|
6686
|
+
},
|
6687
|
+
initialName: 'row 2',
|
6688
|
+
name: 'row 2'
|
6689
|
+
},
|
6690
|
+
{
|
6691
|
+
className: 'totalSeries',
|
6692
|
+
color: '#70000a',
|
6693
|
+
data: [
|
6694
|
+
{
|
6695
|
+
initialName: 'col 1',
|
6696
|
+
name: 'col 1',
|
6697
|
+
y: 123450
|
6698
|
+
},
|
6699
|
+
{
|
6700
|
+
initialName: 'col 2',
|
6701
|
+
name: 'col 2',
|
6702
|
+
y: 123451
|
6703
|
+
},
|
6704
|
+
{
|
6705
|
+
initialName: 'DR_Others',
|
6706
|
+
name: 'DR_Others',
|
6707
|
+
y: 123452
|
6708
|
+
}
|
6709
|
+
],
|
6710
|
+
dataLabels: {
|
6711
|
+
allowOverlap: false,
|
6712
|
+
color: '#151a41',
|
6713
|
+
enabled: true,
|
6714
|
+
formatter: expect.any(Function),
|
6715
|
+
style: {
|
6716
|
+
fontFamily: 'Poppins',
|
6717
|
+
fontSize: '11',
|
6718
|
+
fontWeight: 'normal'
|
6719
|
+
}
|
6720
|
+
},
|
6721
|
+
initialName: 'row 2',
|
6722
|
+
name: 'Total'
|
6723
|
+
}
|
6724
|
+
]);
|
6725
|
+
});
|
6726
|
+
it('should prepare appropriate chart series, when opts \'trendLine\' configuration is set to true', ()=> {
|
6727
|
+
opts = {
|
6728
|
+
trendLine: true
|
6729
|
+
};
|
6730
|
+
const value = highchartsRenderer.ptCreateColumnSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, isNotDrillDown, additionalOptionsMock, opts, chartOptions, chartType);
|
6731
|
+
expect(value).toEqual([
|
6732
|
+
{
|
6733
|
+
data: [
|
6734
|
+
{
|
6735
|
+
initialName: 'col 1',
|
6736
|
+
name: 'col 1',
|
6737
|
+
y: 12345,
|
6738
|
+
drilldown: true
|
6739
|
+
},
|
6740
|
+
{
|
6741
|
+
initialName: 'col 2',
|
6742
|
+
name: 'col 2',
|
6743
|
+
y: 54321,
|
6744
|
+
drilldown: true
|
6745
|
+
},
|
6746
|
+
{
|
6747
|
+
initialName: 'Others',
|
6748
|
+
name: 'Others',
|
6749
|
+
y: 99999,
|
6750
|
+
drilldown: true
|
6751
|
+
}
|
6752
|
+
],
|
6753
|
+
initialName: 'row 1',
|
6754
|
+
name: 'row 1',
|
6755
|
+
dataLabels: {
|
6756
|
+
style: {
|
6757
|
+
fontSize: '11',
|
6758
|
+
fontFamily: 'Poppins',
|
6759
|
+
fontWeight: 'normal'
|
6760
|
+
},
|
6761
|
+
color: '#151a41',
|
6762
|
+
allowOverlap: false,
|
6763
|
+
enabled: true,
|
6764
|
+
formatter: expect.any(Function),
|
6765
|
+
},
|
6766
|
+
color: '#ff0202'
|
6767
|
+
},
|
6768
|
+
{
|
6769
|
+
data: [
|
6770
|
+
{
|
6771
|
+
initialName: 'col 1',
|
6772
|
+
name: 'col 1',
|
6773
|
+
y: 123450,
|
6774
|
+
drilldown: true
|
6775
|
+
},
|
6776
|
+
{
|
6777
|
+
initialName: 'col 2',
|
6778
|
+
name: 'col 2',
|
6779
|
+
y: 11111,
|
6780
|
+
drilldown: true
|
6781
|
+
},
|
6782
|
+
{
|
6783
|
+
initialName: 'Others',
|
6784
|
+
name: 'Others',
|
6785
|
+
y: 99991,
|
6786
|
+
drilldown: true
|
6787
|
+
}
|
6788
|
+
],
|
6789
|
+
initialName: 'row 2',
|
6790
|
+
name: 'row 2',
|
6791
|
+
dataLabels: {
|
6792
|
+
style: {
|
6793
|
+
fontSize: '11',
|
6794
|
+
fontFamily: 'Poppins',
|
6795
|
+
fontWeight: 'normal'
|
6796
|
+
},
|
6797
|
+
color: '#151a41',
|
6798
|
+
allowOverlap: false,
|
6799
|
+
enabled: true,
|
6800
|
+
formatter: expect.any(Function),
|
6801
|
+
},
|
6802
|
+
color: '#b3060e'
|
6803
|
+
},
|
6804
|
+
{
|
6805
|
+
data: [
|
6806
|
+
{
|
6807
|
+
name: 'col 1',
|
6808
|
+
y: 11728
|
6809
|
+
},
|
6810
|
+
{
|
6811
|
+
name: 'col 2',
|
6812
|
+
y: 55555
|
6813
|
+
},
|
6814
|
+
{
|
6815
|
+
name: 'Others',
|
6816
|
+
y: 99382
|
6817
|
+
}
|
6818
|
+
],
|
6819
|
+
initialName: 'row 1',
|
6820
|
+
name: 'Trend Line (row 1)',
|
6821
|
+
dataLabels: {
|
6822
|
+
style: {
|
6823
|
+
fontSize: '11',
|
6824
|
+
fontFamily: 'Poppins',
|
6825
|
+
fontWeight: 'normal'
|
6826
|
+
},
|
6827
|
+
color: '#151a41',
|
6828
|
+
allowOverlap: false,
|
6829
|
+
enabled: true,
|
6830
|
+
formatter: expect.any(Function),
|
6831
|
+
},
|
6832
|
+
color: '#ff0202',
|
6833
|
+
className: 'trendSeries',
|
6834
|
+
dashStyle: 'shortdot',
|
6835
|
+
type: 'line'
|
6836
|
+
},
|
6837
|
+
{
|
6838
|
+
data: [
|
6839
|
+
{
|
6840
|
+
name: 'col 1',
|
6841
|
+
y: 89913.5
|
6842
|
+
},
|
6843
|
+
{
|
6844
|
+
name: 'col 2',
|
6845
|
+
y: 78184
|
6846
|
+
},
|
6847
|
+
{
|
6848
|
+
name: 'Others',
|
6849
|
+
y: 66454.5
|
6850
|
+
}
|
6851
|
+
],
|
6852
|
+
initialName: 'row 2',
|
6853
|
+
name: 'Trend Line (row 2)',
|
6854
|
+
dataLabels: {
|
6855
|
+
style: {
|
6856
|
+
fontSize: '11',
|
6857
|
+
fontFamily: 'Poppins',
|
6858
|
+
fontWeight: 'normal'
|
6859
|
+
},
|
6860
|
+
color: '#151a41',
|
6861
|
+
allowOverlap: false,
|
6862
|
+
enabled: true,
|
6863
|
+
formatter: expect.any(Function),
|
6864
|
+
},
|
6865
|
+
color: '#b3060e',
|
6866
|
+
className: 'trendSeries',
|
6867
|
+
dashStyle: 'shortdot',
|
6868
|
+
type: 'line'
|
6869
|
+
}
|
6870
|
+
]);
|
6871
|
+
});
|
6872
|
+
it('should prepare appropriate chart series, when opts \'comboOptions\' has valid series name to process', () => {
|
6873
|
+
opts = {
|
6874
|
+
comboOptions: {
|
6875
|
+
seriesOptions: [
|
6876
|
+
{
|
6877
|
+
series: 'row 1',
|
6878
|
+
chartType: 'area-chart'
|
6879
|
+
}
|
6880
|
+
]
|
6881
|
+
}
|
6882
|
+
};
|
6883
|
+
chartType = ['combo'];
|
6884
|
+
const value = highchartsRenderer.ptCreateColumnSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, isNotDrillDown, additionalOptionsMock, opts, chartOptions, chartType);
|
6885
|
+
expect(value).toEqual([
|
6886
|
+
{
|
6887
|
+
data: [
|
6888
|
+
{
|
6889
|
+
initialName: 'col 1',
|
6890
|
+
name: 'col 1',
|
6891
|
+
y: 12345,
|
6892
|
+
drilldown: true
|
6893
|
+
},
|
6894
|
+
{
|
6895
|
+
initialName: 'col 2',
|
6896
|
+
name: 'col 2',
|
6897
|
+
y: 54321,
|
6898
|
+
drilldown: true
|
6899
|
+
},
|
6900
|
+
{
|
6901
|
+
initialName: 'Others',
|
6902
|
+
name: 'Others',
|
6903
|
+
y: 99999,
|
6904
|
+
drilldown: true
|
6905
|
+
}
|
6906
|
+
],
|
6907
|
+
initialName: 'row 1',
|
6908
|
+
name: 'row 1',
|
6909
|
+
dataLabels: {
|
6910
|
+
style: {
|
6911
|
+
fontSize: '11',
|
6912
|
+
fontFamily: 'Poppins',
|
6913
|
+
fontWeight: 'normal'
|
6914
|
+
},
|
6915
|
+
color: '#151a41',
|
6916
|
+
allowOverlap: false,
|
6917
|
+
enabled: true,
|
6918
|
+
formatter: expect.any(Function),
|
6919
|
+
},
|
6920
|
+
color: '#ff0202',
|
6921
|
+
type: 'area'
|
6922
|
+
},
|
6923
|
+
{data: [
|
6924
|
+
{
|
6925
|
+
initialName: 'col 1',
|
6926
|
+
name: 'col 1',
|
6927
|
+
y: 123450,
|
6928
|
+
drilldown: true
|
6929
|
+
},
|
6930
|
+
{
|
6931
|
+
initialName: 'col 2',
|
6932
|
+
name: 'col 2',
|
6933
|
+
y: 11111,
|
6934
|
+
drilldown: true
|
6935
|
+
},
|
6936
|
+
{
|
6937
|
+
initialName: 'Others',
|
6938
|
+
name: 'Others',
|
6939
|
+
y: 99991,
|
6940
|
+
drilldown: true
|
6941
|
+
}
|
6942
|
+
],
|
6943
|
+
initialName: 'row 2',
|
6944
|
+
name: 'row 2',
|
6945
|
+
dataLabels: {
|
6946
|
+
style: {
|
6947
|
+
fontSize: '11',
|
6948
|
+
fontFamily: 'Poppins',
|
6949
|
+
fontWeight: 'normal'
|
6950
|
+
},
|
6951
|
+
color: '#151a41',
|
6952
|
+
allowOverlap: false,
|
6953
|
+
enabled: true,
|
6954
|
+
formatter: expect.any(Function),
|
6955
|
+
},
|
6956
|
+
color: '#b3060e',
|
6957
|
+
type: 'line'
|
6958
|
+
}
|
6959
|
+
]);
|
6960
|
+
});
|
6961
|
+
it('should prepare appropriate chart series for standard input', () => {
|
6962
|
+
opts = {};
|
6963
|
+
chartType = null;
|
6964
|
+
const value = highchartsRenderer.ptCreateColumnSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, isNotDrillDown, additionalOptionsMock, opts, chartOptions, chartType);
|
6965
|
+
expect(value).toEqual([
|
6966
|
+
{
|
6967
|
+
data: [
|
6968
|
+
{
|
6969
|
+
initialName: 'col 1',
|
6970
|
+
name: 'col 1',
|
6971
|
+
y: 12345,
|
6972
|
+
drilldown: true
|
6973
|
+
},
|
6974
|
+
{
|
6975
|
+
initialName: 'col 2',
|
6976
|
+
name: 'col 2',
|
6977
|
+
y: 54321,
|
6978
|
+
drilldown: true
|
6979
|
+
},
|
6980
|
+
{
|
6981
|
+
initialName: 'Others',
|
6982
|
+
name: 'Others',
|
6983
|
+
y: 99999,
|
6984
|
+
drilldown: true
|
6985
|
+
}
|
6986
|
+
],
|
6987
|
+
initialName: 'row 1',
|
6988
|
+
name: 'row 1',
|
6989
|
+
dataLabels: {
|
6990
|
+
style: {
|
6991
|
+
fontSize: '11',
|
6992
|
+
fontFamily: 'Poppins',
|
6993
|
+
fontWeight: 'normal'
|
6994
|
+
},
|
6995
|
+
color: '#151a41',
|
6996
|
+
allowOverlap: false,
|
6997
|
+
enabled: true,
|
6998
|
+
formatter: expect.any(Function),
|
6999
|
+
},
|
7000
|
+
color: '#ff0202'
|
7001
|
+
},
|
7002
|
+
{
|
7003
|
+
data: [
|
7004
|
+
{
|
7005
|
+
initialName: 'col 1',
|
7006
|
+
name: 'col 1',
|
7007
|
+
y: 123450,
|
7008
|
+
drilldown: true
|
7009
|
+
},
|
7010
|
+
{
|
7011
|
+
initialName: 'col 2',
|
7012
|
+
name: 'col 2',
|
7013
|
+
y: 11111,
|
7014
|
+
drilldown: true
|
7015
|
+
},
|
7016
|
+
{
|
7017
|
+
initialName: 'Others',
|
7018
|
+
name: 'Others',
|
7019
|
+
y: 99991,
|
7020
|
+
drilldown: true
|
7021
|
+
}
|
7022
|
+
],
|
7023
|
+
initialName: 'row 2',
|
7024
|
+
name: 'row 2',
|
7025
|
+
dataLabels: {
|
7026
|
+
style: {
|
7027
|
+
fontSize: '11',
|
7028
|
+
fontFamily: 'Poppins',
|
7029
|
+
fontWeight: 'normal'
|
7030
|
+
},
|
7031
|
+
color: '#151a41',
|
7032
|
+
allowOverlap: false,
|
7033
|
+
enabled: true,
|
7034
|
+
formatter: expect.any(Function),
|
7035
|
+
},
|
7036
|
+
color: '#b3060e'
|
7037
|
+
}
|
7038
|
+
]);
|
7039
|
+
})
|
7040
|
+
});
|
7041
|
+
describe('Function ptCreateBasicLineSeries', () => {
|
7042
|
+
const format = null;
|
7043
|
+
let pivotDataMock, additionalOptionsMock, colors, onlyNumbers, isUniqueVals, opts, chartOptions;
|
7044
|
+
beforeEach(() => {
|
7045
|
+
colors = [
|
7046
|
+
"#ff0202",
|
7047
|
+
"#b3060e",
|
7048
|
+
"#70000a"
|
7049
|
+
];
|
7050
|
+
opts = {};
|
7051
|
+
chartOptions = {};
|
7052
|
+
pivotDataMock = {
|
7053
|
+
getAggregator: (rows, cols) => {
|
7054
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
7055
|
+
const agg = aggregator({}, '', '');
|
7056
|
+
|
7057
|
+
if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, ['row 1'])) {
|
7058
|
+
agg.sum = 12345;
|
7059
|
+
} else if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, ['row 2'])) {
|
7060
|
+
agg.sum = 123450;
|
7061
|
+
} else if (lodash.isEqual(cols, ['col 2']) && lodash.isEqual(rows, ['row 1'])) {
|
7062
|
+
agg.sum = 54321;
|
7063
|
+
} else if (lodash.isEqual(cols, ['col 2']) && lodash.isEqual(rows, ['row 2'])) {
|
7064
|
+
agg.sum = 11111;
|
7065
|
+
} else if (lodash.isEqual(cols, [highchartsRenderer.DR_OTHERS_KEY]) && lodash.isEqual(rows, ['row 1'])) {
|
7066
|
+
agg.sum = 99999;
|
7067
|
+
} else if (lodash.isEqual(cols, [highchartsRenderer.DR_OTHERS_KEY]) && lodash.isEqual(rows, ['row 2'])) {
|
7068
|
+
agg.sum = 99991;
|
7069
|
+
}
|
7070
|
+
|
7071
|
+
return agg;
|
7072
|
+
},
|
7073
|
+
getColKeys: () => [['col 1'], ['col 2'], [highchartsRenderer.DR_OTHERS_KEY]],
|
7074
|
+
getRowKeys: () => [['row 1'], ['row 2']],
|
7075
|
+
rowFormats: [],
|
7076
|
+
colFormats: [],
|
7077
|
+
rowAttrs: ['row 1'],
|
7078
|
+
};
|
7079
|
+
});
|
7080
|
+
|
7081
|
+
it('should prepare appropriate chart series, when additional options have delta column \'field\'', ()=> {
|
7082
|
+
additionalOptionsMock = {
|
7083
|
+
delta_column: {
|
7084
|
+
field: 'series',
|
7085
|
+
name: 'row 1',
|
7086
|
+
chart: 'line'
|
7087
|
+
}
|
7088
|
+
};
|
7089
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7090
|
+
expect(value).toEqual([
|
7091
|
+
{
|
7092
|
+
data: [
|
7093
|
+
{
|
7094
|
+
y: 12345,
|
7095
|
+
initialName: 'col 1',
|
7096
|
+
name: 'col 1'
|
7097
|
+
},
|
7098
|
+
{
|
7099
|
+
y: 54321,
|
7100
|
+
initialName: 'col 2',
|
7101
|
+
name: 'col 2'
|
7102
|
+
},
|
7103
|
+
{
|
7104
|
+
y: 99999,
|
7105
|
+
initialName: 'Others',
|
7106
|
+
name: 'Others'
|
7107
|
+
}
|
7108
|
+
],
|
7109
|
+
initialName: 'row 1',
|
7110
|
+
name: 'row 1',
|
7111
|
+
color: '#5ecfb9',
|
7112
|
+
type: 'line',
|
7113
|
+
lineColor: '#5ecfb9',
|
7114
|
+
marker: {
|
7115
|
+
lineColor: '#5ecfb9'
|
7116
|
+
}
|
7117
|
+
},
|
7118
|
+
{
|
7119
|
+
data: [
|
7120
|
+
{
|
7121
|
+
y: 123450,
|
7122
|
+
initialName: 'col 1',
|
7123
|
+
name: 'col 1'
|
7124
|
+
},
|
7125
|
+
{
|
7126
|
+
y: 11111,
|
7127
|
+
initialName: 'col 2',
|
7128
|
+
name: 'col 2'
|
7129
|
+
},
|
7130
|
+
{
|
7131
|
+
y: 99991,
|
7132
|
+
initialName: 'Others',
|
7133
|
+
name: 'Others'
|
7134
|
+
}
|
7135
|
+
],
|
7136
|
+
initialName: 'row 2',
|
7137
|
+
name: 'row 2',
|
7138
|
+
color: '#b3060e'
|
7139
|
+
}
|
7140
|
+
]);
|
7141
|
+
});
|
7142
|
+
|
7143
|
+
it('should prepare appropriate chart series, when additional options have delta column \'only variant\'', ()=> {
|
7144
|
+
additionalOptionsMock = {
|
7145
|
+
delta_column: {
|
7146
|
+
field: 'series',
|
7147
|
+
only_variant: true,
|
7148
|
+
name: 'row 1',
|
7149
|
+
chart: 'line'
|
7150
|
+
}
|
7151
|
+
};
|
7152
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7153
|
+
expect(value).toEqual([{
|
7154
|
+
data: [
|
7155
|
+
{
|
7156
|
+
y: 12345,
|
7157
|
+
initialName: 'col 1',
|
7158
|
+
name: 'col 1'
|
7159
|
+
},
|
7160
|
+
{
|
7161
|
+
y: 54321,
|
7162
|
+
initialName: 'col 2',
|
7163
|
+
name: 'col 2'
|
7164
|
+
},
|
7165
|
+
{
|
7166
|
+
y: 99999,
|
7167
|
+
initialName: 'Others',
|
7168
|
+
name: 'Others'
|
7169
|
+
}
|
7170
|
+
],
|
7171
|
+
initialName: 'row 1',
|
7172
|
+
name: 'row 1',
|
7173
|
+
color: '#5ecfb9',
|
7174
|
+
type: 'line',
|
7175
|
+
lineColor: '#5ecfb9',
|
7176
|
+
marker: {
|
7177
|
+
lineColor: '#5ecfb9'
|
7178
|
+
}
|
7179
|
+
}]);
|
7180
|
+
});
|
7181
|
+
it('should change additional options, when additional options \'chart\' configuration and its option \'showAllLegends\' set to false', ()=> {
|
7182
|
+
additionalOptionsMock = {
|
7183
|
+
chart: {
|
7184
|
+
showAllLegends: false
|
7185
|
+
}
|
7186
|
+
};
|
7187
|
+
highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7188
|
+
expect(additionalOptionsMock.chart.isLimited).toEqual(false);
|
7189
|
+
});
|
7190
|
+
|
7191
|
+
|
7192
|
+
it('should change additional options, when additional options \'chart\' configuration and its option \'showAllLegends\' set to true', ()=> {
|
7193
|
+
additionalOptionsMock = {
|
7194
|
+
chart: {
|
7195
|
+
showAllLegends: true
|
7196
|
+
}
|
7197
|
+
};
|
7198
|
+
highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7199
|
+
expect(additionalOptionsMock.chart.isLimited).toEqual(false);
|
7200
|
+
});
|
7201
|
+
|
7202
|
+
it('should prepare appropriate chart series, when opts \'total\' configuration is set to true', ()=> {
|
7203
|
+
opts = {
|
7204
|
+
total: true
|
7205
|
+
};
|
7206
|
+
pivotDataMock.colTotals = {
|
7207
|
+
'col 1': {value: () => 123450},
|
7208
|
+
'col 2': {value: () => 123451},
|
7209
|
+
'DR_Others': {value: () => 123452},
|
7210
|
+
};
|
7211
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7212
|
+
expect(value).toEqual([
|
7213
|
+
{
|
7214
|
+
data: [
|
7215
|
+
{
|
7216
|
+
y: 12345,
|
7217
|
+
initialName: 'col 1',
|
7218
|
+
name: 'col 1'
|
7219
|
+
},
|
7220
|
+
{
|
7221
|
+
y: 54321,
|
7222
|
+
initialName: 'col 2',
|
7223
|
+
name: 'col 2'
|
7224
|
+
},
|
7225
|
+
{
|
7226
|
+
y: 99999,
|
7227
|
+
initialName: 'Others',
|
7228
|
+
name: 'Others'
|
7229
|
+
}
|
7230
|
+
],
|
7231
|
+
initialName: 'row 1',
|
7232
|
+
name: 'row 1',
|
7233
|
+
color: '#ff0202'
|
7234
|
+
},
|
7235
|
+
{
|
7236
|
+
data: [
|
7237
|
+
{
|
7238
|
+
y: 123450,
|
7239
|
+
initialName: 'col 1',
|
7240
|
+
name: 'col 1'
|
7241
|
+
},
|
7242
|
+
{
|
7243
|
+
y: 11111,
|
7244
|
+
initialName: 'col 2',
|
7245
|
+
name: 'col 2'
|
7246
|
+
},
|
7247
|
+
{
|
7248
|
+
y: 99991,
|
7249
|
+
initialName: 'Others',
|
7250
|
+
name: 'Others'
|
7251
|
+
}
|
7252
|
+
],
|
7253
|
+
initialName: 'row 2',
|
7254
|
+
name: 'row 2',
|
7255
|
+
color: '#b3060e'
|
7256
|
+
},
|
7257
|
+
{
|
7258
|
+
data: [
|
7259
|
+
123450,
|
7260
|
+
123451,
|
7261
|
+
123452
|
7262
|
+
],
|
7263
|
+
initialName: 'row 2',
|
7264
|
+
name: 'Total',
|
7265
|
+
color: '#70000a',
|
7266
|
+
className: 'totalSeries'
|
7267
|
+
}
|
7268
|
+
]);
|
7269
|
+
});
|
7270
|
+
|
7271
|
+
it('should prepare appropriate chart series, when opts \'trendLine\' configuration is set to true', ()=> {
|
7272
|
+
opts = {
|
7273
|
+
trendLine: true
|
7274
|
+
};
|
7275
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7276
|
+
expect(value).toEqual([
|
7277
|
+
{
|
7278
|
+
data: [
|
7279
|
+
{
|
7280
|
+
y: 12345,
|
7281
|
+
initialName: 'col 1',
|
7282
|
+
name: 'col 1'
|
7283
|
+
},
|
7284
|
+
{
|
7285
|
+
y: 54321,
|
7286
|
+
initialName: 'col 2',
|
7287
|
+
name: 'col 2'
|
7288
|
+
},
|
7289
|
+
{
|
7290
|
+
y: 99999,
|
7291
|
+
initialName: 'Others',
|
7292
|
+
name: 'Others'
|
7293
|
+
}
|
7294
|
+
],
|
7295
|
+
initialName: 'row 1',
|
7296
|
+
name: 'row 1',
|
7297
|
+
color: '#ff0202'
|
7298
|
+
},
|
7299
|
+
{
|
7300
|
+
data: [
|
7301
|
+
{
|
7302
|
+
y: 123450,
|
7303
|
+
initialName: 'col 1',
|
7304
|
+
name: 'col 1'
|
7305
|
+
},
|
7306
|
+
{
|
7307
|
+
y: 11111,
|
7308
|
+
initialName: 'col 2',
|
7309
|
+
name: 'col 2'
|
7310
|
+
},
|
7311
|
+
{
|
7312
|
+
y: 99991,
|
7313
|
+
initialName: 'Others',
|
7314
|
+
name: 'Others'
|
7315
|
+
}
|
7316
|
+
],
|
7317
|
+
initialName: 'row 2',
|
7318
|
+
name: 'row 2',
|
7319
|
+
color: '#b3060e'
|
7320
|
+
},
|
7321
|
+
{
|
7322
|
+
data: [
|
7323
|
+
11728,
|
7324
|
+
55555,
|
7325
|
+
99382
|
7326
|
+
],
|
7327
|
+
initialName: 'row 1',
|
7328
|
+
name: 'Trend Line (row 1)',
|
7329
|
+
color: '#ff0202',
|
7330
|
+
className: 'trendSeries',
|
7331
|
+
dashStyle: 'shortdot',
|
7332
|
+
type: 'line'
|
7333
|
+
},
|
7334
|
+
{
|
7335
|
+
data: [
|
7336
|
+
89913.5,
|
7337
|
+
78184,
|
7338
|
+
66454.5
|
7339
|
+
],
|
7340
|
+
initialName: 'row 2',
|
7341
|
+
name: 'Trend Line (row 2)',
|
7342
|
+
color: '#b3060e',
|
7343
|
+
className: 'trendSeries',
|
7344
|
+
dashStyle: 'shortdot',
|
7345
|
+
type: 'line'
|
7346
|
+
}
|
7347
|
+
]);
|
7348
|
+
});
|
7349
|
+
|
7350
|
+
it('should prepare appropriate chart series for standard input', () => {
|
7351
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7352
|
+
expect(value).toEqual([
|
7353
|
+
{
|
7354
|
+
data: [
|
7355
|
+
{
|
7356
|
+
y: 12345,
|
7357
|
+
initialName: 'col 1',
|
7358
|
+
name: 'col 1'
|
7359
|
+
},
|
7360
|
+
{
|
7361
|
+
y: 54321,
|
7362
|
+
initialName: 'col 2',
|
7363
|
+
name: 'col 2'
|
7364
|
+
},
|
7365
|
+
{
|
7366
|
+
y: 99999,
|
7367
|
+
initialName: 'Others',
|
7368
|
+
name: 'Others'
|
7369
|
+
}
|
7370
|
+
],
|
7371
|
+
initialName: 'row 1',
|
7372
|
+
name: 'row 1',
|
7373
|
+
color: '#ff0202'
|
7374
|
+
},
|
7375
|
+
{
|
7376
|
+
data: [
|
7377
|
+
{
|
7378
|
+
y: 123450,
|
7379
|
+
initialName: 'col 1',
|
7380
|
+
name: 'col 1'
|
7381
|
+
},
|
7382
|
+
{
|
7383
|
+
y: 11111,
|
7384
|
+
initialName: 'col 2',
|
7385
|
+
name: 'col 2'
|
7386
|
+
},
|
7387
|
+
{
|
7388
|
+
y: 99991,
|
7389
|
+
initialName: 'Others',
|
7390
|
+
name: 'Others'
|
7391
|
+
}
|
7392
|
+
],
|
7393
|
+
initialName: 'row 2',
|
7394
|
+
name: 'row 2',
|
7395
|
+
color: '#b3060e'
|
7396
|
+
}
|
7397
|
+
]);
|
7398
|
+
})
|
7399
|
+
});
|
6423
7400
|
});
|