@datarailsshared/dr_renderer 1.2.352 → 1.2.356
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
@@ -167,6 +167,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
167
167
|
}
|
168
168
|
}
|
169
169
|
|
170
|
+
// remove highcharts tooltip from the dom instead of hiding if option is passed
|
171
|
+
Highcharts.wrap(Highcharts.Tooltip.prototype, 'hide', function(proceed, delay) {
|
172
|
+
if (!this.options.destroyWhenHiding) {
|
173
|
+
proceed.call(this, delay);
|
174
|
+
} else {
|
175
|
+
Highcharts.clearTimeout(this.hideTimer);
|
176
|
+
delay = Highcharts.pick(delay, this.options.hideDelay);
|
177
|
+
this.hideTimer = Highcharts.syncTimeout(() => {
|
178
|
+
this.destroy();
|
179
|
+
}, delay);
|
180
|
+
}
|
181
|
+
});
|
182
|
+
|
170
183
|
if(!moment_lib){
|
171
184
|
moment_lib = moment;
|
172
185
|
}
|
@@ -701,6 +714,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
701
714
|
padding: 0,
|
702
715
|
stickOnContact: true,
|
703
716
|
hideDelay: 1500,
|
717
|
+
destroyWhenHiding: true,
|
704
718
|
formatter: function () {
|
705
719
|
const rowKey = pivotData.rowAttrs.length ? lodash.get(this.point, 'series.name') || "" : "";
|
706
720
|
const colKey = lodash.get(this.point, 'name') || this.x.name[0] || "";
|
@@ -1493,7 +1507,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1493
1507
|
totalSeries.color = colors[i];
|
1494
1508
|
}
|
1495
1509
|
|
1496
|
-
|
1510
|
+
|
1497
1511
|
col_n_keys.forEach(columnKey => {
|
1498
1512
|
let key = columnKey;
|
1499
1513
|
let totalKey = columnKey;
|
@@ -1504,18 +1518,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1504
1518
|
const value = pivotData.colTotals[totalKey] ? pivotData.colTotals[totalKey].value() : 0;
|
1505
1519
|
totalSeries.data.push({name: lodash.unescape(key), y: value});
|
1506
1520
|
});
|
1507
|
-
} else {
|
1508
|
-
lodash.forEach(row_n_keys, (rowKey, index) => {
|
1509
|
-
let key = rowKey;
|
1510
|
-
let totalKey = rowKey;
|
1511
|
-
if (lodash.isArray(rowKey)) {
|
1512
|
-
key = col_n_keys[index];
|
1513
|
-
totalKey = totalKey.join(highchartsRenderer.delimer);
|
1514
|
-
}
|
1515
|
-
const value = pivotData.rowTotals[totalKey] ? pivotData.rowTotals[totalKey].value() : 0;
|
1516
|
-
totalSeries.data.push({name: lodash.unescape(key), y: value});
|
1517
|
-
});
|
1518
|
-
}
|
1519
1521
|
|
1520
1522
|
chart_series.push(totalSeries);
|
1521
1523
|
}
|
@@ -8985,6 +8987,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8985
8987
|
res = highchartsRenderer.addTotalsToWalkthroughRowData(widget_obj, res);
|
8986
8988
|
}
|
8987
8989
|
|
8990
|
+
res = highchartsRenderer.fixIncompatibleCalculatedValuesTotals(widget_obj, res);
|
8991
|
+
|
8988
8992
|
let pivot = {};
|
8989
8993
|
|
8990
8994
|
let templateNoData = lodash.find(templates, {id: widget_obj.template_id});
|
@@ -9494,6 +9498,73 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9494
9498
|
}));
|
9495
9499
|
}
|
9496
9500
|
|
9501
|
+
// We are receiving not correct format for subtotals from BE for now - so we modyfing the response
|
9502
|
+
// in order to transform it to acceptable one. It is complex to fix currently on BE side.
|
9503
|
+
// TODO: remove it when fixed on BE side
|
9504
|
+
highchartsRenderer.fixIncompatibleCalculatedValuesTotals = function(widget, res) {
|
9505
|
+
|
9506
|
+
// if it is FE side calculation or empty response - just return unmodified
|
9507
|
+
if (!highchartsRenderer.useTotalsCalculation || !lodash.get(res, 'length')) return res;
|
9508
|
+
|
9509
|
+
const calculatedValuesInValsCount = lodash.filter(
|
9510
|
+
widget.calculated_values, calcVal => lodash.some(widget.vals, { field: calcVal.field })
|
9511
|
+
).length;
|
9512
|
+
|
9513
|
+
// do transformations only if widget has calculated in values
|
9514
|
+
if (calculatedValuesInValsCount) {
|
9515
|
+
const fieldWithDrValuesNames = lodash.reduce(
|
9516
|
+
widget.calculated_values,
|
9517
|
+
(fieldNames, calcVal) => {
|
9518
|
+
const fieldName = lodash.get(lodash.find(widget.vals, { field: calcVal.field }), 'name');
|
9519
|
+
return fieldName ? lodash.concat(fieldNames, [fieldName]) : fieldNames;
|
9520
|
+
},
|
9521
|
+
[]
|
9522
|
+
);
|
9523
|
+
|
9524
|
+
const existingRecords = [];
|
9525
|
+
lodash.forEach(res, (record) => {
|
9526
|
+
|
9527
|
+
// example: replace record { Type: "Discount", City: "Brest", DR_Values: "Normal 1", Amount: 52585.14 }
|
9528
|
+
// with { Type: "Discount", City: "Brest", DR_Values: "Normal 1", value: 52585.14 }
|
9529
|
+
if (widget.vals.length > 1 && !widget.rows.length) {
|
9530
|
+
const valueFieldNameFound = lodash.find(fieldWithDrValuesNames, name => record[name]);
|
9531
|
+
if (valueFieldNameFound) {
|
9532
|
+
record.value = record[valueFieldNameFound];
|
9533
|
+
delete record[valueFieldNameFound];
|
9534
|
+
}
|
9535
|
+
}
|
9536
|
+
|
9537
|
+
// in response from BE we have currently improper column subtotals:
|
9538
|
+
// they returned with 'DR_Values' not empty - same as for regular cell values
|
9539
|
+
// so we have two records with same column values and can't define which is subtotal
|
9540
|
+
const isSameColValuesWasBefore = lodash.some(existingRecords, existingRecord =>
|
9541
|
+
lodash.every(
|
9542
|
+
lodash.concat(['DR_Values'], lodash.map(widget.cols, 'name')), fieldName => existingRecord[fieldName] === record[fieldName]
|
9543
|
+
)
|
9544
|
+
);
|
9545
|
+
const isNoRowValues = lodash.every(widget.rows, field => typeof record[field.name] === 'undefined');
|
9546
|
+
const isSubtotal = isSameColValuesWasBefore && isNoRowValues;
|
9547
|
+
|
9548
|
+
// we need to remove DR_Values for response records which suppose to be subtotals
|
9549
|
+
if (isSubtotal) {
|
9550
|
+
delete record.DR_Values;
|
9551
|
+
}
|
9552
|
+
|
9553
|
+
existingRecords.push(record);
|
9554
|
+
});
|
9555
|
+
|
9556
|
+
// Another BE issue - it is not returning correct subtotals for case we have more than one calculated values
|
9557
|
+
// It is just not counting sum there. So we remove it in order not to show improper values
|
9558
|
+
if ((calculatedValuesInValsCount > 1 || calculatedValuesInValsCount && widget.vals.length > 1) && !widget.rows.length) {
|
9559
|
+
res = lodash.filter(res, record => {
|
9560
|
+
const isColsTotal = typeof record['DR_Values'] === 'undefined';
|
9561
|
+
return !isColsTotal;
|
9562
|
+
})
|
9563
|
+
}
|
9564
|
+
}
|
9565
|
+
return res;
|
9566
|
+
}
|
9567
|
+
|
9497
9568
|
return highchartsRenderer;
|
9498
9569
|
};
|
9499
9570
|
|
@@ -36,7 +36,9 @@ describe('highcharts_renderer', () => {
|
|
36
36
|
opt: {},
|
37
37
|
setOptions: function(value) {Highcharts.opt = value;},
|
38
38
|
numberFormat: function(value) { return value ;},
|
39
|
-
getOptions: function() { return Highcharts.opt; }
|
39
|
+
getOptions: function() { return Highcharts.opt; },
|
40
|
+
Tooltip: {},
|
41
|
+
wrap: () => {},
|
40
42
|
};
|
41
43
|
_window.DataFormatter = DataFormatter;
|
42
44
|
initPivotTable($, _window, _document);
|