@datarailsshared/dr_renderer 1.2.218 → 1.2.219-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 +339 -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
|
};
|
|
@@ -25,6 +26,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
25
26
|
const textColor = "#151a41";
|
|
26
27
|
const chartLabelColor = "#cfd7dd";
|
|
27
28
|
const HIGHCHARTS_FONT_FAMILY = 'Poppins';
|
|
29
|
+
let firstBarColor = null;
|
|
28
30
|
|
|
29
31
|
if(!Highcharts){
|
|
30
32
|
Highcharts = {
|
|
@@ -82,11 +84,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
82
84
|
KPI_WIDGET: 'kpi-widget',
|
|
83
85
|
TEXT_WIDGET: 'text-widget',
|
|
84
86
|
WATERFALL_BREAKDOWN: 'waterfall-chart-breakdown',
|
|
87
|
+
WATERFALL_WALKTHROUGH: 'waterfall-chart-walkthrough',
|
|
85
88
|
PUBLISHED_ITEM: 'published_item',
|
|
86
89
|
RICH_TEXT: 'rich_text',
|
|
87
90
|
EXCEL_VIEWER: 'excel_viewer',
|
|
88
91
|
};
|
|
89
92
|
|
|
93
|
+
highchartsRenderer.VIRTUAL_FIELDS = {
|
|
94
|
+
WATERFALL_VARIANCE: 'DR_WATERFALL_BREAKDOWN_VARIANCE',
|
|
95
|
+
};
|
|
96
|
+
|
|
90
97
|
highchartsRenderer.highcharts_theme = {
|
|
91
98
|
"colors": highchartsRenderer.defaults_colors,
|
|
92
99
|
"chart": {
|
|
@@ -462,7 +469,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
462
469
|
highchartsRenderer.getOthersName(opts) :
|
|
463
470
|
undefined;
|
|
464
471
|
var drOthersInColumn = lodash.find(
|
|
465
|
-
pivotData.getColKeys(),
|
|
472
|
+
pivotData.getColKeys(),
|
|
466
473
|
keys => keys.length && (lodash.includes(keys, 'DR_Others') || lodash.includes(keys, othersName))
|
|
467
474
|
);
|
|
468
475
|
|
|
@@ -482,7 +489,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
482
489
|
rows = [];
|
|
483
490
|
}
|
|
484
491
|
|
|
485
|
-
var cols = this.key;
|
|
492
|
+
var cols = lodash.get(this, 'point.options.colsForTotal') || this.key;
|
|
486
493
|
if (typeof (cols) == 'object' && cols.name) {
|
|
487
494
|
cols = cols.name;
|
|
488
495
|
}
|
|
@@ -490,7 +497,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
490
497
|
if (!cols && is_drill_down_pie) {
|
|
491
498
|
cols = this.point.name;
|
|
492
499
|
}
|
|
493
|
-
|
|
500
|
+
|
|
494
501
|
if (drOthersInColumn) {
|
|
495
502
|
if (!lodash.isArray(cols) && othersName === cols) {
|
|
496
503
|
cols = ['DR_Others'];
|
|
@@ -628,7 +635,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
628
635
|
|| this.series.options.className === 'trendSeries') {
|
|
629
636
|
rows = [];
|
|
630
637
|
}
|
|
631
|
-
|
|
638
|
+
|
|
639
|
+
var cols = lodash.get(this, 'point.options.colsForTotal') || this.key;
|
|
632
640
|
if (!cols && is_drill_down_pie) {
|
|
633
641
|
cols = this.name;
|
|
634
642
|
}
|
|
@@ -651,7 +659,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
651
659
|
rows = temp;
|
|
652
660
|
}
|
|
653
661
|
|
|
654
|
-
var category_text = `<span style="font-weight: bold;"
|
|
662
|
+
var category_text = `<span style="font-weight: bold;">
|
|
663
|
+
${ lodash.get(this, 'point.options.colsForTotal') ? cols[0] : cols } ${ isWaterfallBreakdown ? ': ' : ' ' }
|
|
664
|
+
</span>`;
|
|
655
665
|
if (this.category) {
|
|
656
666
|
category_text = '';
|
|
657
667
|
}
|
|
@@ -668,7 +678,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
668
678
|
const modifiedRowsAndCols = highchartsRenderer.transformRowsAndColsForBreakdown(rows, cols, this.point, opts);
|
|
669
679
|
rows = modifiedRowsAndCols.rows;
|
|
670
680
|
cols = modifiedRowsAndCols.cols;
|
|
671
|
-
}
|
|
681
|
+
}
|
|
672
682
|
|
|
673
683
|
var aggr = pivotData.getAggregator(rows, cols);
|
|
674
684
|
|
|
@@ -1344,7 +1354,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1344
1354
|
const chart_series = [];
|
|
1345
1355
|
const row_n_keys = pivotData.getRowKeys();
|
|
1346
1356
|
const col_n_keys = pivotData.getColKeys();
|
|
1347
|
-
const hasBreakdownValues = lodash.get(opts, 'breakdown_options.values.breakdown.length');
|
|
1348
1357
|
|
|
1349
1358
|
let resultObject = {
|
|
1350
1359
|
data: [],
|
|
@@ -1363,8 +1372,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1363
1372
|
lodash.forEach(col_n_keys, function(col_n_value, col_index) {
|
|
1364
1373
|
|
|
1365
1374
|
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;
|
|
1368
1375
|
resultObject.data.push({
|
|
1369
1376
|
y: totalColumnValue,
|
|
1370
1377
|
name: lodash.unescape(col_n_value).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
|
|
@@ -1376,9 +1383,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1376
1383
|
if (col_index !== col_n_keys.length - 1) {
|
|
1377
1384
|
lodash.forEach(row_n_keys, function (row_n_value) {
|
|
1378
1385
|
const agg = pivotData.getAggregator(row_n_value, col_n_value);
|
|
1379
|
-
let val =
|
|
1380
|
-
? agg.value()
|
|
1381
|
-
: nextTotalColumnValue - totalColumnValue;
|
|
1386
|
+
let val = agg.value();
|
|
1382
1387
|
|
|
1383
1388
|
val = $.isNumeric(val) ? parseFloat(val) : 0;
|
|
1384
1389
|
if (val) {
|
|
@@ -1389,6 +1394,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1389
1394
|
if (tmoobj.name) {
|
|
1390
1395
|
tmoobj.name = tmoobj.name.replace('DR_Others', highchartsRenderer.getOthersName(opts));
|
|
1391
1396
|
}
|
|
1397
|
+
|
|
1392
1398
|
if (lodash.isEmpty(String(tmoobj.name))) {
|
|
1393
1399
|
tmoobj.name = lodash.unescape(col_n_value);
|
|
1394
1400
|
tmoobj.visible = false;
|
|
@@ -1398,12 +1404,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1398
1404
|
tmoobj.colKeys = [lodash.unescape(col_n_keys[col_index - 1]), lodash.unescape(col_n_value)];
|
|
1399
1405
|
resultObject.data.push(tmoobj);
|
|
1400
1406
|
}
|
|
1407
|
+
|
|
1401
1408
|
});
|
|
1402
1409
|
}
|
|
1403
1410
|
});
|
|
1404
1411
|
|
|
1405
1412
|
chart_series.push(resultObject);
|
|
1406
|
-
|
|
1407
1413
|
opts.chart_series = [];
|
|
1408
1414
|
if (!lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
|
|
1409
1415
|
chart_series.forEach(series => {
|
|
@@ -1414,6 +1420,89 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1414
1420
|
return chart_series;
|
|
1415
1421
|
}
|
|
1416
1422
|
|
|
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
|
+
|
|
1417
1506
|
highchartsRenderer.setChartTypeBySeriesType = function (type, series) {
|
|
1418
1507
|
const types = {
|
|
1419
1508
|
'line-chart': 'line',
|
|
@@ -1617,7 +1706,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1617
1706
|
highchartsRenderer.getDataLabelsStylesForDrillDown = function(additionOptions) {
|
|
1618
1707
|
let result = highchartsRenderer.getDataLabelsOptions(additionOptions, { dataLabels: {} });
|
|
1619
1708
|
|
|
1620
|
-
if (!result.dataLabels) return {};
|
|
1709
|
+
if (!result.dataLabels) return {};
|
|
1621
1710
|
return {
|
|
1622
1711
|
activeDataLabelStyle: {
|
|
1623
1712
|
color: result.dataLabels.color,
|
|
@@ -3173,7 +3262,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3173
3262
|
|
|
3174
3263
|
highchartsRenderer.ptRenderWaterfallBreakdown = function (pivotData, opts, drilldownFunc, chartType) {
|
|
3175
3264
|
let chartOptions = {};
|
|
3176
|
-
const additionOptions = opts.chartOptions
|
|
3265
|
+
const additionOptions = opts.chartOptions
|
|
3177
3266
|
? opts.chartOptions
|
|
3178
3267
|
: highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN);
|
|
3179
3268
|
|
|
@@ -3272,6 +3361,122 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3272
3361
|
return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
|
|
3273
3362
|
};
|
|
3274
3363
|
|
|
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
|
+
|
|
3275
3480
|
highchartsRenderer.formatFieldValue = function (field, value) {
|
|
3276
3481
|
let currentType = '';
|
|
3277
3482
|
let format = field.format;
|
|
@@ -4340,6 +4545,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4340
4545
|
}
|
|
4341
4546
|
};
|
|
4342
4547
|
|
|
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
|
+
|
|
4343
4559
|
highchartsRenderer.rhPivotView = function (rowData, options, isTable = false, widget = null) {
|
|
4344
4560
|
if (!rowData || !rowData) {
|
|
4345
4561
|
if (options.onlyOptions) {
|
|
@@ -4348,10 +4564,15 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4348
4564
|
return null;
|
|
4349
4565
|
}
|
|
4350
4566
|
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
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;
|
|
4355
4576
|
const uniqueCategories = lodash.filter(
|
|
4356
4577
|
lodash.uniq(
|
|
4357
4578
|
lodash.map(rowData, row => row[widget.cols[0].name])
|
|
@@ -4361,6 +4582,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4361
4582
|
|
|
4362
4583
|
if (uniqueCategories && (uniqueCategories.length > maxCategories || uniqueCategories.length < minCategories )) {
|
|
4363
4584
|
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. `;
|
|
4364
4587
|
options.error_params = {
|
|
4365
4588
|
title: 'Data Conflict',
|
|
4366
4589
|
text: `Please adjust your dashboard's reference date and filter selections as \
|
|
@@ -4609,19 +4832,25 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4609
4832
|
return highchartsRenderer.getWeekNumber(dateObj);
|
|
4610
4833
|
};
|
|
4611
4834
|
|
|
4612
|
-
highchartsRenderer.
|
|
4613
|
-
let
|
|
4835
|
+
highchartsRenderer.check_values_not_for_convert = function (currentgraph, field_name) {
|
|
4836
|
+
let vals_not_convert = [];
|
|
4614
4837
|
if (lodash.has(currentgraph, "options.chartOptions.delta_column") && currentgraph.options.chartOptions.delta_column) {
|
|
4615
4838
|
let delta_options = currentgraph.options.chartOptions.delta_column;
|
|
4616
4839
|
if (delta_options.field == 'series' && currentgraph.rows && currentgraph.rows[0] &&
|
|
4617
4840
|
currentgraph.rows[0].name == field_name) {
|
|
4618
|
-
|
|
4841
|
+
vals_not_convert = [delta_options.name];
|
|
4619
4842
|
} else if (delta_options.field == 'category' && currentgraph.rows && currentgraph.cols[0] &&
|
|
4620
4843
|
currentgraph.cols[0].name == field_name) {
|
|
4621
|
-
|
|
4844
|
+
vals_not_convert = [delta_options.name];
|
|
4622
4845
|
}
|
|
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
|
+
});
|
|
4623
4852
|
}
|
|
4624
|
-
return
|
|
4853
|
+
return vals_not_convert;
|
|
4625
4854
|
};
|
|
4626
4855
|
|
|
4627
4856
|
highchartsRenderer.updateFiltersShowNames = function (filters) {
|
|
@@ -4641,8 +4870,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4641
4870
|
})
|
|
4642
4871
|
};
|
|
4643
4872
|
|
|
4644
|
-
highchartsRenderer.returnRawDataValue = function (type, value, format, field_name,
|
|
4645
|
-
if (
|
|
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)) {
|
|
4646
4875
|
return value;
|
|
4647
4876
|
}
|
|
4648
4877
|
|
|
@@ -4954,12 +5183,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4954
5183
|
}
|
|
4955
5184
|
});
|
|
4956
5185
|
|
|
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
|
+
|
|
4957
5198
|
// fill rows fields
|
|
4958
|
-
lodash.forEach(
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
lodash.
|
|
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
|
+
}
|
|
4963
5208
|
}
|
|
4964
5209
|
});
|
|
4965
5210
|
|
|
@@ -5649,7 +5894,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5649
5894
|
return valToReturn;
|
|
5650
5895
|
};
|
|
5651
5896
|
|
|
5652
|
-
|
|
5897
|
+
|
|
5653
5898
|
highchartsRenderer.getChartAxisLabel = function(type) {
|
|
5654
5899
|
return highchartsRenderer.chartsTypesInfo[type] ? highchartsRenderer.chartsTypesInfo[type].axisName : CHART_AXIS_DEFAULT_LABEL;
|
|
5655
5900
|
};
|
|
@@ -6484,7 +6729,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6484
6729
|
value_name: 'show',
|
|
6485
6730
|
default_value: true,
|
|
6486
6731
|
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',
|
|
6487
|
-
disabled_fn: (value) => !value.show_out_of_x_axis
|
|
6732
|
+
disabled_fn: (value) => !value.show_out_of_x_axis
|
|
6488
6733
|
&& !value.show_out_of_data_series
|
|
6489
6734
|
&& !value.show_value
|
|
6490
6735
|
&& !value.show_x_axis
|
|
@@ -6525,8 +6770,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6525
6770
|
element_label: '[X Axis]',
|
|
6526
6771
|
value_name: 'show_x_axis',
|
|
6527
6772
|
default_value: true,
|
|
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
|
|
6773
|
+
clickFn: (value) => value.show = value.show
|
|
6774
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6530
6775
|
: value.show,
|
|
6531
6776
|
},
|
|
6532
6777
|
{
|
|
@@ -6534,8 +6779,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6534
6779
|
element_label: '[Data Series]',
|
|
6535
6780
|
value_name: 'show_data_series',
|
|
6536
6781
|
default_value: true,
|
|
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
|
|
6782
|
+
clickFn: (value) => value.show = value.show
|
|
6783
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6539
6784
|
: value.show,
|
|
6540
6785
|
},
|
|
6541
6786
|
{
|
|
@@ -6543,8 +6788,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6543
6788
|
element_label: 'Value',
|
|
6544
6789
|
value_name: 'show_value',
|
|
6545
6790
|
default_value: true,
|
|
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
|
|
6791
|
+
clickFn: (value) => value.show = value.show
|
|
6792
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6548
6793
|
: value.show,
|
|
6549
6794
|
},
|
|
6550
6795
|
{
|
|
@@ -6552,8 +6797,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6552
6797
|
element_label: '% Out of [X Axis]',
|
|
6553
6798
|
value_name: 'show_out_of_x_axis',
|
|
6554
6799
|
default_value: false,
|
|
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
|
|
6800
|
+
clickFn: (value) => value.show = value.show
|
|
6801
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6557
6802
|
: value.show,
|
|
6558
6803
|
},
|
|
6559
6804
|
{
|
|
@@ -6561,8 +6806,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6561
6806
|
element_label: '% Out of [Data Series]',
|
|
6562
6807
|
value_name: 'show_out_of_data_series',
|
|
6563
6808
|
default_value: false,
|
|
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
|
|
6809
|
+
clickFn: (value) => value.show = value.show
|
|
6810
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6566
6811
|
: value.show,
|
|
6567
6812
|
},
|
|
6568
6813
|
]
|
|
@@ -6736,16 +6981,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6736
6981
|
value_name: 'name',
|
|
6737
6982
|
element_label: 'Name',
|
|
6738
6983
|
default_value: '_Variance'
|
|
6739
|
-
}, {
|
|
6740
|
-
element_type: 'input',
|
|
6741
|
-
value_name: 'formula',
|
|
6742
|
-
element_label: 'Formula',
|
|
6743
|
-
default_value: 'x2-x1'
|
|
6744
6984
|
}, {
|
|
6745
6985
|
element_type: 'input',
|
|
6746
|
-
value_name: '
|
|
6747
|
-
element_label: '
|
|
6748
|
-
default_value: ''
|
|
6986
|
+
value_name: 'formula',
|
|
6987
|
+
element_label: 'Formula',
|
|
6988
|
+
default_value: 'x2-x1'
|
|
6989
|
+
}, {
|
|
6990
|
+
element_type: 'input',
|
|
6991
|
+
value_name: 'color',
|
|
6992
|
+
element_label: 'Color',
|
|
6993
|
+
default_value: ''
|
|
6749
6994
|
}, {
|
|
6750
6995
|
element_type: 'radio',
|
|
6751
6996
|
value_name: 'chart',
|
|
@@ -6868,7 +7113,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6868
7113
|
axisTooltipDescription: 'The category (usually an independent variable) is shown on the x-axis and should be between 2 to 5 total columns. ',
|
|
6869
7114
|
legendTooltipTitle: 'Drag one field to further configure your x-axis.',
|
|
6870
7115
|
legendTooltipDescription: 'The breakdown subdivides the chart by a category field for further analysis of what’s contributing to the increase or decrease.',
|
|
6871
|
-
},
|
|
7116
|
+
},
|
|
7117
|
+
[highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH]: {
|
|
7118
|
+
name: 'Waterfall Walkthrough Chart ',
|
|
7119
|
+
label: 'Waterfall Walkthrough Chart ',
|
|
7120
|
+
title: 'TODO: add text',
|
|
7121
|
+
description: 'TODO: add text',
|
|
7122
|
+
axisName: 'Category',
|
|
7123
|
+
startedMessage: 'TODO: add text',
|
|
7124
|
+
axisTooltipTitle: 'TODO: add text',
|
|
7125
|
+
legendTooltipTitle: 'TODO: add text',
|
|
7126
|
+
},
|
|
6872
7127
|
'combo-chart': {
|
|
6873
7128
|
name: 'Combo Chart ',
|
|
6874
7129
|
label: 'Combo Chart ',
|
|
@@ -7524,6 +7779,24 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7524
7779
|
highchartsRenderer.suboptions["legends"],
|
|
7525
7780
|
]
|
|
7526
7781
|
},
|
|
7782
|
+
{
|
|
7783
|
+
type: highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH,
|
|
7784
|
+
name: highchartsRenderer.chartsTypesInfo[highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH].name,
|
|
7785
|
+
class: 'google-visualization-charteditor-thumbs-columnchart',
|
|
7786
|
+
render: highchartsRenderer.ptRenderWaterfallWalkthrough,
|
|
7787
|
+
suboptions: [
|
|
7788
|
+
highchartsRenderer.suboptions["axisX"],
|
|
7789
|
+
highchartsRenderer.suboptions["tooltips"],
|
|
7790
|
+
highchartsRenderer.suboptions["label"],
|
|
7791
|
+
highchartsRenderer.suboptions["subtitle"],
|
|
7792
|
+
highchartsRenderer.suboptions["widget_library"],
|
|
7793
|
+
highchartsRenderer.suboptions["chart"],
|
|
7794
|
+
highchartsRenderer.suboptions["negative_number_format"],
|
|
7795
|
+
highchartsRenderer.suboptions["advanced"],
|
|
7796
|
+
highchartsRenderer.suboptions["legends"],
|
|
7797
|
+
],
|
|
7798
|
+
hidden: true,
|
|
7799
|
+
},
|
|
7527
7800
|
]
|
|
7528
7801
|
},
|
|
7529
7802
|
];
|
|
@@ -7680,7 +7953,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7680
7953
|
_.forEach(Object.keys(dates), key => {
|
|
7681
7954
|
const dateConfiguration = dates[key];
|
|
7682
7955
|
const timestamp = dateConfiguration.timestamp;
|
|
7683
|
-
if (timestamp) {
|
|
7956
|
+
if (timestamp) {
|
|
7684
7957
|
const dateTzOffsetInSeconds = new Date(timestamp * 1000).getTimezoneOffset() * 60;
|
|
7685
7958
|
dateConfiguration.displayedValue = new Date((timestamp + dateTzOffsetInSeconds) * 1000)
|
|
7686
7959
|
.toLocaleDateString();
|
|
@@ -7976,10 +8249,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7976
8249
|
};
|
|
7977
8250
|
|
|
7978
8251
|
highchartsRenderer.createDateFromString = function (dateString, format) {
|
|
7979
|
-
if ((format &&
|
|
8252
|
+
if (!(format && highchartsRenderer.isDateFormat(dateString, format) || highchartsRenderer.isDate(dateString))) {
|
|
7980
8253
|
return null;
|
|
7981
8254
|
}
|
|
7982
|
-
const utcDate = format
|
|
8255
|
+
const utcDate = format
|
|
7983
8256
|
? moment_lib.utc(dateString, format, true)
|
|
7984
8257
|
: moment_lib.utc(dateString);
|
|
7985
8258
|
return utcDate.startOf('day').unix();
|
|
@@ -7997,7 +8270,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7997
8270
|
}
|
|
7998
8271
|
|
|
7999
8272
|
let filters = [];
|
|
8000
|
-
|
|
8273
|
+
|
|
8001
8274
|
if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
|
|
8002
8275
|
const colFilter = highchartsRenderer.createFilterObject(widget.cols[0]);
|
|
8003
8276
|
const labels = [];
|
|
@@ -8025,7 +8298,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8025
8298
|
col_value,
|
|
8026
8299
|
highchartsRenderer.getDateFieldFormat(widget, widget.cols[index])
|
|
8027
8300
|
);
|
|
8028
|
-
|
|
8301
|
+
|
|
8029
8302
|
if ($.isEmptyObject(datetrange)) {
|
|
8030
8303
|
return;
|
|
8031
8304
|
}
|
|
@@ -8130,6 +8403,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8130
8403
|
filter.is_excluded = false;
|
|
8131
8404
|
} else {
|
|
8132
8405
|
filter = highchartsRenderer.createDrillDownFilterObject(widget, widget.cols[0], colKey[0]);
|
|
8406
|
+
filters.push(filter);
|
|
8133
8407
|
}
|
|
8134
8408
|
filter.values = [];
|
|
8135
8409
|
for (let i = 0; i < colKey.length; i++) {
|
|
@@ -8267,7 +8541,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8267
8541
|
var data = res;
|
|
8268
8542
|
|
|
8269
8543
|
lodash.forEach(datesFields, function (row) {
|
|
8270
|
-
row.val_not_convert = highchartsRenderer.
|
|
8544
|
+
row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
|
|
8271
8545
|
});
|
|
8272
8546
|
|
|
8273
8547
|
if (datesFields.length > 0) {
|
|
@@ -8673,14 +8947,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8673
8947
|
return rightPosition;
|
|
8674
8948
|
case 'none':
|
|
8675
8949
|
return none;
|
|
8950
|
+
}
|
|
8951
|
+
} else if (isLine) {
|
|
8952
|
+
return useNewUx ? leftPosition : rightPosition;
|
|
8953
|
+
} else if (isPie) {
|
|
8954
|
+
return useNewUx ? rightPosition : topPosition;
|
|
8676
8955
|
}
|
|
8677
|
-
} else if (isLine) {
|
|
8678
|
-
return useNewUx ? leftPosition : rightPosition;
|
|
8679
|
-
} else if (isPie) {
|
|
8680
|
-
return useNewUx ? rightPosition : topPosition;
|
|
8681
|
-
}
|
|
8682
8956
|
|
|
8683
|
-
|
|
8957
|
+
return useNewUx ? topPosition : bottomPosition;
|
|
8684
8958
|
}
|
|
8685
8959
|
|
|
8686
8960
|
highchartsRenderer.setYAxisMinMax = function (yAxis, axisYOptions) {
|
|
@@ -8695,7 +8969,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8695
8969
|
}
|
|
8696
8970
|
|
|
8697
8971
|
highchartsRenderer.getDateFieldFormat = function(widget, dateField) {
|
|
8698
|
-
const aggregationConfig = widget.options && widget.options.date_aggregation_configs
|
|
8972
|
+
const aggregationConfig = widget.options && widget.options.date_aggregation_configs
|
|
8699
8973
|
? _.find(widget.options.date_aggregation_configs, { field_id: dateField.id })
|
|
8700
8974
|
: null;
|
|
8701
8975
|
|