@datarailsshared/dr_renderer 1.2.241 → 1.2.243
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 +1 -1
- package/src/highcharts_renderer.js +70 -1
package/package.json
CHANGED
|
@@ -1438,7 +1438,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1438
1438
|
|
|
1439
1439
|
let keys = [];
|
|
1440
1440
|
if (value.trend === 'total') {
|
|
1441
|
-
keys =
|
|
1441
|
+
keys = value.key;
|
|
1442
1442
|
} else {
|
|
1443
1443
|
_.forEach(value.key, (item) => {
|
|
1444
1444
|
const findKeyByValue = Object.keys(pivotData.dateValuesDictionary || {}).find(key => pivotData.dateValuesDictionary[key] === item);
|
|
@@ -5217,6 +5217,38 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5217
5217
|
widgetOptions.pivot.chartOptions = widgetOptions.options;
|
|
5218
5218
|
widgetOptions.pivot.chartRender = highchartsRenderer.getChartRendererFunction(widgetOptions.pivot.chartType, drilldownFunc, drillDownListFunc);
|
|
5219
5219
|
|
|
5220
|
+
// TODO: remove this logic after BE sort is implemented
|
|
5221
|
+
// it is required to do sort by totals for comparative analysis - we need to change deltas if columns swaped vice versa
|
|
5222
|
+
const isTwoColumnComparisonWidget = widgetOptions.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN
|
|
5223
|
+
&& lodash.get(widgetOptions, 'options.breakdown_options.values.totals', []).length === 2;
|
|
5224
|
+
|
|
5225
|
+
if (isTwoColumnComparisonWidget) {
|
|
5226
|
+
const totalsField = xaxisFields[0];
|
|
5227
|
+
const isScenarioInTotals = /scenario/i.test(totalsField.name);
|
|
5228
|
+
|
|
5229
|
+
if (isScenarioInTotals) {
|
|
5230
|
+
const breakdownField = legendFields[0];
|
|
5231
|
+
const valuesField = valuesFields[0];
|
|
5232
|
+
|
|
5233
|
+
// getting first total value encounter from response rows - it's value to which delta is attached
|
|
5234
|
+
const firstTotalValueInResponse = lodash.get(widgetOptions, `pivot.rowData[0].${totalsField.name}`);
|
|
5235
|
+
|
|
5236
|
+
// getting first total value from breakdown options (after sort is done)
|
|
5237
|
+
const firstTotalValueAfterSort = lodash.get(widgetOptions, 'options.breakdown_options.values.totals[0].key');
|
|
5238
|
+
|
|
5239
|
+
// if two columns changed places (swaped)
|
|
5240
|
+
// then we need to replace keys in response rows and multiply delta to -1
|
|
5241
|
+
if (firstTotalValueInResponse && firstTotalValueAfterSort && firstTotalValueInResponse !== firstTotalValueAfterSort) {
|
|
5242
|
+
lodash.forEach(widgetOptions.pivot.rowData, row => {
|
|
5243
|
+
const isDeltaRow = row[totalsField.name] && row[breakdownField.name];
|
|
5244
|
+
if (isDeltaRow) {
|
|
5245
|
+
row[totalsField.name] = firstTotalValueAfterSort;
|
|
5246
|
+
row[valuesField.name] *= -1;
|
|
5247
|
+
}
|
|
5248
|
+
});
|
|
5249
|
+
}
|
|
5250
|
+
}
|
|
5251
|
+
}
|
|
5220
5252
|
};
|
|
5221
5253
|
|
|
5222
5254
|
highchartsRenderer.addTemplateDataToExTableOptions = function (selectedTemplate, exTableOptions) {
|
|
@@ -8827,6 +8859,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8827
8859
|
|
|
8828
8860
|
res = highchartsRenderer.setNewFieldNames(res);
|
|
8829
8861
|
|
|
8862
|
+
if (widget_obj.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH) {
|
|
8863
|
+
res = highchartsRenderer.addTotalsToWalkthroughRowData(widget_obj, res);
|
|
8864
|
+
}
|
|
8865
|
+
|
|
8830
8866
|
let pivot = {};
|
|
8831
8867
|
pivot.sorters = highchartsRenderer.getWidgetDataSorters(res, widget_obj);
|
|
8832
8868
|
pivot.rowData = res;
|
|
@@ -9113,6 +9149,39 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
9113
9149
|
return series.name ? 'Trend Line (' + series.name + ')' : 'Trend Line';
|
|
9114
9150
|
}
|
|
9115
9151
|
|
|
9152
|
+
highchartsRenderer.addTotalsToWalkthroughRowData = function(widget, rowDataInitial) {
|
|
9153
|
+
const walkthroughValues = widget.options.walkthrough_options.values.walkthrough;
|
|
9154
|
+
const categoryFields = widget.cols;
|
|
9155
|
+
const valueField = widget.vals[0];
|
|
9156
|
+
const rowData = lodash.cloneDeep(rowDataInitial);
|
|
9157
|
+
const modifiedRowData = [];
|
|
9158
|
+
|
|
9159
|
+
let sum = 0;
|
|
9160
|
+
lodash.forEach(walkthroughValues, (value) => {
|
|
9161
|
+
|
|
9162
|
+
// if it is not total value - then add it as rowData data row and sum it up
|
|
9163
|
+
// else - add total with calculated sum as new rowData data row (totals do not initially exist in BE response)
|
|
9164
|
+
if (value.trend !== 'total') {
|
|
9165
|
+
const rowIndex = lodash.findIndex(rowData, (responseRow) =>
|
|
9166
|
+
lodash.every(categoryFields, (field, fieldKey) => responseRow[field.name] === value.key[fieldKey])
|
|
9167
|
+
);
|
|
9168
|
+
modifiedRowData.push(rowData[rowIndex]);
|
|
9169
|
+
sum += rowData[rowIndex][valueField.name];
|
|
9170
|
+
rowData.splice(rowIndex, 1);
|
|
9171
|
+
} else {
|
|
9172
|
+
const totalRow = {};
|
|
9173
|
+
_.forEach(categoryFields, (field, fieldKey) => {
|
|
9174
|
+
totalRow[field.name] = value.key[fieldKey];
|
|
9175
|
+
});
|
|
9176
|
+
totalRow[valueField.name] = sum;
|
|
9177
|
+
modifiedRowData.push(totalRow);
|
|
9178
|
+
sum = 0;
|
|
9179
|
+
}
|
|
9180
|
+
});
|
|
9181
|
+
|
|
9182
|
+
return lodash.concat(modifiedRowData, rowData);
|
|
9183
|
+
}
|
|
9184
|
+
|
|
9116
9185
|
return highchartsRenderer;
|
|
9117
9186
|
};
|
|
9118
9187
|
|