@datarailsshared/dr_renderer 1.2.216-dragons → 1.2.218

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.2.216-dragons",
3
+ "version": "1.2.218",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -1,6 +1,5 @@
1
1
  const SERIES_CLASSNAMES = {
2
2
  WATERFALL_BREAKDOWN: 'waterfallBreakdown',
3
- WATERFALL_WALKTHROUGH: 'waterfallWalkthrough',
4
3
  TOTAL_SERIES: 'totalSeries',
5
4
  TREND_SERIES: 'trendSeries',
6
5
  };
@@ -26,7 +25,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
26
25
  const textColor = "#151a41";
27
26
  const chartLabelColor = "#cfd7dd";
28
27
  const HIGHCHARTS_FONT_FAMILY = 'Poppins';
29
- let firstBarColor = null;
30
28
 
31
29
  if(!Highcharts){
32
30
  Highcharts = {
@@ -84,16 +82,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
84
82
  KPI_WIDGET: 'kpi-widget',
85
83
  TEXT_WIDGET: 'text-widget',
86
84
  WATERFALL_BREAKDOWN: 'waterfall-chart-breakdown',
87
- WATERFALL_WALKTHROUGH: 'waterfall-chart-walkthrough',
88
85
  PUBLISHED_ITEM: 'published_item',
89
86
  RICH_TEXT: 'rich_text',
90
87
  EXCEL_VIEWER: 'excel_viewer',
91
88
  };
92
89
 
93
- highchartsRenderer.VIRTUAL_FIELDS = {
94
- WATERFALL_VARIANCE: 'DR_WATERFALL_BREAKDOWN_VARIANCE',
95
- };
96
-
97
90
  highchartsRenderer.highcharts_theme = {
98
91
  "colors": highchartsRenderer.defaults_colors,
99
92
  "chart": {
@@ -469,7 +462,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
469
462
  highchartsRenderer.getOthersName(opts) :
470
463
  undefined;
471
464
  var drOthersInColumn = lodash.find(
472
- pivotData.getColKeys(),
465
+ pivotData.getColKeys(),
473
466
  keys => keys.length && (lodash.includes(keys, 'DR_Others') || lodash.includes(keys, othersName))
474
467
  );
475
468
 
@@ -489,7 +482,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
489
482
  rows = [];
490
483
  }
491
484
 
492
- var cols = lodash.get(this, 'point.options.colsForTotal') || this.key;
485
+ var cols = this.key;
493
486
  if (typeof (cols) == 'object' && cols.name) {
494
487
  cols = cols.name;
495
488
  }
@@ -497,7 +490,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
497
490
  if (!cols && is_drill_down_pie) {
498
491
  cols = this.point.name;
499
492
  }
500
-
493
+
501
494
  if (drOthersInColumn) {
502
495
  if (!lodash.isArray(cols) && othersName === cols) {
503
496
  cols = ['DR_Others'];
@@ -635,8 +628,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
635
628
  || this.series.options.className === 'trendSeries') {
636
629
  rows = [];
637
630
  }
638
-
639
- var cols = lodash.get(this, 'point.options.colsForTotal') || this.key;
631
+ var cols = this.key;
640
632
  if (!cols && is_drill_down_pie) {
641
633
  cols = this.name;
642
634
  }
@@ -659,9 +651,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
659
651
  rows = temp;
660
652
  }
661
653
 
662
- var category_text = `<span style="font-weight: bold;">
663
- ${ lodash.get(this, 'point.options.colsForTotal') ? cols[0] : cols } ${ isWaterfallBreakdown ? ': ' : ' ' }
664
- </span>`;
654
+ var category_text = `<span style="font-weight: bold;">${ cols }${ isWaterfallBreakdown ? ': ' : ' ' }</span>`;
665
655
  if (this.category) {
666
656
  category_text = '';
667
657
  }
@@ -678,7 +668,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
678
668
  const modifiedRowsAndCols = highchartsRenderer.transformRowsAndColsForBreakdown(rows, cols, this.point, opts);
679
669
  rows = modifiedRowsAndCols.rows;
680
670
  cols = modifiedRowsAndCols.cols;
681
- }
671
+ }
682
672
 
683
673
  var aggr = pivotData.getAggregator(rows, cols);
684
674
 
@@ -1354,6 +1344,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1354
1344
  const chart_series = [];
1355
1345
  const row_n_keys = pivotData.getRowKeys();
1356
1346
  const col_n_keys = pivotData.getColKeys();
1347
+ const hasBreakdownValues = lodash.get(opts, 'breakdown_options.values.breakdown.length');
1357
1348
 
