@datarailsshared/dr_renderer 1.2.236 → 1.2.238-dragons
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 +406 -65
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const SERIES_CLASSNAMES = {
|
|
2
2
|
WATERFALL_BREAKDOWN: 'waterfallBreakdown',
|
|
3
|
+
WATERFALL_WALKTHROUGH: 'waterfallWalkthrough',
|
|
3
4
|
TOTAL_SERIES: 'totalSeries',
|
|
4
5
|
TREND_SERIES: 'trendSeries',
|
|
5
6
|
};
|
|
@@ -82,6 +83,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
82
83
|
KPI_WIDGET: 'kpi-widget',
|
|
83
84
|
TEXT_WIDGET: 'text-widget',
|
|
84
85
|
WATERFALL_BREAKDOWN: 'waterfall-chart-breakdown',
|
|
86
|
+
WATERFALL_WALKTHROUGH: 'waterfall-chart-walkthrough',
|
|
85
87
|
PUBLISHED_ITEM: 'published_item',
|
|
86
88
|
RICH_TEXT: 'rich_text',
|
|
87
89
|
EXCEL_VIEWER: 'excel_viewer',
|
|
@@ -486,7 +488,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
486
488
|
rows = [];
|
|
487
489
|
}
|
|
488
490
|
|
|
489
|
-
var cols = this.key;
|
|
491
|
+
var cols = lodash.get(this, 'point.options.colsForTotal') || this.key;
|
|
490
492
|
if (typeof (cols) == 'object' && cols.name) {
|
|
491
493
|
cols = cols.name;
|
|
492
494
|
}
|
|
@@ -619,6 +621,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
619
621
|
|
|
620
622
|
var func = function () {
|
|
621
623
|
const isWaterfallBreakdown = this.series.options.className === SERIES_CLASSNAMES.WATERFALL_BREAKDOWN;
|
|
624
|
+
const isWaterfallWalkthrough = this.series.options.className === SERIES_CLASSNAMES.WATERFALL_WALKTHROUGH;
|
|
622
625
|
const isTrendSeries = this.series.options.className === SERIES_CLASSNAMES.TREND_SERIES;
|
|
623
626
|
|
|
624
627
|
var y = parseFloat(this.y);
|
|
@@ -633,7 +636,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
633
636
|
|| isTrendSeries) {
|
|
634
637
|
rows = [];
|
|
635
638
|
}
|
|
636
|
-
|
|
639
|
+
|
|
640
|
+
var cols = lodash.get(this, 'point.options.colsForTotal') || this.key;
|
|
637
641
|
if (!cols && is_drill_down_pie) {
|
|
638
642
|
cols = this.name;
|
|
639
643
|
}
|
|
@@ -648,7 +652,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
648
652
|
if (variant_name && rows && rows[0] && variant_name == rows[0]) {
|
|
649
653
|
rows[0] = variant_name_default_name;
|
|
650
654
|
}
|
|
651
|
-
|
|
652
655
|
try {
|
|
653
656
|
if (is_drill_down_pie && !highchartsRenderer.selfStartsWith(series_name,"Series ")) {
|
|
654
657
|
let temp = cols;
|
|
@@ -656,7 +659,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
656
659
|
rows = temp;
|
|
657
660
|
}
|
|
658
661
|
|
|
659
|
-
var category_text = `<span style="font-weight: bold;"
|
|
662
|
+
var category_text = `<span style="font-weight: bold;">
|
|
663
|
+
${ lodash.get(this, 'point.options.colsForTotal') ? isWaterfallWalkthrough ? this.key : cols[0] : cols } ${ isWaterfallBreakdown ? ': ' : ' ' }
|
|
664
|
+
</span>`;
|
|
660
665
|
if (this.category) {
|
|
661
666
|
category_text = '';
|
|
662
667
|
}
|
|
@@ -680,7 +685,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
680
685
|
let formatted_value_to_return = $.pivotUtilities.getFormattedNumber(y, null, opts);
|
|
681
686
|
if (aggr.value() || isWaterfallBreakdown) {
|
|
682
687
|
formatted_value_to_return = $.pivotUtilities.getFormattedNumber(
|
|
683
|
-
isWaterfallBreakdown || isTrendSeries ? y : aggr.value(), aggr, opts
|
|
688
|
+
isWaterfallBreakdown || isWaterfallWalkthrough || isTrendSeries ? y : aggr.value(), aggr, opts
|
|
684
689
|
);
|
|
685
690
|
}
|
|
686
691
|
|
|
@@ -1037,6 +1042,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1037
1042
|
if (row_n_value && row_n_value.length > 0) {
|
|
1038
1043
|
ob.name = row_n_value.join(highchartsRenderer.delimer).replace('DR_Others', othersName);
|
|
1039
1044
|
}
|
|
1045
|
+
|
|
1040
1046
|
lodash.forEach(col_n_keys, function (col_n_value, index) {
|
|
1041
1047
|
var agg = pivotData.getAggregator(row_n_value, col_n_value);
|
|
1042
1048
|
var val = agg.value();
|
|
@@ -1253,6 +1259,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1253
1259
|
if (opts.trendLine) {
|
|
1254
1260
|
const a = ((ySum * squareXSum) - (xSum * xySum)) / ((n * squareXSum) - (xSum * xSum));
|
|
1255
1261
|
const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
|
|
1262
|
+
|
|
1256
1263
|
const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
|
|
1257
1264
|
trendSeries.className = 'trendSeries';
|
|
1258
1265
|
trendSeries.name = highchartsRenderer.getTrendSeriesName(trendSeries);
|
|
@@ -1263,6 +1270,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1263
1270
|
if (colors && colors[i]) {
|
|
1264
1271
|
trendSeries.color = colors[i];
|
|
1265
1272
|
}
|
|
1273
|
+
|
|
1266
1274
|
trendSerieses.push(trendSeries);
|
|
1267
1275
|
}
|
|
1268
1276
|
i++;
|
|
@@ -1279,6 +1287,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1279
1287
|
}
|
|
1280
1288
|
|
|
1281
1289
|
let weights = { line: 2,spline: 3 ,area:-2, areaspline: -1, scatter:4, column: 1 };
|
|
1290
|
+
|
|
1282
1291
|
if (opts.comboOptions && lodash.includes(chartType,'combo') && !lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
|
|
1283
1292
|
chart_series.forEach((series, seriesIndex) => {
|
|
1284
1293
|
const savedSeriesOption = lodash.find(opts.comboOptions.seriesOptions, {series: series.name});
|
|
@@ -1413,6 +1422,86 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1413
1422
|
return chart_series;
|
|
1414
1423
|
}
|
|
1415
1424
|
|
|
1425
|
+
highchartsRenderer.ptCreateWaterfallWalkthroughSeries = function (pivotData, onlyNumbers, additionOptions, opts) {
|
|
1426
|
+
const waterfallOptions = opts.walkthrough_options;
|
|
1427
|
+
const chart_series = [];
|
|
1428
|
+
let resultObject = {
|
|
1429
|
+
data: [],
|
|
1430
|
+
dataLabels: {
|
|
1431
|
+
allowOverlap: additionOptions && additionOptions.label ? additionOptions.label.overlap : false,
|
|
1432
|
+
enabled: additionOptions && additionOptions.label ? additionOptions.label.show : true,
|
|
1433
|
+
formatter: highchartsRenderer.defaultDataLabelFormatter(pivotData, {'chartOptions': additionOptions, total_value_options: opts.total_value_options}),
|
|
1434
|
+
style: highchartsRenderer.getDataLabelsStyle(additionOptions),
|
|
1435
|
+
},
|
|
1436
|
+
upColor: waterfallOptions.colors.increase,
|
|
1437
|
+
color: waterfallOptions.colors.decrease,
|
|
1438
|
+
className: SERIES_CLASSNAMES.WATERFALL_WALKTHROUGH
|
|
1439
|
+
};
|
|
1440
|
+
resultObject = highchartsRenderer.getDataLabelsOptions(additionOptions, resultObject);
|
|
1441
|
+
lodash.forEach(waterfallOptions.values.walkthrough, function(value, index) {
|
|
1442
|
+
|
|
1443
|
+
let keys = [];
|
|
1444
|
+
if (value.trend === 'total') {
|
|
1445
|
+
keys = ['Total'];
|
|
1446
|
+
} else {
|
|
1447
|
+
_.forEach(value.key, (item) => {
|
|
1448
|
+
const findKeyByValue = Object.keys(pivotData.dateValuesDictionary || {}).find(key => pivotData.dateValuesDictionary[key] === item);
|
|
1449
|
+
keys.push(findKeyByValue ? findKeyByValue : item);
|
|
1450
|
+
})
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
const agg = pivotData.getAggregator([], keys);
|
|
1454
|
+
let val = agg.value();
|
|
1455
|
+
|
|
1456
|
+
if (val != null && $.isNumeric(val)) {
|
|
1457
|
+
val = parseFloat(val);
|
|
1458
|
+
} else if (onlyNumbers) {
|
|
1459
|
+
val = NaN;
|
|
1460
|
+
} else {
|
|
1461
|
+
val = 0;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
if (value.trend === 'decrease') {
|
|
1465
|
+
val = val * -1;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
const name = value.trend === 'total' ? value.formattedKey || value.key[0] : keys.join(highchartsRenderer.delimer);
|
|
1469
|
+
let color = '';
|
|
1470
|
+
if (value.color) {
|
|
1471
|
+
color = value.color;
|
|
1472
|
+
} else {
|
|
1473
|
+
if (value.trend === 'total') color = waterfallOptions.colors.total;
|
|
1474
|
+
if (value.trend === 'decrease') color = waterfallOptions.colors.decrease;
|
|
1475
|
+
if (value.trend === 'increase') color = waterfallOptions.colors.increase;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
resultObject.data.push({
|
|
1479
|
+
y: val,
|
|
1480
|
+
name: lodash.unescape(name).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
|
|
1481
|
+
isSum: value.trend === 'total',
|
|
1482
|
+
isTotal: value.trend === 'total',
|
|
1483
|
+
color,
|
|
1484
|
+
colsForTotal: value.trend === 'total' ? keys : null,
|
|
1485
|
+
});
|
|
1486
|
+
});
|
|
1487
|
+
chart_series.push(resultObject);
|
|
1488
|
+
chart_series.push(
|
|
1489
|
+
{
|
|
1490
|
+
name: 'Positive',
|
|
1491
|
+
visible: false,
|
|
1492
|
+
color: waterfallOptions.colors.increase
|
|
1493
|
+
});
|
|
1494
|
+
|
|
1495
|
+
chart_series.push(
|
|
1496
|
+
{
|
|
1497
|
+
name: 'Negative',
|
|
1498
|
+
visible: false,
|
|
1499
|
+
color: waterfallOptions.colors.decrease
|
|
1500
|
+
});
|
|
1501
|
+
|
|
1502
|
+
return chart_series;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1416
1505
|
highchartsRenderer.setChartTypeBySeriesType = function (type, series) {
|
|
1417
1506
|
const types = {
|
|
1418
1507
|
'line-chart': 'line',
|
|
@@ -3271,6 +3360,121 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3271
3360
|
return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
|
|
3272
3361
|
};
|
|
3273
3362
|
|
|
3363
|
+
highchartsRenderer.ptRenderWaterfallWalkthrough = function (pivotData, opts) {
|
|
3364
|
+
let chartOptions = {};
|
|
3365
|
+
const waterfallOptions = opts?.walkthrough_options;
|
|
3366
|
+
const additionOptions = opts.chartOptions
|
|
3367
|
+
? opts.chartOptions
|
|
3368
|
+
: highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH);
|
|
3369
|
+
|
|
3370
|
+
chartOptions.chart = {
|
|
3371
|
+
type: 'waterfall',
|
|
3372
|
+
zoomType: additionOptions && additionOptions.chart && additionOptions.chart.zoom_type ? additionOptions.chart.zoom_type : 'None',
|
|
3373
|
+
};
|
|
3374
|
+
if (disableAnimation) {
|
|
3375
|
+
chartOptions.chart.animation = false;
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3378
|
+
chartOptions.xAxis = {
|
|
3379
|
+
type: 'category',
|
|
3380
|
+
crosshair: true,
|
|
3381
|
+
min: 0,
|
|
3382
|
+
title: {
|
|
3383
|
+
text : additionOptions && additionOptions.axisX ? additionOptions.axisX.name : '',
|
|
3384
|
+
},
|
|
3385
|
+
uniqueNames: false,
|
|
3386
|
+
};
|
|
3387
|
+
|
|
3388
|
+
highchartsRenderer.setTitleAndSubTitle(chartOptions, opts, additionOptions);
|
|
3389
|
+
|
|
3390
|
+
chartOptions.yAxis = {
|
|
3391
|
+
min: null,
|
|
3392
|
+
max: null,
|
|
3393
|
+
title: {
|
|
3394
|
+
text: additionOptions && additionOptions.axisY ? additionOptions.axisY.name : '',
|
|
3395
|
+
autoylabel: additionOptions && additionOptions.axisY ? additionOptions.axisY.autoylabel : ''
|
|
3396
|
+
},
|
|
3397
|
+
labels: {
|
|
3398
|
+
formatter: highchartsRenderer.defaultValueLabelsFormatter(pivotData, opts)
|
|
3399
|
+
},
|
|
3400
|
+
};
|
|
3401
|
+
if (additionOptions) {
|
|
3402
|
+
highchartsRenderer.setYAxisMinMax(chartOptions.yAxis, additionOptions.axisY);
|
|
3403
|
+
}
|
|
3404
|
+
|
|
3405
|
+
chartOptions.tooltip = {
|
|
3406
|
+
formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
|
|
3407
|
+
valueDecimals: 2,
|
|
3408
|
+
};
|
|
3409
|
+
|
|
3410
|
+
highchartsRenderer.handleGridLines(additionOptions, chartOptions);
|
|
3411
|
+
|
|
3412
|
+
if (lodash.get(opts, 'paletteOptions.widgetPalette', null)) {
|
|
3413
|
+
const mc_palette = lodash.find(lodash.get(opts.paletteOptions, 'monochromePalettes', []), { selected: true });
|
|
3414
|
+
chartOptions.colors = mc_palette ? mc_palette.colors : opts.paletteOptions.widgetPalette;
|
|
3415
|
+
} else if (lodash.get(opts, 'paletteOptions.dashboardPalette.colors', null)) {
|
|
3416
|
+
chartOptions.colors = opts.paletteOptions.dashboardPalette.colors;
|
|
3417
|
+
}
|
|
3418
|
+
chartOptions.series = highchartsRenderer
|
|
3419
|
+
.ptCreateWaterfallWalkthroughSeries(pivotData, null, additionOptions, opts);
|
|
3420
|
+
|
|
3421
|
+
chartOptions = highchartsRenderer.prepareAxisX(chartOptions, additionOptions, pivotData.getColKeys());
|
|
3422
|
+
chartOptions.plotOptions = {
|
|
3423
|
+
waterfall: {
|
|
3424
|
+
pointPadding: 0.2,
|
|
3425
|
+
borderWidth: 0,
|
|
3426
|
+
borderRadius: 1,
|
|
3427
|
+
lineWidth: 0,
|
|
3428
|
+
},
|
|
3429
|
+
series: {
|
|
3430
|
+
animation: !disableAnimation,
|
|
3431
|
+
cropThreshold: 1000,
|
|
3432
|
+
dataLabels: {
|
|
3433
|
+
allowOverlap: additionOptions && additionOptions.label ? additionOptions.label.overlap : false,
|
|
3434
|
+
enabled: additionOptions && additionOptions.label ? additionOptions.label.show : true,
|
|
3435
|
+
formatter: highchartsRenderer.defaultDataLabelFormatter(pivotData, opts),
|
|
3436
|
+
style: highchartsRenderer.getDataLabelsStyle(additionOptions),
|
|
3437
|
+
inside: false
|
|
3438
|
+
},
|
|
3439
|
+
events: {
|
|
3440
|
+
legendItemClick: () => {
|
|
3441
|
+
return false;
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
};
|
|
3446
|
+
|
|
3447
|
+
if (opts.drillDownListFunc) {
|
|
3448
|
+
chartOptions.plotOptions.series.cursor = 'pointer';
|
|
3449
|
+
chartOptions.plotOptions.series.point = {
|
|
3450
|
+
events: {
|
|
3451
|
+
click: opts.drillDownListFunc
|
|
3452
|
+
}
|
|
3453
|
+
};
|
|
3454
|
+
}
|
|
3455
|
+
if (waterfallOptions.colors) {
|
|
3456
|
+
chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, 3, false);
|
|
3457
|
+
chartOptions.legend.useHTML = true;
|
|
3458
|
+
chartOptions.legend.labelFormatter = function() {
|
|
3459
|
+
const name = this.options.className ? 'Total': this.name;
|
|
3460
|
+
const findTotal = _.find(this.options.data, {isTotal: true});
|
|
3461
|
+
const color = findTotal?.color ? findTotal.color : this.color;
|
|
3462
|
+
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>';
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
chartOptions.legend.symbolPadding = 0;
|
|
3466
|
+
chartOptions.legend.symbolWidth = 0;
|
|
3467
|
+
chartOptions.legend.symbolHeight = 0;
|
|
3468
|
+
chartOptions.legend.squareSymbol = false;
|
|
3469
|
+
} else {
|
|
3470
|
+
chartOptions.legend = {
|
|
3471
|
+
enabled: false
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
|
|
3475
|
+
return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
|
|
3476
|
+
}
|
|
3477
|
+
|
|
3274
3478
|
highchartsRenderer.formatFieldValue = function (field, value) {
|
|
3275
3479
|
let currentType = '';
|
|
3276
3480
|
let format = field.format;
|
|
@@ -4339,6 +4543,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4339
4543
|
}
|
|
4340
4544
|
};
|
|
4341
4545
|
|
|
4546
|
+
highchartsRenderer.waterfallConstants = {
|
|
4547
|
+
[highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN]: {
|
|
4548
|
+
minCategoriesCount: 2,
|
|
4549
|
+
maxCategoriesCount: 5,
|
|
4550
|
+
},
|
|
4551
|
+
[highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH]: {
|
|
4552
|
+
minCategoriesCount: 2,
|
|
4553
|
+
maxCategoriesCount: 10,
|
|
4554
|
+
}
|
|
4555
|
+
};
|
|
4556
|
+
|
|
4342
4557
|
highchartsRenderer.rhPivotView = function (rowData, options, isTable = false, widget = null) {
|
|
4343
4558
|
if (!rowData || !rowData) {
|
|
4344
4559
|
if (options.onlyOptions) {
|
|
@@ -4347,16 +4562,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4347
4562
|
return null;
|
|
4348
4563
|
}
|
|
4349
4564
|
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
)
|
|
4565
|
+
const isWalktrough = lodash.get(widget, 'chart_type') === highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH;
|
|
4566
|
+
const isBreakdown = lodash.get(widget, 'chart_type')=== highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN;
|
|
4567
|
+
const isWaterfall = isWalktrough || isBreakdown;
|
|
4568
|
+
|
|
4569
|
+
if (isWaterfall) {
|
|
4570
|
+
const maxCategories = highchartsRenderer.waterfallConstants[widget.chart_type].maxCategoriesCount;
|
|
4571
|
+
const minCategories = highchartsRenderer.waterfallConstants[widget.chart_type].minCategoriesCount;
|
|
4572
|
+
let uniqueCategories = [];
|
|
4573
|
+
|
|
4574
|
+
if (isBreakdown) {
|
|
4575
|
+
uniqueCategories = lodash.filter(
|
|
4576
|
+
lodash.uniq(
|
|
4577
|
+
lodash.map(rowData, row => row[widget.cols[0].name])
|
|
4578
|
+
),
|
|
4579
|
+
value => !!value
|
|
4580
|
+
);
|
|
4581
|
+
} else {
|
|
4582
|
+
uniqueCategories = lodash.filter(
|
|
4583
|
+
lodash.get(widget, 'options.walkthrough_options.values.walkthrough'),
|
|
4584
|
+
(category) => category.trend !== 'total'
|
|
4585
|
+
);
|
|
4586
|
+
}
|
|
4360
4587
|
|
|
4361
4588
|
if (uniqueCategories && (uniqueCategories.length > maxCategories || uniqueCategories.length < minCategories )) {
|
|
4362
4589
|
options.error_has_occurred = true;
|
|
@@ -4608,19 +4835,25 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4608
4835
|
return highchartsRenderer.getWeekNumber(dateObj);
|
|
4609
4836
|
};
|
|
4610
4837
|
|
|
4611
|
-
highchartsRenderer.
|
|
4612
|
-
let
|
|
4838
|
+
highchartsRenderer.check_values_not_for_convert = function (currentgraph, field_name) {
|
|
4839
|
+
let vals_not_convert = [];
|
|
4613
4840
|
if (lodash.has(currentgraph, "options.chartOptions.delta_column") && currentgraph.options.chartOptions.delta_column) {
|
|
4614
4841
|
let delta_options = currentgraph.options.chartOptions.delta_column;
|
|
4615
4842
|
if (delta_options.field == 'series' && currentgraph.rows && currentgraph.rows[0] &&
|
|
4616
4843
|
currentgraph.rows[0].name == field_name) {
|
|
4617
|
-
|
|
4844
|
+
vals_not_convert = [delta_options.name];
|
|
4618
4845
|
} else if (delta_options.field == 'category' && currentgraph.rows && currentgraph.cols[0] &&
|
|
4619
4846
|
currentgraph.cols[0].name == field_name) {
|
|
4620
|
-
|
|
4847
|
+
vals_not_convert = [delta_options.name];
|
|
4621
4848
|
}
|
|
4849
|
+
} else if (currentgraph.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH) {
|
|
4850
|
+
lodash.forEach(currentgraph.options.walkthrough_options.values.walkthrough, value => {
|
|
4851
|
+
if (value.trend === 'total') {
|
|
4852
|
+
vals_not_convert.push(value.key[0]);
|
|
4853
|
+
}
|
|
4854
|
+
});
|
|
4622
4855
|
}
|
|
4623
|
-
return
|
|
4856
|
+
return vals_not_convert;
|
|
4624
4857
|
};
|
|
4625
4858
|
|
|
4626
4859
|
highchartsRenderer.updateFiltersShowNames = function (filters) {
|
|
@@ -4640,8 +4873,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4640
4873
|
})
|
|
4641
4874
|
};
|
|
4642
4875
|
|
|
4643
|
-
highchartsRenderer.returnRawDataValue = function (type, value, format, field_name,
|
|
4644
|
-
if (
|
|
4876
|
+
highchartsRenderer.returnRawDataValue = function (type, value, format, field_name, vals_not_for_convert) {
|
|
4877
|
+
if (vals_not_for_convert && vals_not_for_convert.length && lodash.includes(vals_not_for_convert, value)) {
|
|
4645
4878
|
return value;
|
|
4646
4879
|
}
|
|
4647
4880
|
|
|
@@ -5100,34 +5333,104 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5100
5333
|
|
|
5101
5334
|
highchartsRenderer.addTemplateDataToCalcModel = function (selectedTemplate, calcModelOptions) {
|
|
5102
5335
|
highchartsRenderer.setWidgetFieldsToTemplate(selectedTemplate);
|
|
5103
|
-
|
|
5104
|
-
const scenarioName = 'scenario';
|
|
5105
5336
|
const fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplate.fields);
|
|
5106
|
-
const fieldScenarioAlias = _.find(fields, field => (field.alias || '').toLowerCase() === scenarioName)
|
|
5107
|
-
const fieldScenario = _.find(fields, field => (field.name || '').toLowerCase() === scenarioName)
|
|
5108
|
-
const filters = calcModelOptions.config && calcModelOptions.config.filters;
|
|
5109
|
-
|
|
5110
|
-
const filterFields = [];
|
|
5111
|
-
const valueFields = [];
|
|
5112
|
-
const dateFields = [];
|
|
5113
|
-
const dataTypeFields = [];
|
|
5114
|
-
const dataSeriesFields = [];
|
|
5115
5337
|
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
const fillData = (fieldsArr, destinationArr) => {
|
|
5338
|
+
const fillData = (fieldsArr, ignoreFieldsIdToRemove = []) => {
|
|
5339
|
+
const destinationArr = [];
|
|
5120
5340
|
lodash.forEach(fieldsArr, function (valObj) {
|
|
5121
|
-
fieldOb = lodash.find(fields, { id: valObj.id });
|
|
5341
|
+
const fieldOb = lodash.find(fields, { id: valObj.id });
|
|
5122
5342
|
if (fieldOb) {
|
|
5123
5343
|
destinationArr.push(fieldOb);
|
|
5124
|
-
lodash.remove(fields, { id: fieldOb.id });
|
|
5344
|
+
!lodash.includes(ignoreFieldsIdToRemove, fieldOb.id) && lodash.remove(fields, { id: fieldOb.id });
|
|
5125
5345
|
}
|
|
5126
5346
|
});
|
|
5347
|
+
|
|
5348
|
+
return destinationArr;
|
|
5127
5349
|
}
|
|
5128
5350
|
|
|
5351
|
+
const canAssignPredefinedField = (() => {
|
|
5352
|
+
const assignedFields = {};
|
|
5353
|
+
|
|
5354
|
+
return function (predefinedData, type, field, bindValue, oppositeValue) {
|
|
5355
|
+
if (!assignedFields[type]) {
|
|
5356
|
+
assignedFields[type] = [];
|
|
5357
|
+
}
|
|
5358
|
+
|
|
5359
|
+
const isFieldMatch = predefinedData.regex.test(field[bindValue] || '');
|
|
5360
|
+
|
|
5361
|
+
const isFieldTypeCorrect = predefinedData.allowedFieldTypes
|
|
5362
|
+
? lodash.includes(predefinedData.allowedFieldTypes, field.type) : true;
|
|
5363
|
+
|
|
5364
|
+
const isFieldAssigned = assignedFields[type].includes(field[bindValue].toLowerCase())
|
|
5365
|
+
|| assignedFields[type].includes(field[oppositeValue].toLowerCase());
|
|
5366
|
+
|
|
5367
|
+
if (!(isFieldMatch && isFieldTypeCorrect)) return false;
|
|
5368
|
+
|
|
5369
|
+
const loweredFieldValue = field[bindValue].toLowerCase();
|
|
5370
|
+
assignedFields[type].push(loweredFieldValue, loweredFieldValue.replaceAll('_', ' '));
|
|
5371
|
+
|
|
5372
|
+
return !isFieldAssigned;
|
|
5373
|
+
}
|
|
5374
|
+
})();
|
|
5375
|
+
|
|
5376
|
+
const reportingMonthRegex = /reporting[_\s]month/i;
|
|
5377
|
+
|
|
5378
|
+
const predefinedField = {
|
|
5379
|
+
value: {
|
|
5380
|
+
regex: /posting[_\s]amount/i,
|
|
5381
|
+
allowedFieldTypes: ['Float', 'Integer'],
|
|
5382
|
+
fields: [],
|
|
5383
|
+
},
|
|
5384
|
+
dataType: {
|
|
5385
|
+
regex: /data[_\s]type[_\s]by/i,
|
|
5386
|
+
allowedFieldTypes: ['Text'],
|
|
5387
|
+
fields: [],
|
|
5388
|
+
},
|
|
5389
|
+
date: {
|
|
5390
|
+
regex: reportingMonthRegex,
|
|
5391
|
+
allowedFieldTypes: ['Date'],
|
|
5392
|
+
fields: [],
|
|
5393
|
+
},
|
|
5394
|
+
filters: {
|
|
5395
|
+
isMultipleFields: true,
|
|
5396
|
+
regex: /^(scenario|DR_ACC_L0)$/i,
|
|
5397
|
+
fields: [],
|
|
5398
|
+
},
|
|
5399
|
+
dataSeries: {
|
|
5400
|
+
isMultipleFields: true,
|
|
5401
|
+
regex: /^(scenario|account[_\s]full|entity|intercompany|posting[_\s]currency|reporting[_\s]currency|report[_\s]field|USER_TO_DR_ACC_KEY|USER_TO_DR_KPI_KEY)$/i,
|
|
5402
|
+
fields: [],
|
|
5403
|
+
},
|
|
5404
|
+
};
|
|
5405
|
+
|
|
5406
|
+
if (!lodash.get(calcModelOptions, 'config', false)) {
|
|
5407
|
+
/**
|
|
5408
|
+
* alias stronger than name (order in array is important)
|
|
5409
|
+
* Firstly we try to get predefined field by aliases and then fill in by names
|
|
5410
|
+
* */
|
|
5411
|
+
const fieldsDataQueueConfig = [
|
|
5412
|
+
{ value: 'alias', opposite: 'name' },
|
|
5413
|
+
{ value: 'name', opposite: 'alias' }
|
|
5414
|
+
];
|
|
5415
|
+
|
|
5416
|
+
for (const key in predefinedField) {
|
|
5417
|
+
lodash.forEach(fieldsDataQueueConfig, ({value, opposite}) => {
|
|
5418
|
+
const ignoredFields = predefinedField[key].ignoreAssignedFields;
|
|
5419
|
+
const result = predefinedField[key].isMultipleFields
|
|
5420
|
+
? lodash.filter(fields, field => canAssignPredefinedField(predefinedField[key], key, field, value, opposite, ignoredFields))
|
|
5421
|
+
: [lodash.find(fields, field => canAssignPredefinedField(predefinedField[key], key, field, value, opposite, ignoredFields))].filter(f => !!f);
|
|
5422
|
+
|
|
5423
|
+
if (result && result.length) {
|
|
5424
|
+
predefinedField[key].fields.push(...result);
|
|
5425
|
+
}
|
|
5426
|
+
});
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
|
|
5430
|
+
const filters = lodash.get(calcModelOptions, 'config.filters', predefinedField.filters.fields);
|
|
5431
|
+
|
|
5129
5432
|
lodash.forEach(filters, function (filterObj) {
|
|
5130
|
-
fieldOb = lodash.find(fields, { id: filterObj.id });
|
|
5433
|
+
const fieldOb = lodash.find(fields, { id: filterObj.id });
|
|
5131
5434
|
if (!fieldOb) return;
|
|
5132
5435
|
|
|
5133
5436
|
filterObj.values = filterObj.values && lodash.map(filterObj.values, highchartsRenderer.decodeFunc);
|
|
@@ -5145,22 +5448,32 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5145
5448
|
}
|
|
5146
5449
|
});
|
|
5147
5450
|
|
|
5148
|
-
const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by',
|
|
5149
|
-
const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field',
|
|
5150
|
-
const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field',
|
|
5151
|
-
const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field',
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5451
|
+
const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by', predefinedField.dataSeries.fields);
|
|
5452
|
+
const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field', predefinedField.date.fields[0])].filter(f => !!f);
|
|
5453
|
+
const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field', predefinedField.value.fields[0])].filter(f => !!f);
|
|
5454
|
+
const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field', predefinedField.dataType.fields[0])].filter(f => !!f);
|
|
5455
|
+
const scenarioField = lodash.get(calcModelOptions, 'config.scenario', lodash.find(predefinedField.filters.fields, filter => [filter.name, filter.alias].includes('scenario')));
|
|
5456
|
+
const reportingMonthFieldWithAlias = lodash.find(fields, _field => reportingMonthRegex.test(_field.alias));
|
|
5457
|
+
const reportingMonthFieldWithName = lodash.find(fields, _field => reportingMonthRegex.test(_field.name));
|
|
5458
|
+
|
|
5459
|
+
/**
|
|
5460
|
+
* We can have several common fields, so we should ignore deleting during fillData
|
|
5461
|
+
* */
|
|
5462
|
+
const commonFieldsId = [scenarioField && scenarioField.id];
|
|
5463
|
+
const filterFields = fillData(filters, commonFieldsId);
|
|
5464
|
+
const valueFields = fillData(storedAggFields, commonFieldsId);
|
|
5465
|
+
const dateFields = fillData(storedDateFields, commonFieldsId);
|
|
5466
|
+
const dataTypeFields = fillData(storedDataTypeFields, commonFieldsId);
|
|
5467
|
+
const dataSeriesFields = fillData(storedGroupByFields, commonFieldsId);
|
|
5468
|
+
|
|
5469
|
+
lodash.remove(fields, _field => lodash.includes(commonFieldsId, _field.id));
|
|
5158
5470
|
|
|
5159
5471
|
calcModelOptions.pivot = {
|
|
5160
5472
|
fieldsArray: fields,
|
|
5161
5473
|
selectedFieldsArray: dataSeriesFields,
|
|
5162
5474
|
filtersArray: filterFields,
|
|
5163
5475
|
scenarioField,
|
|
5476
|
+
reportingMonthField: reportingMonthFieldWithAlias || reportingMonthFieldWithName,
|
|
5164
5477
|
dateFields,
|
|
5165
5478
|
dataTypeFields,
|
|
5166
5479
|
valueFields
|
|
@@ -6749,16 +7062,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6749
7062
|
value_name: 'name',
|
|
6750
7063
|
element_label: 'Name',
|
|
6751
7064
|
default_value: '_Variance'
|
|
6752
|
-
}, {
|
|
6753
|
-
element_type: 'input',
|
|
6754
|
-
value_name: 'formula',
|
|
6755
|
-
element_label: 'Formula',
|
|
6756
|
-
default_value: 'x2-x1'
|
|
6757
7065
|
}, {
|
|
6758
7066
|
element_type: 'input',
|
|
6759
|
-
value_name: '
|
|
6760
|
-
element_label: '
|
|
6761
|
-
default_value: ''
|
|
7067
|
+
value_name: 'formula',
|
|
7068
|
+
element_label: 'Formula',
|
|
7069
|
+
default_value: 'x2-x1'
|
|
7070
|
+
}, {
|
|
7071
|
+
element_type: 'input',
|
|
7072
|
+
value_name: 'color',
|
|
7073
|
+
element_label: 'Color',
|
|
7074
|
+
default_value: ''
|
|
6762
7075
|
}, {
|
|
6763
7076
|
element_type: 'radio',
|
|
6764
7077
|
value_name: 'chart',
|
|
@@ -6882,6 +7195,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6882
7195
|
legendTooltipTitle: 'Drag one field to further configure your x-axis.',
|
|
6883
7196
|
legendTooltipDescription: 'The breakdown subdivides the chart by a category field for further analysis of what’s contributing to the increase or decrease.',
|
|
6884
7197
|
},
|
|
7198
|
+
[highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH]: {
|
|
7199
|
+
name: 'Waterfall Walkthrough Chart ',
|
|
7200
|
+
label: 'Waterfall Walkthrough Chart ',
|
|
7201
|
+
title: 'TODO: add text',
|
|
7202
|
+
description: 'TODO: add text',
|
|
7203
|
+
axisName: 'Category',
|
|
7204
|
+
startedMessage: 'TODO: add text',
|
|
7205
|
+
axisTooltipTitle: 'TODO: add text',
|
|
7206
|
+
legendTooltipTitle: 'TODO: add text',
|
|
7207
|
+
},
|
|
6885
7208
|
'combo-chart': {
|
|
6886
7209
|
name: 'Combo Chart ',
|
|
6887
7210
|
label: 'Combo Chart ',
|
|
@@ -7537,6 +7860,24 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7537
7860
|
highchartsRenderer.suboptions["legends"],
|
|
7538
7861
|
]
|
|
7539
7862
|
},
|
|
7863
|
+
{
|
|
7864
|
+
type: highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH,
|
|
7865
|
+
name: highchartsRenderer.chartsTypesInfo[highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH].name,
|
|
7866
|
+
class: 'google-visualization-charteditor-thumbs-columnchart',
|
|
7867
|
+
render: highchartsRenderer.ptRenderWaterfallWalkthrough,
|
|
7868
|
+
suboptions: [
|
|
7869
|
+
highchartsRenderer.suboptions["axisX"],
|
|
7870
|
+
highchartsRenderer.suboptions["tooltips"],
|
|
7871
|
+
highchartsRenderer.suboptions["label"],
|
|
7872
|
+
highchartsRenderer.suboptions["subtitle"],
|
|
7873
|
+
highchartsRenderer.suboptions["widget_library"],
|
|
7874
|
+
highchartsRenderer.suboptions["chart"],
|
|
7875
|
+
highchartsRenderer.suboptions["negative_number_format"],
|
|
7876
|
+
highchartsRenderer.suboptions["advanced"],
|
|
7877
|
+
highchartsRenderer.suboptions["legends"],
|
|
7878
|
+
],
|
|
7879
|
+
hidden: true,
|
|
7880
|
+
},
|
|
7540
7881
|
]
|
|
7541
7882
|
},
|
|
7542
7883
|
];
|
|
@@ -8281,7 +8622,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8281
8622
|
var data = res;
|
|
8282
8623
|
|
|
8283
8624
|
lodash.forEach(datesFields, function (row) {
|
|
8284
|
-
row.val_not_convert = highchartsRenderer.
|
|
8625
|
+
row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
|
|
8285
8626
|
});
|
|
8286
8627
|
|
|
8287
8628
|
if (datesFields.length > 0) {
|
|
@@ -8687,14 +9028,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8687
9028
|
return rightPosition;
|
|
8688
9029
|
case 'none':
|
|
8689
9030
|
return none;
|
|
9031
|
+
}
|
|
9032
|
+
} else if (isLine) {
|
|
9033
|
+
return useNewUx ? leftPosition : rightPosition;
|
|
9034
|
+
} else if (isPie) {
|
|
9035
|
+
return useNewUx ? rightPosition : topPosition;
|
|
8690
9036
|
}
|
|
8691
|
-
} else if (isLine) {
|
|
8692
|
-
return useNewUx ? leftPosition : rightPosition;
|
|
8693
|
-
} else if (isPie) {
|
|
8694
|
-
return useNewUx ? rightPosition : topPosition;
|
|
8695
|
-
}
|
|
8696
9037
|
|
|
8697
|
-
|
|
9038
|
+
return useNewUx ? topPosition : bottomPosition;
|
|
8698
9039
|
}
|
|
8699
9040
|
|
|
8700
9041
|
highchartsRenderer.setYAxisMinMax = function (yAxis, axisYOptions) {
|