@datarailsshared/dr_renderer 1.5.103 → 1.5.107
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
|
@@ -687,7 +687,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
687
687
|
rows = temp;
|
|
688
688
|
}
|
|
689
689
|
|
|
690
|
-
if (!is_drill_down_pie && labelOptions.show_out_of_x_axis) {
|
|
690
|
+
if (!is_drill_down_pie && labelOptions.show_out_of_x_axis && pivotData.getAggregator(rows, cols).widget_values_format !== "#,###%") {
|
|
691
691
|
const axisTotal = pivotData.getAggregator([], cols).value();
|
|
692
692
|
if (value && axisTotal) {
|
|
693
693
|
percentageArray.push(Math.round(value / axisTotal * 100) + '%');
|
|
@@ -901,7 +901,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
901
901
|
}
|
|
902
902
|
|
|
903
903
|
const percentageArray = [];
|
|
904
|
-
if (tooltipOptions.show_out_of_x_axis) {
|
|
904
|
+
if (tooltipOptions.show_out_of_x_axis && aggr.widget_values_format !== "#,###%") {
|
|
905
905
|
const axisTotal = pivotData.getAggregator([], cols).value();
|
|
906
906
|
const outOfAxisPercentages = axisTotal ? Math.round(y / axisTotal * 100) + '%' : '';
|
|
907
907
|
outOfAxisPercentages && percentageArray.push(`% Out of ${percentageLabels.axis}: ${outOfAxisPercentages}`);
|
|
@@ -465,7 +465,8 @@ describe('highcharts_renderer', () => {
|
|
|
465
465
|
getColKeys: jest.fn(() => [['col1'], ['col2']]),
|
|
466
466
|
getRowKeys: jest.fn(() => [['row1'], ['row2']]),
|
|
467
467
|
getAggregator: jest.fn(() => ({
|
|
468
|
-
value: () => 1000
|
|
468
|
+
value: () => 1000,
|
|
469
|
+
widget_values_format: "#,###"
|
|
469
470
|
}))
|
|
470
471
|
};
|
|
471
472
|
|
|
@@ -654,7 +655,7 @@ describe('highcharts_renderer', () => {
|
|
|
654
655
|
});
|
|
655
656
|
|
|
656
657
|
describe('Label options handling', () => {
|
|
657
|
-
it('should return raw value when show_out_of_x_axis is true but percentage logic is not triggered', () => {
|
|
658
|
+
it('should return raw value when show_out_of_x_axis is true but percentage logic is not triggered due to percentage format', () => {
|
|
658
659
|
opts = {
|
|
659
660
|
chartOptions: {
|
|
660
661
|
label: {
|
|
@@ -665,7 +666,10 @@ describe('highcharts_renderer', () => {
|
|
|
665
666
|
};
|
|
666
667
|
|
|
667
668
|
funcContext.y = 250;
|
|
668
|
-
mockPivotData.getAggregator = jest.fn(() => ({
|
|
669
|
+
mockPivotData.getAggregator = jest.fn(() => ({
|
|
670
|
+
value: () => 1000,
|
|
671
|
+
widget_values_format: "#,###%"
|
|
672
|
+
}));
|
|
669
673
|
|
|
670
674
|
let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts);
|
|
671
675
|
let result = fn.call(funcContext);
|
|
@@ -684,7 +688,10 @@ describe('highcharts_renderer', () => {
|
|
|
684
688
|
};
|
|
685
689
|
|
|
686
690
|
funcContext.y = 200;
|
|
687
|
-
mockPivotData.getAggregator = jest.fn(() => ({
|
|
691
|
+
mockPivotData.getAggregator = jest.fn(() => ({
|
|
692
|
+
value: () => 800,
|
|
693
|
+
widget_values_format: "#,###"
|
|
694
|
+
}));
|
|
688
695
|
|
|
689
696
|
let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts);
|
|
690
697
|
let result = fn.call(funcContext);
|
|
@@ -692,7 +699,7 @@ describe('highcharts_renderer', () => {
|
|
|
692
699
|
expect(result).toBe('200');
|
|
693
700
|
});
|
|
694
701
|
|
|
695
|
-
it('should return raw value when both percentage options are enabled but percentage logic is not triggered', () => {
|
|
702
|
+
it('should return raw value when both percentage options are enabled but percentage logic is not triggered due to percentage format', () => {
|
|
696
703
|
opts = {
|
|
697
704
|
chartOptions: {
|
|
698
705
|
label: {
|
|
@@ -707,7 +714,10 @@ describe('highcharts_renderer', () => {
|
|
|
707
714
|
let callCount = 0;
|
|
708
715
|
mockPivotData.getAggregator = jest.fn(() => {
|
|
709
716
|
callCount++;
|
|
710
|
-
return {
|
|
717
|
+
return {
|
|
718
|
+
value: () => callCount === 1 ? 1000 : 800,
|
|
719
|
+
widget_values_format: "#,###%"
|
|
720
|
+
};
|
|
711
721
|
});
|
|
712
722
|
|
|
713
723
|
let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts);
|
|
@@ -716,7 +726,7 @@ describe('highcharts_renderer', () => {
|
|
|
716
726
|
expect(result).toBe('250');
|
|
717
727
|
});
|
|
718
728
|
|
|
719
|
-
it('should show only percentages without value when show_value is false
|
|
729
|
+
it('should show only percentages without value when show_value is false and percentages are enabled', () => {
|
|
720
730
|
opts = {
|
|
721
731
|
chartOptions: {
|
|
722
732
|
label: {
|
|
@@ -727,7 +737,10 @@ describe('highcharts_renderer', () => {
|
|
|
727
737
|
};
|
|
728
738
|
|
|
729
739
|
funcContext.y = 250;
|
|
730
|
-
mockPivotData.getAggregator = jest.fn(() => ({
|
|
740
|
+
mockPivotData.getAggregator = jest.fn(() => ({
|
|
741
|
+
value: () => 1000,
|
|
742
|
+
widget_values_format: "#,###"
|
|
743
|
+
}));
|
|
731
744
|
|
|
732
745
|
let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts);
|
|
733
746
|
let result = fn.call(funcContext);
|
|
@@ -746,7 +759,10 @@ describe('highcharts_renderer', () => {
|
|
|
746
759
|
};
|
|
747
760
|
|
|
748
761
|
funcContext.y = 0;
|
|
749
|
-
mockPivotData.getAggregator = jest.fn(() => ({
|
|
762
|
+
mockPivotData.getAggregator = jest.fn(() => ({
|
|
763
|
+
value: () => 1000,
|
|
764
|
+
widget_values_format: "#,###"
|
|
765
|
+
}));
|
|
750
766
|
|
|
751
767
|
let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts);
|
|
752
768
|
let result = fn.call(funcContext);
|
|
@@ -765,7 +781,10 @@ describe('highcharts_renderer', () => {
|
|
|
765
781
|
};
|
|
766
782
|
|
|
767
783
|
funcContext.y = 250;
|
|
768
|
-
mockPivotData.getAggregator = jest.fn(() => ({
|
|
784
|
+
mockPivotData.getAggregator = jest.fn(() => ({
|
|
785
|
+
value: () => 0,
|
|
786
|
+
widget_values_format: "#,###"
|
|
787
|
+
}));
|
|
769
788
|
|
|
770
789
|
let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts);
|
|
771
790
|
let result = fn.call(funcContext);
|
|
@@ -828,11 +847,10 @@ describe('highcharts_renderer', () => {
|
|
|
828
847
|
funcContext.y = 300;
|
|
829
848
|
mockPivotData.getRowKeys = jest.fn(() => ([['row1'], ['row2']]));
|
|
830
849
|
|
|
831
|
-
let callCount = 0;
|
|
832
850
|
mockPivotData.getAggregator = jest.fn((rows, cols) => {
|
|
833
|
-
if (rows.length === 1) return { value: () => 400 };
|
|
834
|
-
if (rows.length === 0 && cols.length > 0) return { value: () => 1200 };
|
|
835
|
-
return { value: () => 800 };
|
|
851
|
+
if (rows.length === 1) return { value: () => 400, widget_values_format: "#,###" };
|
|
852
|
+
if (rows.length === 0 && cols.length > 0) return { value: () => 1200, widget_values_format: "#,###" };
|
|
853
|
+
return { value: () => 800, widget_values_format: "#,###" };
|
|
836
854
|
});
|
|
837
855
|
|
|
838
856
|
let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts);
|
|
@@ -854,18 +872,10 @@ describe('highcharts_renderer', () => {
|
|
|
854
872
|
funcContext.y = 200; // value = 200
|
|
855
873
|
mockPivotData.getRowKeys = jest.fn(() => ([['row1'], ['row2']]));
|
|
856
874
|
|
|
857
|
-
let callCount = 0;
|
|
858
875
|
mockPivotData.getAggregator = jest.fn((rows, cols) => {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
return { value: () => 400 };
|
|
863
|
-
}
|
|
864
|
-
if (rows.length === 0 && cols.length > 0) {
|
|
865
|
-
return { value: () => 0 };
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
return { value: () => 200 };
|
|
876
|
+
if (rows.length === 1) return { value: () => 400, widget_values_format: "#,###" };
|
|
877
|
+
if (rows.length === 0 && cols.length > 0) return { value: () => 0, widget_values_format: "#,###" };
|
|
878
|
+
return { value: () => 200, widget_values_format: "#,###" };
|
|
869
879
|
});
|
|
870
880
|
|
|
871
881
|
let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts);
|
|
@@ -890,9 +900,9 @@ describe('highcharts_renderer', () => {
|
|
|
890
900
|
|
|
891
901
|
mockPivotData.getAggregator = jest.fn((rows, cols) => {
|
|
892
902
|
if (cols.length === 0) {
|
|
893
|
-
return { value: () => 0 };
|
|
903
|
+
return { value: () => 0, widget_values_format: "#,###" };
|
|
894
904
|
}
|
|
895
|
-
return { value: () => 200 };
|
|
905
|
+
return { value: () => 200, widget_values_format: "#,###" };
|
|
896
906
|
});
|
|
897
907
|
|
|
898
908
|
let fn = highchartsRenderer.defaultDataLabelFormatter(mockPivotData, opts);
|
|
@@ -5501,6 +5511,8 @@ describe('highcharts_renderer', () => {
|
|
|
5501
5511
|
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
|
5502
5512
|
const agg = aggregator({}, '', '');
|
|
5503
5513
|
|
|
5514
|
+
agg.widget_values_format = format;
|
|
5515
|
+
|
|
5504
5516
|
if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, ['row 1'])) {
|
|
5505
5517
|
agg.sum = 12345;
|
|
5506
5518
|
} else if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, [])) {
|