@datarailsshared/dr_renderer 1.2.242 → 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 +32 -0
package/package.json
CHANGED
|
@@ -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) {
|