@datarailsshared/dr_renderer 1.2.415 → 1.2.416
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
@@ -8392,4 +8392,199 @@ describe('highcharts_renderer', () => {
|
|
8392
8392
|
highchartsRenderer.ptRenderSolidGauge('mock_pivot_data', 'mock_opts');
|
8393
8393
|
expect(highchartsRenderer.ptRenderGauge).toHaveBeenCalledWith('mock_pivot_data', 'mock_opts', true);
|
8394
8394
|
});
|
8395
|
+
|
8396
|
+
describe("Function ptCreateWaterfallBreakdownSeries", () => {
|
8397
|
+
const format = null;
|
8398
|
+
const additionalOptionsMock = { testOption: 'test additional option 1' }
|
8399
|
+
|
8400
|
+
const commonPivotDataMockProps = {
|
8401
|
+
colFormats: 'mock_formats',
|
8402
|
+
colAttrs: ['Test Number Field'],
|
8403
|
+
allTotal: {
|
8404
|
+
uniq: 1
|
8405
|
+
}
|
8406
|
+
};
|
8407
|
+
|
8408
|
+
const optsMock = {
|
8409
|
+
breakdown_options: {
|
8410
|
+
colors: {
|
8411
|
+
decrease: "#BF1D30",
|
8412
|
+
increase: "#20A452",
|
8413
|
+
total: "rgba(0, 254, 87, 1)",
|
8414
|
+
},
|
8415
|
+
},
|
8416
|
+
};
|
8417
|
+
|
8418
|
+
const pivotDataMockWithNoBreakdownField = {
|
8419
|
+
getAggregator: (rows, cols) => {
|
8420
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
8421
|
+
const agg = aggregator({}, '', '');
|
8422
|
+
|
8423
|
+
if (lodash.isEqual(cols, [1]) && lodash.isEqual(rows, [])) {
|
8424
|
+
agg.sum = 10;
|
8425
|
+
} else if (lodash.isEqual(cols, [2]) && lodash.isEqual(rows, [])) {
|
8426
|
+
agg.sum = 30;
|
8427
|
+
} else if (lodash.isEqual(cols, [3]) && lodash.isEqual(rows, [])) {
|
8428
|
+
agg.sum = 80;
|
8429
|
+
} else if (lodash.isEqual(cols, [1]) && lodash.isEqual(rows, ['Variance'])) {
|
8430
|
+
agg.sum = 20;
|
8431
|
+
} else if (lodash.isEqual(cols, [2]) && lodash.isEqual(rows, ['Variance'])) {
|
8432
|
+
agg.sum = 50;
|
8433
|
+
}
|
8434
|
+
return agg;
|
8435
|
+
},
|
8436
|
+
getColKeys: () => [[1], [2], [3]],
|
8437
|
+
getRowKeys: () => [],
|
8438
|
+
getRowKeysByCols: () => [[["Variance"]], [["Variance"]]],
|
8439
|
+
...commonPivotDataMockProps,
|
8440
|
+
};
|
8441
|
+
|
8442
|
+
const pivotDataMockWithBreakdownField = {
|
8443
|
+
getAggregator: (rows, cols) => {
|
8444
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
8445
|
+
const agg = aggregator({}, '', '');
|
8446
|
+
|
8447
|
+
if (lodash.isEqual(cols, [1]) && lodash.isEqual(rows, [])) {
|
8448
|
+
agg.sum = 10;
|
8449
|
+
} else if (lodash.isEqual(cols, [2]) && lodash.isEqual(rows, [])) {
|
8450
|
+
agg.sum = 30;
|
8451
|
+
} else if (lodash.isEqual(cols, [3]) && lodash.isEqual(rows, [])) {
|
8452
|
+
agg.sum = 80;
|
8453
|
+
} else if (lodash.isEqual(cols, [1]) && lodash.isEqual(rows, ['val1'])) {
|
8454
|
+
agg.sum = 5;
|
8455
|
+
} else if (lodash.isEqual(cols, [1]) && lodash.isEqual(rows, ['val2'])) {
|
8456
|
+
agg.sum = 15;
|
8457
|
+
} else if (lodash.isEqual(cols, [2]) && lodash.isEqual(rows, ['val1'])) {
|
8458
|
+
agg.sum = 30;
|
8459
|
+
} else if (lodash.isEqual(cols, [2]) && lodash.isEqual(rows, ['val2'])) {
|
8460
|
+
agg.sum = 20;
|
8461
|
+
}
|
8462
|
+
return agg;
|
8463
|
+
},
|
8464
|
+
getColKeys: () => [[1], [2], [3]],
|
8465
|
+
getRowKeys: () => [],
|
8466
|
+
getRowKeysByCols: () => [[["val2"], ["val1"]], [["val1"], ["val2"]]],
|
8467
|
+
...commonPivotDataMockProps,
|
8468
|
+
};
|
8469
|
+
|
8470
|
+
beforeEach(() => {
|
8471
|
+
spyOn(highchartsRenderer, "defaultDataLabelFormatter").and.returnValue("mock formatter function");
|
8472
|
+
spyOn(highchartsRenderer, "getDataLabelsStyle").and.returnValue({ height: '100px' });
|
8473
|
+
spyOn(highchartsRenderer, "getOthersName").and.returnValue({ height: 'Test Others Name' });
|
8474
|
+
spyOn(highchartsRenderer, 'getDataLabelsOptions').and.callFake((additionOptions, resultObject) => {
|
8475
|
+
resultObject.dataLabels.additionalTestProp = 'test_value';
|
8476
|
+
return resultObject;
|
8477
|
+
});
|
8478
|
+
spyOn(highchartsRenderer, 'getFormattedColKey')
|
8479
|
+
.and.callFake((initialName, pivotData) => `formatted_col(${ initialName })`);
|
8480
|
+
spyOn(highchartsRenderer, 'getFormattedRowKey')
|
8481
|
+
.and.callFake((initialName, pivotData) => `formatted_row(${ initialName })`);
|
8482
|
+
spyOn(highchartsRenderer, 'isFormattingDatesAsOtherAxisTypes').and.returnValue(true);
|
8483
|
+
});
|
8484
|
+
|
8485
|
+
it("should create appropriate series for case no breakdown field (one row value - Variance instead)", () => {
|
8486
|
+
const pivotDataMock = lodash.cloneDeep(pivotDataMockWithNoBreakdownField);
|
8487
|
+
|
8488
|
+
const series = highchartsRenderer.ptCreateWaterfallBreakdownSeries(pivotDataMock, additionalOptionsMock, optsMock);
|
8489
|
+
expect(series).toEqual([
|
8490
|
+
{
|
8491
|
+
className: 'waterfallBreakdown',
|
8492
|
+
color: '#BF1D30',
|
8493
|
+
data: [
|
8494
|
+
{
|
8495
|
+
color: 'rgba(0, 254, 87, 1)',
|
8496
|
+
initialName: '1',
|
8497
|
+
isSum: false,
|
8498
|
+
isTotal: true,
|
8499
|
+
name: 'formatted_col(1)',
|
8500
|
+
y: 10,
|
8501
|
+
},
|
8502
|
+
{ colKeys: ['1', '2'], initialName: 'Variance', name: 'formatted_row(Variance)', y: 20 },
|
8503
|
+
{
|
8504
|
+
color: 'rgba(0, 254, 87, 1)',
|
8505
|
+
initialName: '2',
|
8506
|
+
isSum: true,
|
8507
|
+
isTotal: true,
|
8508
|
+
name: 'formatted_col(2)',
|
8509
|
+
y: 30,
|
8510
|
+
},
|
8511
|
+
{ colKeys: ['2', '3'], initialName: 'Variance', name: 'formatted_row(Variance)', y: 50 },
|
8512
|
+
{
|
8513
|
+
color: 'rgba(0, 254, 87, 1)',
|
8514
|
+
initialName: '3',
|
8515
|
+
isSum: true,
|
8516
|
+
isTotal: true,
|
8517
|
+
name: 'formatted_col(3)',
|
8518
|
+
y: 80,
|
8519
|
+
},
|
8520
|
+
],
|
8521
|
+
dataLabels: {
|
8522
|
+
additionalTestProp: 'test_value',
|
8523
|
+
allowOverlap: false,
|
8524
|
+
enabled: true,
|
8525
|
+
formatter: 'mock formatter function',
|
8526
|
+
style: { height: '100px' },
|
8527
|
+
},
|
8528
|
+
name: 'Test Number Field',
|
8529
|
+
upColor: '#20A452',
|
8530
|
+
},
|
8531
|
+
{ color: '#20A452', name: 'Positive', visible: false },
|
8532
|
+
{ color: '#BF1D30', name: 'Negative', visible: false },
|
8533
|
+
]);
|
8534
|
+
});
|
8535
|
+
|
8536
|
+
it("should create appropriate series for case there is breakdown field (differently sorted vals)", () => {
|
8537
|
+
const pivotDataMock = lodash.cloneDeep(pivotDataMockWithBreakdownField);
|
8538
|
+
|
8539
|
+
const series = highchartsRenderer.ptCreateWaterfallBreakdownSeries(pivotDataMock, additionalOptionsMock, optsMock);
|
8540
|
+
expect(series).toEqual([
|
8541
|
+
{
|
8542
|
+
className: 'waterfallBreakdown',
|
8543
|
+
color: '#BF1D30',
|
8544
|
+
data: [
|
8545
|
+
{
|
8546
|
+
color: 'rgba(0, 254, 87, 1)',
|
8547
|
+
initialName: '1',
|
8548
|
+
isSum: false,
|
8549
|
+
isTotal: true,
|
8550
|
+
name: 'formatted_col(1)',
|
8551
|
+
y: 10,
|
8552
|
+
},
|
8553
|
+
{ colKeys: ['1', '2'], initialName: 'val2', name: 'formatted_row(val2)', y: 15 },
|
8554
|
+
{ colKeys: ['1', '2'], initialName: 'val1', name: 'formatted_row(val1)', y: 5 },
|
8555
|
+
{
|
8556
|
+
color: 'rgba(0, 254, 87, 1)',
|
8557
|
+
initialName: '2',
|
8558
|
+
isSum: true,
|
8559
|
+
isTotal: true,
|
8560
|
+
name: 'formatted_col(2)',
|
8561
|
+
y: 30,
|
8562
|
+
},
|
8563
|
+
{ colKeys: ['2', '3'], initialName: 'val1', name: 'formatted_row(val1)', y: 30 },
|
8564
|
+
{ colKeys: ['2', '3'], initialName: 'val2', name: 'formatted_row(val2)', y: 20 },
|
8565
|
+
{
|
8566
|
+
color: 'rgba(0, 254, 87, 1)',
|
8567
|
+
initialName: '3',
|
8568
|
+
isSum: true,
|
8569
|
+
isTotal: true,
|
8570
|
+
name: 'formatted_col(3)',
|
8571
|
+
y: 80,
|
8572
|
+
},
|
8573
|
+
],
|
8574
|
+
dataLabels: {
|
8575
|
+
additionalTestProp: 'test_value',
|
8576
|
+
allowOverlap: false,
|
8577
|
+
enabled: true,
|
8578
|
+
formatter: 'mock formatter function',
|
8579
|
+
style: { height: '100px' },
|
8580
|
+
},
|
8581
|
+
name: 'Test Number Field',
|
8582
|
+
upColor: '#20A452',
|
8583
|
+
},
|
8584
|
+
{ color: '#20A452', name: 'Positive', visible: false },
|
8585
|
+
{ color: '#BF1D30', name: 'Negative', visible: false },
|
8586
|
+
]);
|
8587
|
+
});
|
8588
|
+
});
|
8589
|
+
|
8395
8590
|
});
|