@datarailsshared/dr_renderer 1.2.397 → 1.2.398

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.2.397",
3
+ "version": "1.2.398",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -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,622 @@ 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
+ });
6423
7041
  });