1358
1349
  let resultObject = {
1359
1350
  data: [],
@@ -1372,6 +1363,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1372
1363
  lodash.forEach(col_n_keys, function(col_n_value, col_index) {
1373
1364
 
1374
1365
  const totalColumnValue = pivotData.getAggregator([], col_n_value).value();
1366
+ const nextTotalColumnKey = col_n_keys[col_index + 1];
1367
+ const nextTotalColumnValue = nextTotalColumnKey ? pivotData.getAggregator([], nextTotalColumnKey).value() : null;
1375
1368
  resultObject.data.push({
1376
1369
  y: totalColumnValue,
1377
1370
  name: lodash.unescape(col_n_value).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
@@ -1383,7 +1376,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1383
1376
  if (col_index !== col_n_keys.length - 1) {
1384
1377
  lodash.forEach(row_n_keys, function (row_n_value) {
1385
1378
  const agg = pivotData.getAggregator(row_n_value, col_n_value);
1386
- let val = agg.value();
1379
+ let val = hasBreakdownValues
1380
+ ? agg.value()
1381
+ : nextTotalColumnValue - totalColumnValue;
1387
1382
 
1388
1383
  val = $.isNumeric(val) ? parseFloat(val) : 0;
1389
1384
  if (val) {
@@ -1394,7 +1389,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1394
1389
  if (tmoobj.name) {
1395
1390
  tmoobj.name = tmoobj.name.replace('DR_Others', highchartsRenderer.getOthersName(opts));
1396
1391
  }
1397
-
1398
1392
  if (lodash.isEmpty(String(tmoobj.name))) {
1399
1393
  tmoobj.name = lodash.unescape(col_n_value);
1400
1394
  tmoobj.visible = false;
@@ -1404,12 +1398,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1404
1398
  tmoobj.colKeys = [lodash.unescape(col_n_keys[col_index - 1]), lodash.unescape(col_n_value)];
1405
1399
  resultObject.data.push(tmoobj);
1406
1400
  }
1407
-
1408
1401
  });
1409
1402
  }
1410
1403
  });
1411
1404
 
1412
1405
  chart_series.push(resultObject);
1406
+
1413
1407
  opts.chart_series = [];
1414
1408
  if (!lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
1415
1409
  chart_series.forEach(series => {
@@ -1420,89 +1414,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1420
1414
  return chart_series;
1421
1415
  }
1422
1416
 
1423
- highchartsRenderer.ptCreateWaterfallWalkthroughSeries = function (pivotData, onlyNumbers, additionOptions, opts) {
1424
- const waterfallOptions = opts.walkthrough_options;
1425
- const chart_series = [];
1426
- let resultObject = {
1427
- data: [],
1428
- dataLabels: {
1429
- allowOverlap: additionOptions && additionOptions.label ? additionOptions.label.overlap : false,
1430
- enabled: additionOptions && additionOptions.label ? additionOptions.label.show : true,
1431
- formatter: highchartsRenderer.defaultDataLabelFormatter(pivotData, {'chartOptions': additionOptions, total_value_options: opts.total_value_options}),
1432
- style: highchartsRenderer.getDataLabelsStyle(additionOptions),
1433
- },
1434
- upColor: waterfallOptions.colors.increase,
1435
- color: waterfallOptions.colors.decrease,
1436
- className: SERIES_CLASSNAMES.WATERFALL_WALKTHROUGH
1437
- };
1438
- resultObject = highchartsRenderer.getDataLabelsOptions(additionOptions, resultObject);
1439
- lodash.forEach(waterfallOptions.values.walkthrough, function(value, index) {
1440
-
1441
- let keys = [];
1442
- if (value.trend === 'total') {
1443
- keys = ['Total'];
1444
- } else {
1445
- _.forEach(value.key, (item) => {
1446
- const findKeyByValue = Object.keys(pivotData.dateValuesDictionary || {}).find(key => pivotData.dateValuesDictionary[key] === item);
1447
- keys.push(findKeyByValue ? findKeyByValue : item);
1448
- })
1449
- }
1450
-
1451
- const agg = pivotData.getAggregator([], keys);
1452
- let val = agg.value();
1453
-
1454
- if (val != null && $.isNumeric(val)) {
1455
- val = parseFloat(val);
1456
- } else if (onlyNumbers) {
1457
- val = NaN;
1458
- } else {
1459
- val = 0;
1460
- }
1461
-
1462
- if (value.trend === 'decrease') {
1463
- val = val * -1;
1464
- }
1465
-
1466
- const name = value.trend === 'total' ? value.formattedKey || value.key[0] : keys.join(highchartsRenderer.delimer);
1467
- let color = '';
1468
- if (value.trend !== 'total') {
1469
- if (index === 0 && !firstBarColor) {
1470
- color = waterfallOptions.colors.total;
1471
- firstBarColor = waterfallOptions.colors.total;
1472
- } else {
1473
- color = value.color
1474
- }
1475
- } else {
1476
- color = waterfallOptions.colors.total;
1477
- }
1478
-
1479
- resultObject.data.push({
1480
- y: val,
1481
- name: lodash.unescape(name).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
1482
- isSum: value.trend === 'total',
1483
- isTotal: value.trend === 'total',
1484
- color,
1485
- colsForTotal: value.trend === 'total' ? keys : null,
1486
- });
1487
- });
1488
- chart_series.push(resultObject);
1489
- chart_series.push(
1490
- {
1491
- name: 'Increase',
1492
- visible: false,
1493
- color: waterfallOptions.colors.increase
1494
- });
1495
-
1496
- chart_series.push(
1497
- {
1498
- name: 'Decrease',
1499
- visible: false,
1500
- color: waterfallOptions.colors.decrease
1501
- });
1502
-
1503
- return chart_series;
1504
- }
1505
-
1506
1417
  highchartsRenderer.setChartTypeBySeriesType = function (type, series) {
1507
1418
  const types = {
1508
1419
  'line-chart': 'line',
@@ -1706,7 +1617,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1706
1617
  highchartsRenderer.getDataLabelsStylesForDrillDown = function(additionOptions) {
1707
1618
  let result = highchartsRenderer.getDataLabelsOptions(additionOptions, { dataLabels: {} });
1708
1619
 
1709
- if (!result.dataLabels) return {};
1620
+ if (!result.dataLabels) return {};
1710
1621
  return {
1711
1622
  activeDataLabelStyle: {
1712
1623
  color: result.dataLabels.color,
@@ -3262,7 +3173,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3262
3173
 
3263
3174
  highchartsRenderer.ptRenderWaterfallBreakdown = function (pivotData, opts, drilldownFunc, chartType) {
3264
3175
  let chartOptions = {};
3265
- const additionOptions = opts.chartOptions
3176
+ const additionOptions = opts.chartOptions
3266
3177
  ? opts.chartOptions
3267
3178
  : highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN);
3268
3179
 
@@ -3361,122 +3272,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3361
3272
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3362
3273
  };
3363
3274
 
3364
- highchartsRenderer.ptRenderWaterfallWalkthrough = function (pivotData, opts) {
3365
- let chartOptions = {};
3366
- const waterfallOptions = opts?.walkthrough_options;
3367
- const additionOptions = opts.chartOptions
3368
- ? opts.chartOptions
3369
- : highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH);
3370
-
3371
- chartOptions.chart = {
3372
- type: 'waterfall',
3373
- zoomType: additionOptions && additionOptions.chart && additionOptions.chart.zoom_type ? additionOptions.chart.zoom_type : 'None',
3374
- };
3375
- if (disableAnimation) {
3376
- chartOptions.chart.animation = false;
3377
- }
3378
- const walkthroughFieldIsNotSet = lodash.some(pivotData.getRowKeys(), rowKey => !rowKey || lodash.isArray(rowKey) && !rowKey.length);
3379
-
3380
- chartOptions.xAxis = {
3381
- type: 'category',
3382
- crosshair: true,
3383
- min: 0,
3384
- title: {
3385
- text : additionOptions && additionOptions.axisX ? additionOptions.axisX.name : '',
3386
- },
3387
- uniqueNames: walkthroughFieldIsNotSet,
3388
- };
3389
-
3390
- highchartsRenderer.setTitleAndSubTitle(chartOptions, opts, additionOptions);
3391
-
3392
- chartOptions.yAxis = {
3393
- min: null,
3394
- max: null,
3395
- title: {
3396
- text: additionOptions && additionOptions.axisY ? additionOptions.axisY.name : '',
3397
- autoylabel: additionOptions && additionOptions.axisY ? additionOptions.axisY.autoylabel : ''
3398
- },
3399
- labels: {
3400
- formatter: highchartsRenderer.defaultValueLabelsFormatter(pivotData, opts)
3401
- },
3402
- };
3403
- if (additionOptions) {
3404
- highchartsRenderer.setYAxisMinMax(chartOptions.yAxis, additionOptions.axisY);
3405
- }
3406
-
3407
- chartOptions.tooltip = {
3408
- formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
3409
- valueDecimals: 2,
3410
- };
3411
-
3412
- highchartsRenderer.handleGridLines(additionOptions, chartOptions);
3413
-
3414
- if (lodash.get(opts, 'paletteOptions.widgetPalette', null)) {
3415
- const mc_palette = lodash.find(lodash.get(opts.paletteOptions, 'monochromePalettes', []), { selected: true });
3416
- chartOptions.colors = mc_palette ? mc_palette.colors : opts.paletteOptions.widgetPalette;
3417
- } else if (lodash.get(opts, 'paletteOptions.dashboardPalette.colors', null)) {
3418
- chartOptions.colors = opts.paletteOptions.dashboardPalette.colors;
3419
- }
3420
- chartOptions.series = highchartsRenderer
3421
- .ptCreateWaterfallWalkthroughSeries(pivotData, null, additionOptions, opts);
3422
-
3423
- chartOptions = highchartsRenderer.prepareAxisX(chartOptions, additionOptions, pivotData.getColKeys());
3424
- chartOptions.plotOptions = {
3425
- waterfall: {
3426
- pointPadding: 0.2,
3427
- borderWidth: 0,
3428
- borderRadius: 1,
3429
- lineWidth: 0,
3430
- },
3431
- series: {
3432
- animation: !disableAnimation,
3433
- cropThreshold: 1000,
3434
- dataLabels: {
3435
- allowOverlap: additionOptions && additionOptions.label ? additionOptions.label.overlap : false,
3436
- enabled: additionOptions && additionOptions.label ? additionOptions.label.show : true,
3437
- formatter: highchartsRenderer.defaultDataLabelFormatter(pivotData, opts),
3438
- style: highchartsRenderer.getDataLabelsStyle(additionOptions),
3439
- inside: false
3440
- },
3441
- events: {
3442
- legendItemClick: () => {
3443
- return false;
3444
- }
3445
- }
3446
- }
3447
- };
3448
-
3449
- if (opts.drillDownListFunc) {
3450
- chartOptions.plotOptions.series.cursor = 'pointer';
3451
- chartOptions.plotOptions.series.point = {
3452
- events: {
3453
- click: opts.drillDownListFunc
3454
- }
3455
- };
3456
- }
3457
- if (waterfallOptions.colors) {
3458
- chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, 3, false);
3459
- chartOptions.legend.useHTML = true;
3460
- chartOptions.legend.labelFormatter = function() {
3461
- const name = this.options.className ? 'Total': this.name;
3462
- const findTotal = _.find(this.options.data, {isTotal: true});
3463
- const color = findTotal?.color ? findTotal.color : this.color;
3464
- return '<span style="margin: 5px; vertical-align: middle; display:inline-block; background-color: '+ color + '; width: 12px; height: 12px; border-radius: 50%"></span><span style="color: #000; display: inline-block; margin: 5px; vertical-align: middle;">' + name + '</span>';
3465
- }
3466
-
3467
- chartOptions.legend.symbolPadding = 0;
3468
- chartOptions.legend.symbolWidth = 0;
3469
- chartOptions.legend.symbolHeight = 0;
3470
- chartOptions.legend.squareSymbol = false;
3471
- } else {
3472
- chartOptions.legend = {
3473
- enabled: false
3474
- }
3475
- }
3476
-
3477
- return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3478
- }
3479
-
3480
3275
  highchartsRenderer.formatFieldValue = function (field, value) {
3481
3276
  let currentType = '';
3482
3277
  let format = field.format;
@@ -4545,17 +4340,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4545
4340
  }
4546
4341
  };
4547
4342
 
4548
- highchartsRenderer.waterfallConstants = {
4549
- [highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN]: {
4550
- minCategoriesCount: 2,
4551
- maxCategoriesCount: 5,
4552
- },
4553
- [highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH]: {
4554
- minCategoriesCount: 2,
4555
- maxCategoriesCount: 10,
4556
- }
4557
- };
4558
-
4559
4343
  highchartsRenderer.rhPivotView = function (rowData, options, isTable = false, widget = null) {
4560
4344
  if (!rowData || !rowData) {
4561
4345
  if (options.onlyOptions) {
@@ -4564,15 +4348,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4564
4348
  return null;
4565
4349
  }
4566
4350
 
4567
- const isWaterfall = widget
4568
- && (
4569
- widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN
4570
- || widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH
4571
- );
4572
-
4573
- if (isWaterfall) {
4574
- const maxCategories = highchartsRenderer.waterfallConstants[widget.chart_type].maxCategoriesCount;
4575
- const minCategories = highchartsRenderer.waterfallConstants[widget.chart_type].minCategoriesCount;
4351
+ if (widget && widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
4352
+ const breakdownSettings = widget.options.breakdown_options.settings;
4353
+ const maxCategories = breakdownSettings.maxCategoriesCount;
4354
+ const minCategories = breakdownSettings.minCategoriesCount;
4576
4355
  const uniqueCategories = lodash.filter(
4577
4356
  lodash.uniq(
4578
4357
  lodash.map(rowData, row => row[widget.cols[0].name])
@@ -4582,8 +4361,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4582
4361
 
4583
4362
  if (uniqueCategories && (uniqueCategories.length > maxCategories || uniqueCategories.length < minCategories )) {
4584
4363
  options.error_has_occurred = true;
4585
- const isDateField = widget.cols[0].type === 'Date';
4586
- const commonMessagePart = `This chart support a selection of ${minCategories}-${maxCategories} items from the category section. `;
4587
4364
  options.error_params = {
4588
4365
  title: 'Data Conflict',
4589
4366
  text: `Please adjust your dashboard's reference date and filter selections as \
@@ -4832,25 +4609,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4832
4609
  return highchartsRenderer.getWeekNumber(dateObj);
4833
4610
  };
4834
4611
 
4835
- highchartsRenderer.check_values_not_for_convert = function (currentgraph, field_name) {
4836
- let vals_not_convert = [];
4612
+ highchartsRenderer.check_value_not_for_convert = function (currentgraph, field_name) {
4613
+ let val_not_convert = null;
4837
4614
  if (lodash.has(currentgraph, "options.chartOptions.delta_column") && currentgraph.options.chartOptions.delta_column) {
4838
4615
  let delta_options = currentgraph.options.chartOptions.delta_column;
4839
4616
  if (delta_options.field == 'series' && currentgraph.rows && currentgraph.rows[0] &&
4840
4617
  currentgraph.rows[0].name == field_name) {
4841
- vals_not_convert = [delta_options.name];
4618
+ val_not_convert = delta_options.name;
4842
4619
  } else if (delta_options.field == 'category' && currentgraph.rows && currentgraph.cols[0] &&
4843
4620
  currentgraph.cols[0].name == field_name) {
4844
- vals_not_convert = [delta_options.name];
4621
+ val_not_convert = delta_options.name;
4845
4622
  }
4846
- } else if (currentgraph.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH) {
4847
- lodash.forEach(currentgraph.options.walkthrough_options.values.walkthrough, value => {
4848
- if (value.trend === 'total') {
4849
- vals_not_convert.push(value.key[0]);
4850
- }
4851
- });
4852
4623
  }
4853
- return vals_not_convert;
4624
+ return val_not_convert;
4854
4625
  };
4855
4626
 
4856
4627
  highchartsRenderer.updateFiltersShowNames = function (filters) {
@@ -4870,8 +4641,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4870
4641
  })
4871
4642
  };
4872
4643
 
4873
- highchartsRenderer.returnRawDataValue = function (type, value, format, field_name, vals_not_for_convert) {
4874
- if (vals_not_for_convert && vals_not_for_convert.length && lodash.includes(vals_not_for_convert, value)) {
4644
+ highchartsRenderer.returnRawDataValue = function (type, value, format, field_name, val_not_for_convert) {
4645
+ if (val_not_for_convert && val_not_for_convert == value) {
4875
4646
  return value;
4876
4647
  }
4877
4648
 
@@ -5183,28 +4954,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5183
4954
  }
5184
4955
  });
5185
4956
 
5186
- // add virtual fields to rows if required
5187
- let rows = widgetOptions.rows;
5188
- if (!lodash.get(widgetOptions, 'rows.length') && widgetOptions.options.breakdown_options) {
5189
- rows = [
5190
- {
5191
- id: -1,
5192
- name: highchartsRenderer.VIRTUAL_FIELDS.WATERFALL_VARIANCE,
5193
- type: 'Text',
5194
- },
5195
- ];
5196
- }
5197
-
5198
4957
  // fill rows fields
5199
- lodash.forEach(rows, function (valObj) {
5200
- if (lodash.includes(highchartsRenderer.VIRTUAL_FIELDS, valObj.name)) {
5201
- legendFields.push(valObj);
5202
- } else {
5203
- fieldOb = lodash.find(fields, {id: valObj.id});
5204
- if (fieldOb) {
5205
- legendFields.push(fieldOb);
5206
- lodash.remove(fields, {id: fieldOb.id});
5207
- }
4958
+ lodash.forEach(widgetOptions.rows, function (valObj) {
4959
+ fieldOb = lodash.find(fields, {id: valObj.id});
4960
+ if (fieldOb) {
4961
+ legendFields.push(fieldOb);
4962
+ lodash.remove(fields, {id: fieldOb.id});
5208
4963
  }
5209
4964
  });
5210
4965
 
@@ -5331,22 +5086,71 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5331
5086
  highchartsRenderer.addTemplateDataToCalcModel = function (selectedTemplate, calcModelOptions) {
5332
5087
  highchartsRenderer.setWidgetFieldsToTemplate(selectedTemplate);
5333
5088
 
5334
- var fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplate.widget_fields);
5335
- var fieldOb;
5336
- var selectedFields = [];
5089
+ const scenarioName = 'scenario';
5090
+ const fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplate.fields);
5091
+ const fieldScenarioAlias = _.find(fields, field => (field.alias || '').toLowerCase() === scenarioName)
5092
+ const fieldScenario = _.find(fields, field => (field.name || '').toLowerCase() === scenarioName)
5093
+ const filters = calcModelOptions.config && calcModelOptions.config.filters;
5337
5094
 
5338
- // fill selected fields
5339
- lodash.forEach(calcModelOptions.fields, function (valObj) {
5340
- fieldOb = lodash.find(fields, {id: valObj.id});
5341
- if (fieldOb) {
5342
- selectedFields.push(fieldOb);
5343
- lodash.remove(fields, {id: fieldOb.id});
5095
+ const filterFields = [];
5096
+ const valueFields = [];
5097
+ const dateFields = [];
5098
+ const dataTypeFields = [];
5099
+ const dataSeriesFields = [];
5100
+
5101
+ let scenarioField = lodash.get(calcModelOptions, 'config.scenario', undefined) || fieldScenarioAlias || fieldScenario;
5102
+ let fieldOb;
5103
+
5104
+ const fillData = (fieldsArr, destinationArr) => {
5105
+ lodash.forEach(fieldsArr, function (valObj) {
5106
+ fieldOb = lodash.find(fields, { id: valObj.id });
5107
+ if (fieldOb) {
5108
+ destinationArr.push(fieldOb);
5109
+ lodash.remove(fields, { id: fieldOb.id });
5110
+ }
5111
+ });
5112
+ }
5113
+
5114
+ lodash.forEach(filters, function (filterObj) {
5115
+ fieldOb = lodash.find(fields, { id: filterObj.id });
5116
+ if (fieldOb && lodash.get(filterObj, 'values.datetype') === 'list') {
5117
+ filterObj.values = filterObj.values.val
5118
+ } else if (fieldOb && filterObj.values && filterObj.values.datetype && filterObj.values.datetype !== 'list') {
5119
+ fieldOb.values = filterObj.values;
5120
+ } else if (fieldOb && filterObj.values && filterObj.values.type === 'advanced') {
5121
+ fieldOb.values = filterObj.values;
5122
+ }
5123
+ if (fieldOb && filterObj.values && filterObj.values instanceof Array) {
5124
+ if (filterObj.is_excluded === true) {
5125
+ fieldOb.excludes = filterObj.values;
5126
+ } else {
5127
+ fieldOb.includes = filterObj.values;
5128
+ }
5129
+ }
5130
+ if (filterObj.allow_nulls && fieldOb) {
5131
+ fieldOb.allow_nulls = filterObj.allow_nulls;
5344
5132
  }
5345
5133
  });
5346
5134
 
5135
+ const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by', []);
5136
+ const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field', undefined)].filter(f => !!f);
5137
+ const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field', undefined)].filter(f => !!f);
5138
+ const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field', undefined)].filter(f => !!f);
5139
+
5140
+ fillData(storedGroupByFields, dataSeriesFields);
5141
+ fillData(storedDateFields, dateFields);
5142
+ fillData(storedAggFields, valueFields);
5143
+ fillData(storedDataTypeFields, dataTypeFields);
5144
+ fillData(filters, filterFields);
5145
+
5347
5146
  calcModelOptions.pivot = {
5348
5147
  fieldsArray: fields,
5349
- selectedFieldsArray: selectedFields
5148
+ selectedFieldsArray: dataSeriesFields,
5149
+ filtersArray: filterFields,
5150
+ scenarioField,
5151
+ dateFields,
5152
+ dataTypeFields,
5153
+ valueFields
5350
5154
  };
5351
5155
  }
5352
5156
 
@@ -5845,7 +5649,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5845
5649
  return valToReturn;
5846
5650
  };
5847
5651
 
5848
-
5652
+
5849
5653
  highchartsRenderer.getChartAxisLabel = function(type) {
5850
5654
  return highchartsRenderer.chartsTypesInfo[type] ? highchartsRenderer.chartsTypesInfo[type].axisName : CHART_AXIS_DEFAULT_LABEL;
5851
5655
  };
@@ -6680,7 +6484,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6680
6484
  value_name: 'show',
6681
6485
  default_value: true,
6682
6486
  disabled_str: '!{var}.show_out_of_x_axis && !{var}.show_out_of_data_series && !{var}.show_value && !{var}.show_x_axis && !{var}.show_data_series',
6683
- disabled_fn: (value) => !value.show_out_of_x_axis
6487
+ disabled_fn: (value) => !value.show_out_of_x_axis
6684
6488
  && !value.show_out_of_data_series
6685
6489
  && !value.show_value
6686
6490
  && !value.show_x_axis
@@ -6721,8 +6525,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6721
6525
  element_label: '[X Axis]',
6722
6526
  value_name: 'show_x_axis',
6723
6527
  default_value: true,
6724
- clickFn: (value) => value.show = value.show
6725
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6528
+ clickFn: (value) => value.show = value.show
6529
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6726
6530
  : value.show,
6727
6531
  },
6728
6532
  {
@@ -6730,8 +6534,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6730
6534
  element_label: '[Data Series]',
6731
6535
  value_name: 'show_data_series',
6732
6536
  default_value: true,
6733
- clickFn: (value) => value.show = value.show
6734
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6537
+ clickFn: (value) => value.show = value.show
6538
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6735
6539
  : value.show,
6736
6540
  },
6737
6541
  {
@@ -6739,8 +6543,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6739
6543
  element_label: 'Value',
6740
6544
  value_name: 'show_value',
6741
6545
  default_value: true,
6742
- clickFn: (value) => value.show = value.show
6743
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6546
+ clickFn: (value) => value.show = value.show
6547
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6744
6548
  : value.show,
6745
6549
  },
6746
6550
  {
@@ -6748,8 +6552,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6748
6552
  element_label: '% Out of [X Axis]',
6749
6553
  value_name: 'show_out_of_x_axis',
6750
6554
  default_value: false,
6751
- clickFn: (value) => value.show = value.show
6752
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6555
+ clickFn: (value) => value.show = value.show
6556
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6753
6557
  : value.show,
6754
6558
  },
6755
6559
  {
@@ -6757,8 +6561,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6757
6561
  element_label: '% Out of [Data Series]',
6758
6562
  value_name: 'show_out_of_data_series',
6759
6563
  default_value: false,
6760
- clickFn: (value) => value.show = value.show
6761
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6564
+ clickFn: (value) => value.show = value.show
6565
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6762
6566
  : value.show,
6763
6567
  },
6764
6568
  ]
@@ -6932,16 +6736,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6932
6736
  value_name: 'name',
6933
6737
  element_label: 'Name',
6934
6738
  default_value: '_Variance'
6935
- }, {
6936
- element_type: 'input',
6937
- value_name: 'formula',
6938
- element_label: 'Formula',
6939
- default_value: 'x2-x1'
6940
6739
  }, {
6941
6740
  element_type: 'input',
6942
- value_name: 'color',
6943
- element_label: 'Color',
6944
- default_value: ''
6741
+ value_name: 'formula',
6742
+ element_label: 'Formula',
6743
+ default_value: 'x2-x1'
6744
+ }, {
6745
+ element_type: 'input',
6746
+ value_name: 'color',
6747
+ element_label: 'Color',
6748
+ default_value: ''
6945
6749
  }, {
6946
6750
  element_type: 'radio',
6947
6751
  value_name: 'chart',
@@ -7064,17 +6868,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7064
6868
  axisTooltipDescription: 'The category (usually an independent variable) is shown on the x-axis and should be between 2 to 5 total columns. ',
7065
6869
  legendTooltipTitle: 'Drag one field to further configure your x-axis.',
7066
6870
  legendTooltipDescription: 'The breakdown subdivides the chart by a category field for further analysis of what’s contributing to the increase or decrease.',
7067
- },
7068
- [highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH]: {
7069
- name: 'Waterfall Walkthrough Chart ',
7070
- label: 'Waterfall Walkthrough Chart ',
7071
- title: 'TODO: add text',
7072
- description: 'TODO: add text',
7073
- axisName: 'Category',
7074
- startedMessage: 'TODO: add text',
7075
- axisTooltipTitle: 'TODO: add text',
7076
- legendTooltipTitle: 'TODO: add text',
7077
- },
6871
+ },
7078
6872
  'combo-chart': {
7079
6873
  name: 'Combo Chart ',
7080
6874
  label: 'Combo Chart ',
@@ -7730,24 +7524,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7730
7524
  highchartsRenderer.suboptions["legends"],
7731
7525
  ]
7732
7526
  },
7733
- {
7734
- type: highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH,
7735
- name: highchartsRenderer.chartsTypesInfo[highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH].name,
7736
- class: 'google-visualization-charteditor-thumbs-columnchart',
7737
- render: highchartsRenderer.ptRenderWaterfallWalkthrough,
7738
- suboptions: [
7739
- highchartsRenderer.suboptions["axisX"],
7740
- highchartsRenderer.suboptions["tooltips"],
7741
- highchartsRenderer.suboptions["label"],
7742
- highchartsRenderer.suboptions["subtitle"],
7743
- highchartsRenderer.suboptions["widget_library"],
7744
- highchartsRenderer.suboptions["chart"],
7745
- highchartsRenderer.suboptions["negative_number_format"],
7746
- highchartsRenderer.suboptions["advanced"],
7747
- highchartsRenderer.suboptions["legends"],
7748
- ],
7749
- hidden: true,
7750
- },
7751
7527
  ]
7752
7528
  },
7753
7529
  ];
@@ -7904,7 +7680,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7904
7680
  _.forEach(Object.keys(dates), key => {
7905
7681
  const dateConfiguration = dates[key];
7906
7682
  const timestamp = dateConfiguration.timestamp;
7907
- if (timestamp) {
7683
+ if (timestamp) {
7908
7684
  const dateTzOffsetInSeconds = new Date(timestamp * 1000).getTimezoneOffset() * 60;
7909
7685
  dateConfiguration.displayedValue = new Date((timestamp + dateTzOffsetInSeconds) * 1000)
7910
7686
  .toLocaleDateString();
@@ -8200,10 +7976,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8200
7976
  };
8201
7977
 
8202
7978
  highchartsRenderer.createDateFromString = function (dateString, format) {
8203
- if (!(format && highchartsRenderer.isDateFormat(dateString, format) || highchartsRenderer.isDate(dateString))) {
7979
+ if ((format && !highchartsRenderer.isDateFormat(dateString, format)) || !highchartsRenderer.isDate(dateString)) {
8204
7980
  return null;
8205
7981
  }
8206
- const utcDate = format
7982
+ const utcDate = format
8207
7983
  ? moment_lib.utc(dateString, format, true)
8208
7984
  : moment_lib.utc(dateString);
8209
7985
  return utcDate.startOf('day').unix();
@@ -8221,7 +7997,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8221
7997
  }
8222
7998
 
8223
7999
  let filters = [];
8224
-
8000
+
8225
8001
  if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
8226
8002
  const colFilter = highchartsRenderer.createFilterObject(widget.cols[0]);
8227
8003
  const labels = [];
@@ -8249,7 +8025,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8249
8025
  col_value,
8250
8026
  highchartsRenderer.getDateFieldFormat(widget, widget.cols[index])
8251
8027
  );
8252
-
8028
+
8253
8029
  if ($.isEmptyObject(datetrange)) {
8254
8030
  return;
8255
8031
  }
@@ -8354,7 +8130,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8354
8130
  filter.is_excluded = false;
8355
8131
  } else {
8356
8132
  filter = highchartsRenderer.createDrillDownFilterObject(widget, widget.cols[0], colKey[0]);
8357
- filters.push(filter);
8358
8133
  }
8359
8134
  filter.values = [];
8360
8135
  for (let i = 0; i < colKey.length; i++) {
@@ -8492,7 +8267,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8492
8267
  var data = res;
8493
8268
 
8494
8269
  lodash.forEach(datesFields, function (row) {
8495
- row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
8270
+ row.val_not_convert = highchartsRenderer.check_value_not_for_convert(widget, row.name);
8496
8271
  });
8497
8272
 
8498
8273
  if (datesFields.length > 0) {
@@ -8898,14 +8673,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8898
8673
  return rightPosition;
8899
8674
  case 'none':
8900
8675
  return none;
8901
- }
8902
- } else if (isLine) {
8903
- return useNewUx ? leftPosition : rightPosition;
8904
- } else if (isPie) {
8905
- return useNewUx ? rightPosition : topPosition;
8906
8676
  }
8677
+ } else if (isLine) {
8678
+ return useNewUx ? leftPosition : rightPosition;
8679
+ } else if (isPie) {
8680
+ return useNewUx ? rightPosition : topPosition;
8681
+ }
8907
8682
 
8908
- return useNewUx ? topPosition : bottomPosition;
8683
+ return useNewUx ? topPosition : bottomPosition;
8909
8684
  }
8910
8685
 
8911
8686
  highchartsRenderer.setYAxisMinMax = function (yAxis, axisYOptions) {
@@ -8920,7 +8695,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8920
8695
  }
8921
8696
 
8922
8697
  highchartsRenderer.getDateFieldFormat = function(widget, dateField) {
8923
- const aggregationConfig = widget.options && widget.options.date_aggregation_configs
8698
+ const aggregationConfig = widget.options && widget.options.date_aggregation_configs
8924
8699
  ? _.find(widget.options.date_aggregation_configs, { field_id: dateField.id })
8925
8700
  : null;
8926
8701