@datarailsshared/dr_renderer 1.2.406 → 1.2.408
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
@@ -1135,8 +1135,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1135
1135
|
has_delta = true;
|
1136
1136
|
}
|
1137
1137
|
|
1138
|
-
|
1139
|
-
|
1138
|
+
lodash.forEach([col_n_keys, row_n_keys], keysArray => {
|
1139
|
+
if (keysArray && !keysArray.length) {
|
1140
|
+
keysArray.push([]);
|
1141
|
+
}
|
1142
|
+
});
|
1140
1143
|
|
1141
1144
|
var i = 0;
|
1142
1145
|
var variat_serias = null;
|
@@ -2422,10 +2425,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2422
2425
|
}
|
2423
2426
|
var uniqueVals = kpioptions.value.value == "Unique";
|
2424
2427
|
|
2425
|
-
if (!pivotData.colKeys.length) {
|
2426
|
-
pivotData.colKeys.push([]);
|
2427
|
-
}
|
2428
|
-
|
2429
2428
|
let temp_series = highchartsRenderer.ptCreateBasicLineSeries(pivotData, null, true, uniqueVals, null, opts, chartOptions);
|
2430
2429
|
|
2431
2430
|
var total = [];
|
@@ -7450,5 +7450,742 @@ describe('highcharts_renderer', () => {
|
|
7450
7450
|
expect(placeholder.querySelector(textSelector).innerHTML).toEqual(value.text);
|
7451
7451
|
});
|
7452
7452
|
});
|
7453
|
-
})
|
7453
|
+
});
|
7454
|
+
|
7455
|
+
describe("Function ptCreateWaterfallWalkthroughSeries", () => {
|
7456
|
+
const format = null;
|
7457
|
+
const additionalOptionsMock = { testOption: 'test additional option 1' }
|
7458
|
+
|
7459
|
+
const commonPivotDataMockProps = {
|
7460
|
+
colFormats: 'mock_formats',
|
7461
|
+
colAttrs: ['Test Number Field'],
|
7462
|
+
allTotal: {
|
7463
|
+
uniq: 1
|
7464
|
+
}
|
7465
|
+
};
|
7466
|
+
|
7467
|
+
const pivotDataMockForOneFieldAndOneTotal = {
|
7468
|
+
getAggregator: (rows, cols) => {
|
7469
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
7470
|
+
const agg = aggregator({}, '', '');
|
7471
|
+
|
7472
|
+
if (lodash.isEqual(cols, [1]) && lodash.isEqual(rows, [])) {
|
7473
|
+
agg.sum = 100;
|
7474
|
+
} else if (lodash.isEqual(cols, [2]) && lodash.isEqual(rows, [])) {
|
7475
|
+
agg.sum = 50;
|
7476
|
+
} else if (lodash.isEqual(cols, [3]) && lodash.isEqual(rows, [])) {
|
7477
|
+
agg.sum = 40;
|
7478
|
+
} else if (lodash.isEqual(cols, ['Total']) && lodash.isEqual(rows, [])) {
|
7479
|
+
agg.sum = 110;
|
7480
|
+
}
|
7481
|
+
|
7482
|
+
return agg;
|
7483
|
+
},
|
7484
|
+
...commonPivotDataMockProps,
|
7485
|
+
};
|
7486
|
+
|
7487
|
+
const pivotDataMockForTwoFieldsAndOneTotal = {
|
7488
|
+
getAggregator: (rows, cols) => {
|
7489
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
7490
|
+
const agg = aggregator({}, '', '');
|
7491
|
+
|
7492
|
+
if (lodash.isEqual(cols, [1, 1707389300]) && lodash.isEqual(rows, [])) {
|
7493
|
+
agg.sum = 100;
|
7494
|
+
} else if (lodash.isEqual(cols, [2, 1707389400]) && lodash.isEqual(rows, [])) {
|
7495
|
+
agg.sum = 50;
|
7496
|
+
} else if (lodash.isEqual(cols, [2, 1707389500]) && lodash.isEqual(rows, [])) {
|
7497
|
+
agg.sum = 40;
|
7498
|
+
} else if (lodash.isEqual(cols, ['Total']) && lodash.isEqual(rows, [])) {
|
7499
|
+
agg.sum = 110;
|
7500
|
+
}
|
7501
|
+
|
7502
|
+
return agg;
|
7503
|
+
},
|
7504
|
+
...commonPivotDataMockProps,
|
7505
|
+
};
|
7506
|
+
|
7507
|
+
const pivotDataMockForTwoFieldsAndNoTotals = {
|
7508
|
+
getAggregator: (rows, cols) => {
|
7509
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
7510
|
+
const agg = aggregator({}, '', '');
|
7511
|
+
|
7512
|
+
if (lodash.isEqual(cols, [1, 1707389300]) && lodash.isEqual(rows, [])) {
|
7513
|
+
agg.sum = 100;
|
7514
|
+
} else if (lodash.isEqual(cols, [2, 1707389400]) && lodash.isEqual(rows, [])) {
|
7515
|
+
agg.sum = 50;
|
7516
|
+
} else if (lodash.isEqual(cols, [2, 1707389500]) && lodash.isEqual(rows, [])) {
|
7517
|
+
agg.sum = 40;
|
7518
|
+
}
|
7519
|
+
|
7520
|
+
return agg;
|
7521
|
+
},
|
7522
|
+
...commonPivotDataMockProps,
|
7523
|
+
};
|
7524
|
+
|
7525
|
+
const pivotDataMockForTwoFieldsAndTwoTotals = {
|
7526
|
+
getAggregator: (rows, cols) => {
|
7527
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
7528
|
+
const agg = aggregator({}, '', '');
|
7529
|
+
|
7530
|
+
if (lodash.isEqual(cols, [1, 1707389300]) && lodash.isEqual(rows, [])) {
|
7531
|
+
agg.sum = 100;
|
7532
|
+
} else if (lodash.isEqual(cols, [2, 1707389400]) && lodash.isEqual(rows, [])) {
|
7533
|
+
agg.sum = 50;
|
7534
|
+
} else if (lodash.isEqual(cols, ['Total 1']) && lodash.isEqual(rows, [])) {
|
7535
|
+
agg.sum = 150;
|
7536
|
+
} else if (lodash.isEqual(cols, [2, 1707389500]) && lodash.isEqual(rows, [])) {
|
7537
|
+
agg.sum = 40;
|
7538
|
+
} else if (lodash.isEqual(cols, ['Total 2']) && lodash.isEqual(rows, [])) {
|
7539
|
+
agg.sum = 110;
|
7540
|
+
}
|
7541
|
+
|
7542
|
+
return agg;
|
7543
|
+
},
|
7544
|
+
...commonPivotDataMockProps,
|
7545
|
+
};
|
7546
|
+
|
7547
|
+
const pivotDataMockWithZeroValue = {
|
7548
|
+
getAggregator: (rows, cols) => {
|
7549
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
7550
|
+
const agg = aggregator({}, '', '');
|
7551
|
+
|
7552
|
+
if (lodash.isEqual(cols, [1]) && lodash.isEqual(rows, [])) {
|
7553
|
+
agg.sum = 100;
|
7554
|
+
} else if (lodash.isEqual(cols, [2]) && lodash.isEqual(rows, [])) {
|
7555
|
+
agg.sum = 0;
|
7556
|
+
} else if (lodash.isEqual(cols, [3]) && lodash.isEqual(rows, [])) {
|
7557
|
+
agg.sum = 40;
|
7558
|
+
} else if (lodash.isEqual(cols, ['Total']) && lodash.isEqual(rows, [])) {
|
7559
|
+
agg.sum = 60;
|
7560
|
+
}
|
7561
|
+
|
7562
|
+
return agg;
|
7563
|
+
},
|
7564
|
+
...commonPivotDataMockProps,
|
7565
|
+
};
|
7566
|
+
|
7567
|
+
beforeEach(() => {
|
7568
|
+
spyOn(highchartsRenderer, "defaultDataLabelFormatter").and.returnValue("mock formatter function");
|
7569
|
+
spyOn(highchartsRenderer, "getDataLabelsStyle").and.returnValue({ height: '100px' });
|
7570
|
+
spyOn(highchartsRenderer, "getOthersName").and.returnValue({ height: 'Test Others Name' });
|
7571
|
+
spyOn(highchartsRenderer, 'getDataLabelsOptions').and.callFake((additionOptions, resultObject) => {
|
7572
|
+
resultObject.dataLabels.additionalTestProp = 'test_value';
|
7573
|
+
return resultObject;
|
7574
|
+
});
|
7575
|
+
spyOn(highchartsRenderer, 'getFormattedColKey')
|
7576
|
+
.and.callFake((initialName, pivotData) => `formatted(${ initialName })`);
|
7577
|
+
spyOn(highchartsRenderer, 'isFormattingDatesAsOtherAxisTypes').and.returnValue(true);
|
7578
|
+
});
|
7579
|
+
|
7580
|
+
it("should create appropriate series for case when only one column field and one total", () => {
|
7581
|
+
const pivotDataMock = lodash.cloneDeep(pivotDataMockForOneFieldAndOneTotal);
|
7582
|
+
|
7583
|
+
const optsMock = {
|
7584
|
+
walkthrough_options: {
|
7585
|
+
values: {
|
7586
|
+
walkthrough: [
|
7587
|
+
{ key: [1], color: null, format: null, trend: "increase" },
|
7588
|
+
{ key: [2], color: null, format: null, trend: "increase" },
|
7589
|
+
{ key: [3], color: null, format: null, trend: "decrease" },
|
7590
|
+
{ key: ["Total"], color: null, format: null, trend: "total" },
|
7591
|
+
],
|
7592
|
+
},
|
7593
|
+
colors: {
|
7594
|
+
increase: 'green',
|
7595
|
+
decrease: 'red',
|
7596
|
+
total: 'blue',
|
7597
|
+
},
|
7598
|
+
}
|
7599
|
+
}
|
7600
|
+
|
7601
|
+
const series = highchartsRenderer.ptCreateWaterfallWalkthroughSeries(pivotDataMock, false, additionalOptionsMock, optsMock);
|
7602
|
+
expect(series).toEqual([
|
7603
|
+
{
|
7604
|
+
className: "waterfallWalkthrough",
|
7605
|
+
color: "red",
|
7606
|
+
data: [
|
7607
|
+
{
|
7608
|
+
color: "green",
|
7609
|
+
colsForTotal: null,
|
7610
|
+
initialName: "1",
|
7611
|
+
isSum: false,
|
7612
|
+
isTotal: false,
|
7613
|
+
name: "formatted(1)",
|
7614
|
+
totalIndex: undefined,
|
7615
|
+
y: 100
|
7616
|
+
},
|
7617
|
+
{
|
7618
|
+
color: "green",
|
7619
|
+
colsForTotal: null,
|
7620
|
+
initialName: "2",
|
7621
|
+
isSum: false,
|
7622
|
+
isTotal: false,
|
7623
|
+
name: "formatted(2)",
|
7624
|
+
totalIndex: undefined,
|
7625
|
+
y: 50
|
7626
|
+
},
|
7627
|
+
{
|
7628
|
+
color: "red",
|
7629
|
+
colsForTotal: null,
|
7630
|
+
initialName: "3",
|
7631
|
+
isSum: false,
|
7632
|
+
isTotal: false,
|
7633
|
+
name: "formatted(3)",
|
7634
|
+
totalIndex: undefined,
|
7635
|
+
y: -40
|
7636
|
+
},
|
7637
|
+
{
|
7638
|
+
color: "blue",
|
7639
|
+
colsForTotal: ["Total",],
|
7640
|
+
initialName: "Total",
|
7641
|
+
isSum: true,
|
7642
|
+
isTotal: true,
|
7643
|
+
name: "Total",
|
7644
|
+
totalIndex: 3,
|
7645
|
+
y: 110,
|
7646
|
+
}
|
7647
|
+
],
|
7648
|
+
dataLabels: {
|
7649
|
+
additionalTestProp: "test_value",
|
7650
|
+
allowOverlap: false,
|
7651
|
+
enabled: true,
|
7652
|
+
formatter: "mock formatter function",
|
7653
|
+
style: {"height": "100px"}
|
7654
|
+
},
|
7655
|
+
upColor: "green"
|
7656
|
+
},
|
7657
|
+
{
|
7658
|
+
color: "green",
|
7659
|
+
name: "Positive",
|
7660
|
+
visible: false
|
7661
|
+
},
|
7662
|
+
{
|
7663
|
+
color: "red",
|
7664
|
+
name: "Negative",
|
7665
|
+
visible: false
|
7666
|
+
}
|
7667
|
+
]);
|
7668
|
+
});
|
7669
|
+
|
7670
|
+
it("should create appropriate series - skip zero value", () => {
|
7671
|
+
const pivotDataMock = lodash.cloneDeep(pivotDataMockWithZeroValue);
|
7672
|
+
|
7673
|
+
const optsMock = {
|
7674
|
+
walkthrough_options: {
|
7675
|
+
values: {
|
7676
|
+
walkthrough: [
|
7677
|
+
{ key: [1], color: null, format: null, trend: "increase" },
|
7678
|
+
{ key: [2], color: null, format: null, trend: "increase" },
|
7679
|
+
{ key: [3], color: null, format: null, trend: "decrease" },
|
7680
|
+
{ key: ["Total"], color: null, format: null, trend: "total" },
|
7681
|
+
],
|
7682
|
+
},
|
7683
|
+
colors: {
|
7684
|
+
increase: 'green',
|
7685
|
+
decrease: 'red',
|
7686
|
+
total: 'blue',
|
7687
|
+
},
|
7688
|
+
}
|
7689
|
+
}
|
7690
|
+
|
7691
|
+
const series = highchartsRenderer.ptCreateWaterfallWalkthroughSeries(pivotDataMock, false, additionalOptionsMock, optsMock);
|
7692
|
+
expect(series).toEqual([
|
7693
|
+
{
|
7694
|
+
className: "waterfallWalkthrough",
|
7695
|
+
color: "red",
|
7696
|
+
data: [
|
7697
|
+
{
|
7698
|
+
color: "green",
|
7699
|
+
colsForTotal: null,
|
7700
|
+
initialName: "1",
|
7701
|
+
isSum: false,
|
7702
|
+
isTotal: false,
|
7703
|
+
name: "formatted(1)",
|
7704
|
+
totalIndex: undefined,
|
7705
|
+
y: 100
|
7706
|
+
},
|
7707
|
+
{
|
7708
|
+
color: "red",
|
7709
|
+
colsForTotal: null,
|
7710
|
+
initialName: "3",
|
7711
|
+
isSum: false,
|
7712
|
+
isTotal: false,
|
7713
|
+
name: "formatted(3)",
|
7714
|
+
totalIndex: undefined,
|
7715
|
+
y: -40
|
7716
|
+
},
|
7717
|
+
{
|
7718
|
+
color: "blue",
|
7719
|
+
colsForTotal: ["Total",],
|
7720
|
+
initialName: "Total",
|
7721
|
+
isSum: true,
|
7722
|
+
isTotal: true,
|
7723
|
+
name: "Total",
|
7724
|
+
totalIndex: 3,
|
7725
|
+
y: 60,
|
7726
|
+
}
|
7727
|
+
],
|
7728
|
+
dataLabels: {
|
7729
|
+
additionalTestProp: "test_value",
|
7730
|
+
allowOverlap: false,
|
7731
|
+
enabled: true,
|
7732
|
+
formatter: "mock formatter function",
|
7733
|
+
style: {"height": "100px"}
|
7734
|
+
},
|
7735
|
+
upColor: "green"
|
7736
|
+
},
|
7737
|
+
{
|
7738
|
+
color: "green",
|
7739
|
+
name: "Positive",
|
7740
|
+
visible: false
|
7741
|
+
},
|
7742
|
+
{
|
7743
|
+
color: "red",
|
7744
|
+
name: "Negative",
|
7745
|
+
visible: false
|
7746
|
+
}
|
7747
|
+
]);
|
7748
|
+
});
|
7749
|
+
|
7750
|
+
it("should create appropriate series for case when two column fields and one total", () => {
|
7751
|
+
const pivotDataMock = lodash.cloneDeep(pivotDataMockForTwoFieldsAndOneTotal);
|
7752
|
+
const optsMock = {
|
7753
|
+
walkthrough_options: {
|
7754
|
+
values: {
|
7755
|
+
walkthrough: [
|
7756
|
+
{ key: [1, 1707389300], color: null, format: null, trend: "increase" },
|
7757
|
+
{ key: [2, 1707389400], color: null, format: null, trend: "increase" },
|
7758
|
+
{ key: [2, 1707389500], color: null, format: null, trend: "decrease" },
|
7759
|
+
{ key: ["Total"], color: null, format: null, trend: "total" },
|
7760
|
+
],
|
7761
|
+
},
|
7762
|
+
colors: {
|
7763
|
+
increase: 'green',
|
7764
|
+
decrease: 'red',
|
7765
|
+
total: 'blue',
|
7766
|
+
},
|
7767
|
+
}
|
7768
|
+
}
|
7769
|
+
|
7770
|
+
const series = highchartsRenderer.ptCreateWaterfallWalkthroughSeries(pivotDataMock, false, additionalOptionsMock, optsMock);
|
7771
|
+
expect(series).toEqual([
|
7772
|
+
{
|
7773
|
+
className: "waterfallWalkthrough",
|
7774
|
+
color: "red",
|
7775
|
+
data: [
|
7776
|
+
{
|
7777
|
+
color: "green",
|
7778
|
+
colsForTotal: null,
|
7779
|
+
initialName: "1 , 1707389300",
|
7780
|
+
isSum: false,
|
7781
|
+
isTotal: false,
|
7782
|
+
name: "formatted(1 , 1707389300)",
|
7783
|
+
totalIndex: undefined,
|
7784
|
+
y: 100
|
7785
|
+
},
|
7786
|
+
{
|
7787
|
+
color: "green",
|
7788
|
+
colsForTotal: null,
|
7789
|
+
initialName: "2 , 1707389400",
|
7790
|
+
isSum: false,
|
7791
|
+
isTotal: false,
|
7792
|
+
name: "formatted(2 , 1707389400)",
|
7793
|
+
totalIndex: undefined,
|
7794
|
+
y: 50
|
7795
|
+
},
|
7796
|
+
{
|
7797
|
+
color: "red",
|
7798
|
+
colsForTotal: null,
|
7799
|
+
initialName: "2 , 1707389500",
|
7800
|
+
isSum: false,
|
7801
|
+
isTotal: false,
|
7802
|
+
name: "formatted(2 , 1707389500)",
|
7803
|
+
totalIndex: undefined,
|
7804
|
+
y: -40
|
7805
|
+
},
|
7806
|
+
{
|
7807
|
+
color: "blue",
|
7808
|
+
colsForTotal: ["Total",],
|
7809
|
+
initialName: "Total",
|
7810
|
+
isSum: true,
|
7811
|
+
isTotal: true,
|
7812
|
+
name: "Total",
|
7813
|
+
totalIndex: 3,
|
7814
|
+
y: 110,
|
7815
|
+
}
|
7816
|
+
],
|
7817
|
+
dataLabels: {
|
7818
|
+
additionalTestProp: "test_value",
|
7819
|
+
allowOverlap: false,
|
7820
|
+
enabled: true,
|
7821
|
+
formatter: "mock formatter function",
|
7822
|
+
style: {"height": "100px"}
|
7823
|
+
},
|
7824
|
+
upColor: "green"
|
7825
|
+
},
|
7826
|
+
{
|
7827
|
+
color: "green",
|
7828
|
+
name: "Positive",
|
7829
|
+
visible: false
|
7830
|
+
},
|
7831
|
+
{
|
7832
|
+
color: "red",
|
7833
|
+
name: "Negative",
|
7834
|
+
visible: false
|
7835
|
+
}
|
7836
|
+
]);
|
7837
|
+
});
|
7838
|
+
|
7839
|
+
it("should create appropriate series - no totals", () => {
|
7840
|
+
const pivotDataMock = lodash.cloneDeep(pivotDataMockForTwoFieldsAndNoTotals);
|
7841
|
+
|
7842
|
+
const optsMock = {
|
7843
|
+
walkthrough_options: {
|
7844
|
+
values: {
|
7845
|
+
walkthrough: [
|
7846
|
+
{ key: [1, 1707389300], color: null, format: null, trend: "increase" },
|
7847
|
+
{ key: [2, 1707389400], color: null, format: null, trend: "increase" },
|
7848
|
+
{ key: [2, 1707389500], color: null, format: null, trend: "decrease" },
|
7849
|
+
],
|
7850
|
+
},
|
7851
|
+
colors: {
|
7852
|
+
increase: 'green',
|
7853
|
+
decrease: 'red',
|
7854
|
+
total: 'blue',
|
7855
|
+
},
|
7856
|
+
}
|
7857
|
+
}
|
7858
|
+
|
7859
|
+
const series = highchartsRenderer.ptCreateWaterfallWalkthroughSeries(pivotDataMock, false, additionalOptionsMock, optsMock);
|
7860
|
+
expect(series).toEqual([
|
7861
|
+
{
|
7862
|
+
className: "waterfallWalkthrough",
|
7863
|
+
color: "red",
|
7864
|
+
data: [
|
7865
|
+
{
|
7866
|
+
color: "green",
|
7867
|
+
colsForTotal: null,
|
7868
|
+
initialName: "1 , 1707389300",
|
7869
|
+
isSum: false,
|
7870
|
+
isTotal: false,
|
7871
|
+
name: "formatted(1 , 1707389300)",
|
7872
|
+
totalIndex: undefined,
|
7873
|
+
y: 100
|
7874
|
+
},
|
7875
|
+
{
|
7876
|
+
color: "green",
|
7877
|
+
colsForTotal: null,
|
7878
|
+
initialName: "2 , 1707389400",
|
7879
|
+
isSum: false,
|
7880
|
+
isTotal: false,
|
7881
|
+
name: "formatted(2 , 1707389400)",
|
7882
|
+
totalIndex: undefined,
|
7883
|
+
y: 50
|
7884
|
+
},
|
7885
|
+
{
|
7886
|
+
color: "red",
|
7887
|
+
colsForTotal: null,
|
7888
|
+
initialName: "2 , 1707389500",
|
7889
|
+
isSum: false,
|
7890
|
+
isTotal: false,
|
7891
|
+
name: "formatted(2 , 1707389500)",
|
7892
|
+
totalIndex: undefined,
|
7893
|
+
y: -40
|
7894
|
+
},
|
7895
|
+
],
|
7896
|
+
dataLabels: {
|
7897
|
+
additionalTestProp: "test_value",
|
7898
|
+
allowOverlap: false,
|
7899
|
+
enabled: true,
|
7900
|
+
formatter: "mock formatter function",
|
7901
|
+
style: {"height": "100px"}
|
7902
|
+
},
|
7903
|
+
upColor: "green"
|
7904
|
+
},
|
7905
|
+
{
|
7906
|
+
color: "green",
|
7907
|
+
name: "Positive",
|
7908
|
+
visible: false
|
7909
|
+
},
|
7910
|
+
{
|
7911
|
+
color: "red",
|
7912
|
+
name: "Negative",
|
7913
|
+
visible: false
|
7914
|
+
}
|
7915
|
+
]);
|
7916
|
+
});
|
7917
|
+
|
7918
|
+
it("should create appropriate series - two totals", () => {
|
7919
|
+
const pivotDataMock = lodash.cloneDeep(pivotDataMockForTwoFieldsAndTwoTotals);
|
7920
|
+
|
7921
|
+
const optsMock = {
|
7922
|
+
walkthrough_options: {
|
7923
|
+
values: {
|
7924
|
+
walkthrough: [
|
7925
|
+
{ key: [1, 1707389300], color: null, format: null, trend: "increase" },
|
7926
|
+
{ key: [2, 1707389400], color: null, format: null, trend: "increase" },
|
7927
|
+
{ key: ["Total 1"], color: null, format: null, trend: "total" },
|
7928
|
+
{ key: [2, 1707389500], color: null, format: null, trend: "decrease" },
|
7929
|
+
{ key: ["Total 2"], color: null, format: null, trend: "total" },
|
7930
|
+
],
|
7931
|
+
},
|
7932
|
+
colors: {
|
7933
|
+
increase: 'green',
|
7934
|
+
decrease: 'red',
|
7935
|
+
total: 'blue',
|
7936
|
+
},
|
7937
|
+
}
|
7938
|
+
}
|
7939
|
+
|
7940
|
+
const series = highchartsRenderer.ptCreateWaterfallWalkthroughSeries(pivotDataMock, false, additionalOptionsMock, optsMock);
|
7941
|
+
expect(series).toEqual([
|
7942
|
+
{
|
7943
|
+
className: "waterfallWalkthrough",
|
7944
|
+
color: "red",
|
7945
|
+
data: [
|
7946
|
+
{
|
7947
|
+
color: "green",
|
7948
|
+
colsForTotal: null,
|
7949
|
+
initialName: "1 , 1707389300",
|
7950
|
+
isSum: false,
|
7951
|
+
isTotal: false,
|
7952
|
+
name: "formatted(1 , 1707389300)",
|
7953
|
+
totalIndex: undefined,
|
7954
|
+
y: 100
|
7955
|
+
},
|
7956
|
+
{
|
7957
|
+
color: "green",
|
7958
|
+
colsForTotal: null,
|
7959
|
+
initialName: "2 , 1707389400",
|
7960
|
+
isSum: false,
|
7961
|
+
isTotal: false,
|
7962
|
+
name: "formatted(2 , 1707389400)",
|
7963
|
+
totalIndex: undefined,
|
7964
|
+
y: 50
|
7965
|
+
},
|
7966
|
+
{
|
7967
|
+
color: "blue",
|
7968
|
+
colsForTotal: ["Total 1",],
|
7969
|
+
initialName: "Total 1",
|
7970
|
+
isSum: true,
|
7971
|
+
isTotal: true,
|
7972
|
+
name: "Total 1",
|
7973
|
+
totalIndex: 2,
|
7974
|
+
y: 150,
|
7975
|
+
},
|
7976
|
+
{
|
7977
|
+
color: "red",
|
7978
|
+
colsForTotal: null,
|
7979
|
+
initialName: "2 , 1707389500",
|
7980
|
+
isSum: false,
|
7981
|
+
isTotal: false,
|
7982
|
+
name: "formatted(2 , 1707389500)",
|
7983
|
+
totalIndex: undefined,
|
7984
|
+
y: -40
|
7985
|
+
},
|
7986
|
+
{
|
7987
|
+
color: "blue",
|
7988
|
+
colsForTotal: ["Total 2",],
|
7989
|
+
initialName: "Total 2",
|
7990
|
+
isSum: true,
|
7991
|
+
isTotal: true,
|
7992
|
+
name: "Total 2",
|
7993
|
+
totalIndex: 4,
|
7994
|
+
y: 110,
|
7995
|
+
}
|
7996
|
+
],
|
7997
|
+
dataLabels: {
|
7998
|
+
additionalTestProp: "test_value",
|
7999
|
+
allowOverlap: false,
|
8000
|
+
enabled: true,
|
8001
|
+
formatter: "mock formatter function",
|
8002
|
+
style: {"height": "100px"}
|
8003
|
+
},
|
8004
|
+
upColor: "green"
|
8005
|
+
},
|
8006
|
+
{
|
8007
|
+
color: "green",
|
8008
|
+
name: "Positive",
|
8009
|
+
visible: false
|
8010
|
+
},
|
8011
|
+
{
|
8012
|
+
color: "red",
|
8013
|
+
name: "Negative",
|
8014
|
+
visible: false
|
8015
|
+
}
|
8016
|
+
]);
|
8017
|
+
});
|
8018
|
+
|
8019
|
+
it("should use colors from walkthrough_options values (when it is set and common colors not passed)", () => {
|
8020
|
+
const pivotDataMock = lodash.cloneDeep(pivotDataMockForTwoFieldsAndOneTotal);
|
8021
|
+
|
8022
|
+
const optsMock = {
|
8023
|
+
walkthrough_options: {
|
8024
|
+
values: {
|
8025
|
+
walkthrough: [
|
8026
|
+
{ key: [1, 1707389300], color: 'orange', format: null, trend: "increase" },
|
8027
|
+
{ key: [2, 1707389400], color: 'purple', format: null, trend: "increase" },
|
8028
|
+
{ key: [2, 1707389500], color: 'magenta', format: null, trend: "decrease" },
|
8029
|
+
{ key: ["Total"], color: 'lavander', format: null, trend: "total" },
|
8030
|
+
],
|
8031
|
+
},
|
8032
|
+
colors: null,
|
8033
|
+
}
|
8034
|
+
}
|
8035
|
+
|
8036
|
+
const series = highchartsRenderer.ptCreateWaterfallWalkthroughSeries(pivotDataMock, false, additionalOptionsMock, optsMock);
|
8037
|
+
expect(series).toEqual([
|
8038
|
+
{
|
8039
|
+
className: "waterfallWalkthrough",
|
8040
|
+
color: undefined,
|
8041
|
+
data: [
|
8042
|
+
{
|
8043
|
+
color: "orange",
|
8044
|
+
colsForTotal: null,
|
8045
|
+
initialName: "1 , 1707389300",
|
8046
|
+
isSum: false,
|
8047
|
+
isTotal: false,
|
8048
|
+
name: "formatted(1 , 1707389300)",
|
8049
|
+
totalIndex: undefined,
|
8050
|
+
y: 100
|
8051
|
+
},
|
8052
|
+
{
|
8053
|
+
color: "purple",
|
8054
|
+
colsForTotal: null,
|
8055
|
+
initialName: "2 , 1707389400",
|
8056
|
+
isSum: false,
|
8057
|
+
isTotal: false,
|
8058
|
+
name: "formatted(2 , 1707389400)",
|
8059
|
+
totalIndex: undefined,
|
8060
|
+
y: 50
|
8061
|
+
},
|
8062
|
+
{
|
8063
|
+
color: "magenta",
|
8064
|
+
colsForTotal: null,
|
8065
|
+
initialName: "2 , 1707389500",
|
8066
|
+
isSum: false,
|
8067
|
+
isTotal: false,
|
8068
|
+
name: "formatted(2 , 1707389500)",
|
8069
|
+
totalIndex: undefined,
|
8070
|
+
y: -40
|
8071
|
+
},
|
8072
|
+
{
|
8073
|
+
color: "lavander",
|
8074
|
+
colsForTotal: ["Total",],
|
8075
|
+
initialName: "Total",
|
8076
|
+
isSum: true,
|
8077
|
+
isTotal: true,
|
8078
|
+
name: "Total",
|
8079
|
+
totalIndex: 3,
|
8080
|
+
y: 110,
|
8081
|
+
}
|
8082
|
+
],
|
8083
|
+
dataLabels: {
|
8084
|
+
additionalTestProp: "test_value",
|
8085
|
+
allowOverlap: false,
|
8086
|
+
enabled: true,
|
8087
|
+
formatter: "mock formatter function",
|
8088
|
+
style: {"height": "100px"}
|
8089
|
+
},
|
8090
|
+
upColor: undefined
|
8091
|
+
},
|
8092
|
+
{
|
8093
|
+
color: undefined,
|
8094
|
+
name: "Positive",
|
8095
|
+
visible: false
|
8096
|
+
},
|
8097
|
+
{
|
8098
|
+
color: undefined,
|
8099
|
+
name: "Negative",
|
8100
|
+
visible: false
|
8101
|
+
}
|
8102
|
+
]);
|
8103
|
+
});
|
8104
|
+
|
8105
|
+
it("should use default colors (when no colors info in walkthrough_options)", () => {
|
8106
|
+
const pivotDataMock = lodash.cloneDeep(pivotDataMockForTwoFieldsAndOneTotal);
|
8107
|
+
|
8108
|
+
const optsMock = {
|
8109
|
+
walkthrough_options: {
|
8110
|
+
values: {
|
8111
|
+
walkthrough: [
|
8112
|
+
{ key: [1, 1707389300], color: null, format: null, trend: "increase" },
|
8113
|
+
{ key: [2, 1707389400], color: null, format: null, trend: "increase" },
|
8114
|
+
{ key: [2, 1707389500], color: null, format: null, trend: "decrease" },
|
8115
|
+
{ key: ["Total"], color: null, format: null, trend: "total" },
|
8116
|
+
],
|
8117
|
+
},
|
8118
|
+
colors: {},
|
8119
|
+
}
|
8120
|
+
}
|
8121
|
+
|
8122
|
+
const series = highchartsRenderer.ptCreateWaterfallWalkthroughSeries(pivotDataMock, false, additionalOptionsMock, optsMock);
|
8123
|
+
expect(series).toEqual([
|
8124
|
+
{
|
8125
|
+
className: "waterfallWalkthrough",
|
8126
|
+
color: undefined,
|
8127
|
+
data: [
|
8128
|
+
{
|
8129
|
+
color: "#20A452",
|
8130
|
+
colsForTotal: null,
|
8131
|
+
initialName: "1 , 1707389300",
|
8132
|
+
isSum: false,
|
8133
|
+
isTotal: false,
|
8134
|
+
name: "formatted(1 , 1707389300)",
|
8135
|
+
totalIndex: undefined,
|
8136
|
+
y: 100
|
8137
|
+
},
|
8138
|
+
{
|
8139
|
+
color: "#20A452",
|
8140
|
+
colsForTotal: null,
|
8141
|
+
initialName: "2 , 1707389400",
|
8142
|
+
isSum: false,
|
8143
|
+
isTotal: false,
|
8144
|
+
name: "formatted(2 , 1707389400)",
|
8145
|
+
totalIndex: undefined,
|
8146
|
+
y: 50
|
8147
|
+
},
|
8148
|
+
{
|
8149
|
+
color: "#BF1D30",
|
8150
|
+
colsForTotal: null,
|
8151
|
+
initialName: "2 , 1707389500",
|
8152
|
+
isSum: false,
|
8153
|
+
isTotal: false,
|
8154
|
+
name: "formatted(2 , 1707389500)",
|
8155
|
+
totalIndex: undefined,
|
8156
|
+
y: -40
|
8157
|
+
},
|
8158
|
+
{
|
8159
|
+
color: "",
|
8160
|
+
colsForTotal: ["Total",],
|
8161
|
+
initialName: "Total",
|
8162
|
+
isSum: true,
|
8163
|
+
isTotal: true,
|
8164
|
+
name: "Total",
|
8165
|
+
totalIndex: 3,
|
8166
|
+
y: 110,
|
8167
|
+
}
|
8168
|
+
],
|
8169
|
+
dataLabels: {
|
8170
|
+
additionalTestProp: "test_value",
|
8171
|
+
allowOverlap: false,
|
8172
|
+
enabled: true,
|
8173
|
+
formatter: "mock formatter function",
|
8174
|
+
style: {"height": "100px"}
|
8175
|
+
},
|
8176
|
+
upColor: undefined
|
8177
|
+
},
|
8178
|
+
{
|
8179
|
+
color: undefined,
|
8180
|
+
name: "Positive",
|
8181
|
+
visible: false
|
8182
|
+
},
|
8183
|
+
{
|
8184
|
+
color: undefined,
|
8185
|
+
name: "Negative",
|
8186
|
+
visible: false
|
8187
|
+
}
|
8188
|
+
]);
|
8189
|
+
});
|
8190
|
+
});
|
7454
8191
|
});
|