@datarailsshared/dr_renderer 1.2.222-unittests → 1.2.224-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.
@@ -31,12 +31,6 @@ jobs:
31
31
  - run:
32
32
  name: Authenticate with registry
33
33
  command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc
34
- - run:
35
- name: Install dependencies
36
- command: npm install
37
- - run:
38
- name: Run npm test
39
- command: npm test
40
34
  - run:
41
35
  name: Publish package
42
36
  command: npm publish . --access=public
@@ -71,4 +65,3 @@ workflows:
71
65
  - /tigers/
72
66
  - /wizards/
73
67
  - /rocket/
74
- - /unittests/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.2.222-unittests",
3
+ "version": "1.2.224-dragons",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -9,8 +9,7 @@
9
9
  "tables"
10
10
  ],
11
11
  "scripts": {
12
- "login": "npm login",
13
- "test": "jest --coverage"
12
+ "login": "npm login"
14
13
  },
15
14
  "author": "Sergey Spivakov",
16
15
  "repository": {
@@ -18,21 +17,6 @@
18
17
  "url": "git+https://bitbucket.org/datarails/dr_renderer.git"
19
18
  },
20
19
  "license": "",
21
- "dependencies": {
22
- "jquery": "^3.6.0",
23
- "lodash": "^4.17.20",
24
- "regenerator-runtime": "^0.13.5"
25
- },
26
- "devDependencies": {
27
- "@babel/core": "^7.20.12",
28
- "@babel/preset-env": "^7.20.2",
29
- "@testing-library/dom": "^7.2.1",
30
- "@testing-library/jest-dom": "^5.5.0",
31
- "babel-jest": "^25.5.1",
32
- "jest": "^25.3.0",
33
- "moment": "^2.29.1",
34
- "serve": "^11.3.0"
35
- },
36
20
  "bugs": {
37
21
  "url": ""
38
22
  },
@@ -40,10 +24,5 @@
40
24
  "whitelistedNonPeerDependencies": [],
41
25
  "main": "src/index.js",
42
26
  "module": "src/index.js",
43
- "sideEffects": false,
44
- "jest": {
45
- "setupFiles": [
46
- "./setup-jest.js"
47
- ]
48
- }
27
+ "sideEffects": false
49
28
  }
@@ -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'];
@@ -615,7 +622,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
615
622
 
616
623
  var func = function () {
617
624
  const isWaterfallBreakdown = this.series.options.className === SERIES_CLASSNAMES.WATERFALL_BREAKDOWN;
618
-
625
+ const isWaterfallWalkthrough = this.series.options.className === SERIES_CLASSNAMES.WATERFALL_WALKTHROUGH;
619
626
  var y = parseFloat(this.y);
620
627
  if (pivotData) {
621
628
  let series_name = (this.series.name || '') + "";
@@ -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
- var cols = this.key;
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
  }
@@ -643,7 +651,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
643
651
  if (variant_name && rows && rows[0] && variant_name == rows[0]) {
644
652
  rows[0] = variant_name_default_name;
645
653
  }
646
-
654
+ if (isWaterfallWalkthrough) {
655
+ cols = [this.key]
656
+ }
647
657
  try {
648
658
  if (is_drill_down_pie && !highchartsRenderer.selfStartsWith(series_name,"Series ")) {
649
659
  let temp = cols;
@@ -651,7 +661,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
651
661
  rows = temp;
652
662
  }
653
663
 
654
- var category_text = `<span style="font-weight: bold;">${ cols }${ isWaterfallBreakdown ? ': ' : ' ' }</span>`;
664
+ var category_text = `<span style="font-weight: bold;">
665
+ ${ lodash.get(this, 'point.options.colsForTotal') ? cols[0] : cols } ${ isWaterfallBreakdown ? ': ' : ' ' }
666
+ </span>`;
655
667
  if (this.category) {
656
668
  category_text = '';
657
669
  }
@@ -668,7 +680,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
668
680
  const modifiedRowsAndCols = highchartsRenderer.transformRowsAndColsForBreakdown(rows, cols, this.point, opts);
669
681
  rows = modifiedRowsAndCols.rows;
670
682
  cols = modifiedRowsAndCols.cols;
671
- }
683
+ }
672
684
 
673
685
  var aggr = pivotData.getAggregator(rows, cols);
674
686
 
@@ -1344,7 +1356,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1344
1356
  const chart_series = [];
1345
1357
  const row_n_keys = pivotData.getRowKeys();
1346
1358
  const col_n_keys = pivotData.getColKeys();
1347
- const hasBreakdownValues = lodash.get(opts, 'breakdown_options.values.breakdown.length');
1348
1359
 
1349
1360
  let resultObject = {
1350
1361
  data: [],
@@ -1363,8 +1374,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1363
1374
  lodash.forEach(col_n_keys, function(col_n_value, col_index) {
1364
1375
 
1365
1376
  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
1377
  resultObject.data.push({
1369
1378
  y: totalColumnValue,
1370
1379
  name: lodash.unescape(col_n_value).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
@@ -1376,9 +1385,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1376
1385
  if (col_index !== col_n_keys.length - 1) {
1377
1386
  lodash.forEach(row_n_keys, function (row_n_value) {
1378
1387
  const agg = pivotData.getAggregator(row_n_value, col_n_value);
1379
- let val = hasBreakdownValues
1380
- ? agg.value()
1381
- : nextTotalColumnValue - totalColumnValue;
1388
+ let val = agg.value();
1382
1389
 
1383
1390
  val = $.isNumeric(val) ? parseFloat(val) : 0;
1384
1391
  if (val) {
@@ -1389,6 +1396,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1389
1396
  if (tmoobj.name) {
1390
1397
  tmoobj.name = tmoobj.name.replace('DR_Others', highchartsRenderer.getOthersName(opts));
1391
1398
  }
1399
+
1392
1400
  if (lodash.isEmpty(String(tmoobj.name))) {
1393
1401
  tmoobj.name = lodash.unescape(col_n_value);
1394
1402
  tmoobj.visible = false;
@@ -1398,12 +1406,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1398
1406
  tmoobj.colKeys = [lodash.unescape(col_n_keys[col_index - 1]), lodash.unescape(col_n_value)];
1399
1407
  resultObject.data.push(tmoobj);
1400
1408
  }
1409
+
1401
1410
  });
1402
1411
  }
1403
1412
  });
1404
1413
 
1405
1414
  chart_series.push(resultObject);
1406
-
1407
1415
  opts.chart_series = [];
1408
1416
  if (!lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
1409
1417
  chart_series.forEach(series => {
@@ -1414,6 +1422,89 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1414
1422
  return chart_series;
1415
1423
  }
1416
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.trend !== 'total') {
1471
+ if (index === 0 && !firstBarColor) {
1472
+ color = waterfallOptions.colors.total;
1473
+ firstBarColor = waterfallOptions.colors.total;
1474
+ } else {
1475
+ color = value.color
1476
+ }
1477
+ } else {
1478
+ color = waterfallOptions.colors.total;
1479
+ }
1480
+
1481
+ resultObject.data.push({
1482
+ y: val,
1483
+ name: lodash.unescape(name).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
1484
+ isSum: value.trend === 'total',
1485
+ isTotal: value.trend === 'total',
1486
+ color,
1487
+ colsForTotal: value.trend === 'total' ? keys : null,
1488
+ });
1489
+ });
1490
+ chart_series.push(resultObject);
1491
+ chart_series.push(
1492
+ {
1493
+ name: 'Increase',
1494
+ visible: false,
1495
+ color: waterfallOptions.colors.increase
1496
+ });
1497
+
1498
+ chart_series.push(
1499
+ {
1500
+ name: 'Decrease',
1501
+ visible: false,
1502
+ color: waterfallOptions.colors.decrease
1503
+ });
1504
+
1505
+ return chart_series;
1506
+ }
1507
+
1417
1508
  highchartsRenderer.setChartTypeBySeriesType = function (type, series) {
1418
1509
  const types = {
1419
1510
  'line-chart': 'line',
@@ -1617,7 +1708,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1617
1708
  highchartsRenderer.getDataLabelsStylesForDrillDown = function(additionOptions) {
1618
1709
  let result = highchartsRenderer.getDataLabelsOptions(additionOptions, { dataLabels: {} });
1619
1710
 
1620
- if (!result.dataLabels) return {};
1711
+ if (!result.dataLabels) return {};
1621
1712
  return {
1622
1713
  activeDataLabelStyle: {
1623
1714
  color: result.dataLabels.color,
@@ -3173,7 +3264,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3173
3264
 
3174
3265
  highchartsRenderer.ptRenderWaterfallBreakdown = function (pivotData, opts, drilldownFunc, chartType) {
3175
3266
  let chartOptions = {};
3176
- const additionOptions = opts.chartOptions
3267
+ const additionOptions = opts.chartOptions
3177
3268
  ? opts.chartOptions
3178
3269
  : highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN);
3179
3270
 
@@ -3272,6 +3363,122 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3272
3363
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3273
3364
  };
3274
3365
 
3366
+ highchartsRenderer.ptRenderWaterfallWalkthrough = function (pivotData, opts) {
3367
+ let chartOptions = {};
3368
+ const waterfallOptions = opts?.walkthrough_options;
3369
+ const additionOptions = opts.chartOptions
3370
+ ? opts.chartOptions
3371
+ : highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH);
3372
+
3373
+ chartOptions.chart = {
3374
+ type: 'waterfall',
3375
+ zoomType: additionOptions && additionOptions.chart && additionOptions.chart.zoom_type ? additionOptions.chart.zoom_type : 'None',
3376
+ };
3377
+ if (disableAnimation) {
3378
+ chartOptions.chart.animation = false;
3379
+ }
3380
+ const walkthroughFieldIsNotSet = lodash.some(pivotData.getRowKeys(), rowKey => !rowKey || lodash.isArray(rowKey) && !rowKey.length);
3381
+
3382
+ chartOptions.xAxis = {
3383
+ type: 'category',
3384
+ crosshair: true,
3385
+ min: 0,
3386
+ title: {
3387
+ text : additionOptions && additionOptions.axisX ? additionOptions.axisX.name : '',
3388
+ },
3389
+ uniqueNames: walkthroughFieldIsNotSet,
3390
+ };
3391
+
3392
+ highchartsRenderer.setTitleAndSubTitle(chartOptions, opts, additionOptions);
3393
+
3394
+ chartOptions.yAxis = {
3395
+ min: null,
3396
+ max: null,
3397
+ title: {
3398
+ text: additionOptions && additionOptions.axisY ? additionOptions.axisY.name : '',
3399
+ autoylabel: additionOptions && additionOptions.axisY ? additionOptions.axisY.autoylabel : ''
3400
+ },
3401
+ labels: {
3402
+ formatter: highchartsRenderer.defaultValueLabelsFormatter(pivotData, opts)
3403
+ },
3404
+ };
3405
+ if (additionOptions) {
3406
+ highchartsRenderer.setYAxisMinMax(chartOptions.yAxis, additionOptions.axisY);
3407
+ }
3408
+
3409
+ chartOptions.tooltip = {
3410
+ formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
3411
+ valueDecimals: 2,
3412
+ };
3413
+
3414
+ highchartsRenderer.handleGridLines(additionOptions, chartOptions);
3415
+
3416
+ if (lodash.get(opts, 'paletteOptions.widgetPalette', null)) {
3417
+ const mc_palette = lodash.find(lodash.get(opts.paletteOptions, 'monochromePalettes', []), { selected: true });
3418
+ chartOptions.colors = mc_palette ? mc_palette.colors : opts.paletteOptions.widgetPalette;
3419
+ } else if (lodash.get(opts, 'paletteOptions.dashboardPalette.colors', null)) {
3420
+ chartOptions.colors = opts.paletteOptions.dashboardPalette.colors;
3421
+ }
3422
+ chartOptions.series = highchartsRenderer
3423
+ .ptCreateWaterfallWalkthroughSeries(pivotData, null, additionOptions, opts);
3424
+
3425
+ chartOptions = highchartsRenderer.prepareAxisX(chartOptions, additionOptions, pivotData.getColKeys());
3426
+ chartOptions.plotOptions = {
3427
+ waterfall: {
3428
+ pointPadding: 0.2,
3429
+ borderWidth: 0,
3430
+ borderRadius: 1,
3431
+ lineWidth: 0,
3432
+ },
3433
+ series: {
3434
+ animation: !disableAnimation,
3435
+ cropThreshold: 1000,
3436
+ dataLabels: {
3437
+ allowOverlap: additionOptions && additionOptions.label ? additionOptions.label.overlap : false,
3438
+ enabled: additionOptions && additionOptions.label ? additionOptions.label.show : true,
3439
+ formatter: highchartsRenderer.defaultDataLabelFormatter(pivotData, opts),
3440
+ style: highchartsRenderer.getDataLabelsStyle(additionOptions),
3441
+ inside: false
3442
+ },
3443
+ events: {
3444
+ legendItemClick: () => {
3445
+ return false;
3446
+ }
3447
+ }
3448
+ }
3449
+ };
3450
+
3451
+ if (opts.drillDownListFunc) {
3452
+ chartOptions.plotOptions.series.cursor = 'pointer';
3453
+ chartOptions.plotOptions.series.point = {
3454
+ events: {
3455
+ click: opts.drillDownListFunc
3456
+ }
3457
+ };
3458
+ }
3459
+ if (waterfallOptions.colors) {
3460
+ chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, 3, false);
3461
+ chartOptions.legend.useHTML = true;
3462
+ chartOptions.legend.labelFormatter = function() {
3463
+ const name = this.options.className ? 'Total': this.name;
3464
+ const findTotal = _.find(this.options.data, {isTotal: true});
3465
+ const color = findTotal?.color ? findTotal.color : this.color;
3466
+ 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>';
3467
+ }
3468
+
3469
+ chartOptions.legend.symbolPadding = 0;
3470
+ chartOptions.legend.symbolWidth = 0;
3471
+ chartOptions.legend.symbolHeight = 0;
3472
+ chartOptions.legend.squareSymbol = false;
3473
+ } else {
3474
+ chartOptions.legend = {
3475
+ enabled: false
3476
+ }
3477
+ }
3478
+
3479
+ return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3480
+ }
3481
+
3275
3482
  highchartsRenderer.formatFieldValue = function (field, value) {
3276
3483
  let currentType = '';
3277
3484
  let format = field.format;
@@ -4340,6 +4547,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4340
4547
  }
4341
4548
  };
4342
4549
 
4550
+ highchartsRenderer.waterfallConstants = {
4551
+ [highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN]: {
4552
+ minCategoriesCount: 2,
4553
+ maxCategoriesCount: 5,
4554
+ },
4555
+ [highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH]: {
4556
+ minCategoriesCount: 2,
4557
+ maxCategoriesCount: 10,
4558
+ }
4559
+ };
4560
+
4343
4561
  highchartsRenderer.rhPivotView = function (rowData, options, isTable = false, widget = null) {
4344
4562
  if (!rowData || !rowData) {
4345
4563
  if (options.onlyOptions) {
@@ -4348,10 +4566,15 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4348
4566
  return null;
4349
4567
  }
4350
4568
 
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;
4569
+ const isWaterfall = widget
4570
+ && (
4571
+ widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN
4572
+ || widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH
4573
+ );
4574
+
4575
+ if (isWaterfall) {
4576
+ const maxCategories = highchartsRenderer.waterfallConstants[widget.chart_type].maxCategoriesCount;
4577
+ const minCategories = highchartsRenderer.waterfallConstants[widget.chart_type].minCategoriesCount;
4355
4578
  const uniqueCategories = lodash.filter(
4356
4579
  lodash.uniq(
4357
4580
  lodash.map(rowData, row => row[widget.cols[0].name])
@@ -4361,6 +4584,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4361
4584
 
4362
4585
  if (uniqueCategories && (uniqueCategories.length > maxCategories || uniqueCategories.length < minCategories )) {
4363
4586
  options.error_has_occurred = true;
4587
+ const isDateField = widget.cols[0].type === 'Date';
4588
+ const commonMessagePart = `This chart support a selection of ${minCategories}-${maxCategories} items from the category section. `;
4364
4589
  options.error_params = {
4365
4590
  title: 'Data Conflict',
4366
4591
  text: `Please adjust your dashboard's reference date and filter selections as \
@@ -4609,19 +4834,25 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4609
4834
  return highchartsRenderer.getWeekNumber(dateObj);
4610
4835
  };
4611
4836
 
4612
- highchartsRenderer.check_value_not_for_convert = function (currentgraph, field_name) {
4613
- let val_not_convert = null;
4837
+ highchartsRenderer.check_values_not_for_convert = function (currentgraph, field_name) {
4838
+ let vals_not_convert = [];
4614
4839
  if (lodash.has(currentgraph, "options.chartOptions.delta_column") && currentgraph.options.chartOptions.delta_column) {
4615
4840
  let delta_options = currentgraph.options.chartOptions.delta_column;
4616
4841
  if (delta_options.field == 'series' && currentgraph.rows && currentgraph.rows[0] &&
4617
4842
  currentgraph.rows[0].name == field_name) {
4618
- val_not_convert = delta_options.name;
4843
+ vals_not_convert = [delta_options.name];
4619
4844
  } else if (delta_options.field == 'category' && currentgraph.rows && currentgraph.cols[0] &&
4620
4845
  currentgraph.cols[0].name == field_name) {
4621
- val_not_convert = delta_options.name;
4846
+ vals_not_convert = [delta_options.name];
4622
4847
  }
4848
+ } else if (currentgraph.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH) {
4849
+ lodash.forEach(currentgraph.options.walkthrough_options.values.walkthrough, value => {
4850
+ if (value.trend === 'total') {
4851
+ vals_not_convert.push(value.key[0]);
4852
+ }
4853
+ });
4623
4854
  }
4624
- return val_not_convert;
4855
+ return vals_not_convert;
4625
4856
  };
4626
4857
 
4627
4858
  highchartsRenderer.updateFiltersShowNames = function (filters) {
@@ -4641,8 +4872,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4641
4872
  })
4642
4873
  };
4643
4874
 
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
+ highchartsRenderer.returnRawDataValue = function (type, value, format, field_name, vals_not_for_convert) {
4876
+ if (vals_not_for_convert && vals_not_for_convert.length && lodash.includes(vals_not_for_convert, value)) {
4646
4877
  return value;
4647
4878
  }
4648
4879
 
@@ -4954,12 +5185,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4954
5185
  }
4955
5186
  });
4956
5187
 
5188
+ // add virtual fields to rows if required
5189
+ let rows = widgetOptions.rows;
5190
+ if (!lodash.get(widgetOptions, 'rows.length') && widgetOptions.options.breakdown_options) {
5191
+ rows = [
5192
+ {
5193
+ id: -1,
5194
+ name: highchartsRenderer.VIRTUAL_FIELDS.WATERFALL_VARIANCE,
5195
+ type: 'Text',
5196
+ },
5197
+ ];
5198
+ }
5199
+
4957
5200
  // fill rows fields
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});
5201
+ lodash.forEach(rows, function (valObj) {
5202
+ if (lodash.includes(highchartsRenderer.VIRTUAL_FIELDS, valObj.name)) {
5203
+ legendFields.push(valObj);
5204
+ } else {
5205
+ fieldOb = lodash.find(fields, {id: valObj.id});
5206
+ if (fieldOb) {
5207
+ legendFields.push(fieldOb);
5208
+ lodash.remove(fields, {id: fieldOb.id});
5209
+ }
4963
5210
  }
4964
5211
  });
4965
5212
 
@@ -5649,7 +5896,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5649
5896
  return valToReturn;
5650
5897
  };
5651
5898
 
5652
-
5899
+
5653
5900
  highchartsRenderer.getChartAxisLabel = function(type) {
5654
5901
  return highchartsRenderer.chartsTypesInfo[type] ? highchartsRenderer.chartsTypesInfo[type].axisName : CHART_AXIS_DEFAULT_LABEL;
5655
5902
  };
@@ -6484,7 +6731,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6484
6731
  value_name: 'show',
6485
6732
  default_value: true,
6486
6733
  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
6734
+ disabled_fn: (value) => !value.show_out_of_x_axis
6488
6735
  && !value.show_out_of_data_series
6489
6736
  && !value.show_value
6490
6737
  && !value.show_x_axis
@@ -6525,8 +6772,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6525
6772
  element_label: '[X Axis]',
6526
6773
  value_name: 'show_x_axis',
6527
6774
  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
6775
+ clickFn: (value) => value.show = value.show
6776
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6530
6777
  : value.show,
6531
6778
  },
6532
6779
  {
@@ -6534,8 +6781,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6534
6781
  element_label: '[Data Series]',
6535
6782
  value_name: 'show_data_series',
6536
6783
  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
6784
+ clickFn: (value) => value.show = value.show
6785
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6539
6786
  : value.show,
6540
6787
  },
6541
6788
  {
@@ -6543,8 +6790,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6543
6790
  element_label: 'Value',
6544
6791
  value_name: 'show_value',
6545
6792
  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
6793
+ clickFn: (value) => value.show = value.show
6794
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6548
6795
  : value.show,
6549
6796
  },
6550
6797
  {
@@ -6552,8 +6799,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6552
6799
  element_label: '% Out of [X Axis]',
6553
6800
  value_name: 'show_out_of_x_axis',
6554
6801
  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
6802
+ clickFn: (value) => value.show = value.show
6803
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6557
6804
  : value.show,
6558
6805
  },
6559
6806
  {
@@ -6561,8 +6808,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6561
6808
  element_label: '% Out of [Data Series]',
6562
6809
  value_name: 'show_out_of_data_series',
6563
6810
  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
6811
+ clickFn: (value) => value.show = value.show
6812
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6566
6813
  : value.show,
6567
6814
  },
6568
6815
  ]
@@ -6736,16 +6983,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6736
6983
  value_name: 'name',
6737
6984
  element_label: 'Name',
6738
6985
  default_value: '_Variance'
6739
- }, {
6740
- element_type: 'input',
6741
- value_name: 'formula',
6742
- element_label: 'Formula',
6743
- default_value: 'x2-x1'
6744
6986
  }, {
6745
6987
  element_type: 'input',
6746
- value_name: 'color',
6747
- element_label: 'Color',
6748
- default_value: ''
6988
+ value_name: 'formula',
6989
+ element_label: 'Formula',
6990
+ default_value: 'x2-x1'
6991
+ }, {
6992
+ element_type: 'input',
6993
+ value_name: 'color',
6994
+ element_label: 'Color',
6995
+ default_value: ''
6749
6996
  }, {
6750
6997
  element_type: 'radio',
6751
6998
  value_name: 'chart',
@@ -6868,7 +7115,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6868
7115
  axisTooltipDescription: 'The category (usually an independent variable) is shown on the x-axis and should be between 2 to 5 total columns. ',
6869
7116
  legendTooltipTitle: 'Drag one field to further configure your x-axis.',
6870
7117
  legendTooltipDescription: 'The breakdown subdivides the chart by a category field for further analysis of what’s contributing to the increase or decrease.',
6871
- },
7118
+ },
7119
+ [highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH]: {
7120
+ name: 'Waterfall Walkthrough Chart ',
7121
+ label: 'Waterfall Walkthrough Chart ',
7122
+ title: 'TODO: add text',
7123
+ description: 'TODO: add text',
7124
+ axisName: 'Category',
7125
+ startedMessage: 'TODO: add text',
7126
+ axisTooltipTitle: 'TODO: add text',
7127
+ legendTooltipTitle: 'TODO: add text',
7128
+ },
6872
7129
  'combo-chart': {
6873
7130
  name: 'Combo Chart ',
6874
7131
  label: 'Combo Chart ',
@@ -7524,6 +7781,24 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7524
7781
  highchartsRenderer.suboptions["legends"],
7525
7782
  ]
7526
7783
  },
7784
+ {
7785
+ type: highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH,
7786
+ name: highchartsRenderer.chartsTypesInfo[highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH].name,
7787
+ class: 'google-visualization-charteditor-thumbs-columnchart',
7788
+ render: highchartsRenderer.ptRenderWaterfallWalkthrough,
7789
+ suboptions: [
7790
+ highchartsRenderer.suboptions["axisX"],
7791
+ highchartsRenderer.suboptions["tooltips"],
7792
+ highchartsRenderer.suboptions["label"],
7793
+ highchartsRenderer.suboptions["subtitle"],
7794
+ highchartsRenderer.suboptions["widget_library"],
7795
+ highchartsRenderer.suboptions["chart"],
7796
+ highchartsRenderer.suboptions["negative_number_format"],
7797
+ highchartsRenderer.suboptions["advanced"],
7798
+ highchartsRenderer.suboptions["legends"],
7799
+ ],
7800
+ hidden: true,
7801
+ },
7527
7802
  ]
7528
7803
  },
7529
7804
  ];
@@ -7680,7 +7955,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7680
7955
  _.forEach(Object.keys(dates), key => {
7681
7956
  const dateConfiguration = dates[key];
7682
7957
  const timestamp = dateConfiguration.timestamp;
7683
- if (timestamp) {
7958
+ if (timestamp) {
7684
7959
  const dateTzOffsetInSeconds = new Date(timestamp * 1000).getTimezoneOffset() * 60;
7685
7960
  dateConfiguration.displayedValue = new Date((timestamp + dateTzOffsetInSeconds) * 1000)
7686
7961
  .toLocaleDateString();
@@ -7976,10 +8251,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7976
8251
  };
7977
8252
 
7978
8253
  highchartsRenderer.createDateFromString = function (dateString, format) {
7979
- if ((format && !highchartsRenderer.isDateFormat(dateString, format)) || !highchartsRenderer.isDate(dateString)) {
8254
+ if (!(format && highchartsRenderer.isDateFormat(dateString, format) || highchartsRenderer.isDate(dateString))) {
7980
8255
  return null;
7981
8256
  }
7982
- const utcDate = format
8257
+ const utcDate = format
7983
8258
  ? moment_lib.utc(dateString, format, true)
7984
8259
  : moment_lib.utc(dateString);
7985
8260
  return utcDate.startOf('day').unix();
@@ -7997,7 +8272,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7997
8272
  }
7998
8273
 
7999
8274
  let filters = [];
8000
-
8275
+
8001
8276
  if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
8002
8277
  const colFilter = highchartsRenderer.createFilterObject(widget.cols[0]);
8003
8278
  const labels = [];
@@ -8025,7 +8300,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8025
8300
  col_value,
8026
8301
  highchartsRenderer.getDateFieldFormat(widget, widget.cols[index])
8027
8302
  );
8028
-
8303
+
8029
8304
  if ($.isEmptyObject(datetrange)) {
8030
8305
  return;
8031
8306
  }
@@ -8130,6 +8405,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8130
8405
  filter.is_excluded = false;
8131
8406
  } else {
8132
8407
  filter = highchartsRenderer.createDrillDownFilterObject(widget, widget.cols[0], colKey[0]);
8408
+ filters.push(filter);
8133
8409
  }
8134
8410
  filter.values = [];
8135
8411
  for (let i = 0; i < colKey.length; i++) {
@@ -8267,7 +8543,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8267
8543
  var data = res;
8268
8544
 
8269
8545
  lodash.forEach(datesFields, function (row) {
8270
- row.val_not_convert = highchartsRenderer.check_value_not_for_convert(widget, row.name);
8546
+ row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
8271
8547
  });
8272
8548
 
8273
8549
  if (datesFields.length > 0) {
@@ -8673,14 +8949,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8673
8949
  return rightPosition;
8674
8950
  case 'none':
8675
8951
  return none;
8952
+ }
8953
+ } else if (isLine) {
8954
+ return useNewUx ? leftPosition : rightPosition;
8955
+ } else if (isPie) {
8956
+ return useNewUx ? rightPosition : topPosition;
8676
8957
  }
8677
- } else if (isLine) {
8678
- return useNewUx ? leftPosition : rightPosition;
8679
- } else if (isPie) {
8680
- return useNewUx ? rightPosition : topPosition;
8681
- }
8682
8958
 
8683
- return useNewUx ? topPosition : bottomPosition;
8959
+ return useNewUx ? topPosition : bottomPosition;
8684
8960
  }
8685
8961
 
8686
8962
  highchartsRenderer.setYAxisMinMax = function (yAxis, axisYOptions) {
@@ -8695,7 +8971,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8695
8971
  }
8696
8972
 
8697
8973
  highchartsRenderer.getDateFieldFormat = function(widget, dateField) {
8698
- const aggregationConfig = widget.options && widget.options.date_aggregation_configs
8974
+ const aggregationConfig = widget.options && widget.options.date_aggregation_configs
8699
8975
  ? _.find(widget.options.date_aggregation_configs, { field_id: dateField.id })
8700
8976
  : null;
8701
8977
 
package/babel.config.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
3
- };
package/jest.config.js DELETED
@@ -1,27 +0,0 @@
1
- module.exports = {
2
- clearMocks: true,
3
- setupFilesAfterEnv: ['regenerator-runtime/runtime'],
4
- testPathIgnorePatterns: [
5
- "/node_modules/",
6
- ],
7
- transformIgnorePatterns: [
8
- "<rootDir>/node_modules/(?!jquery|lodash|moment/)",
9
- ],
10
- collectCoverage: true,
11
- collectCoverageFrom: [
12
- '**/*.js',
13
- '!**/*.config.js',
14
- '!**/build/**',
15
- '!**/coverage/**',
16
- '!**/node_modules/**',
17
- '!**/vendor/**'
18
- ],
19
- // coverageThreshold: {
20
- // "global": {
21
- // "branches": 100,
22
- // "functions": 100,
23
- // "lines": 100,
24
- // "statements": 100
25
- // }
26
- // },
27
- };
@@ -1,48 +0,0 @@
1
- import * as $ from 'jquery';
2
- import * as lodash from 'lodash';
3
- import * as moment from 'moment';
4
- import initPivotTable from "../src/pivottable";
5
- import initDRPivotTable from "../src/dr_pivottable";
6
-
7
- const getHighchartsRenderer = require('../src/highcharts_renderer');
8
- const DataFormatter = require('../src/dataformatter');
9
- const DEFAULT_USER_COLORS = {
10
- colors: ['#008aff', '#91e7e7', '#f37789', '#ffdc65', '#0e569d', '#bbe0ff', '#57b2ff', '#5ecfb9', '#c7ffda', '#179ab9'],
11
- variance_color: null
12
- };
13
-
14
- let highchartsRenderer = {};
15
- let _window = window;
16
- let _document = document;
17
-
18
- describe('highcharts_renderer', () => {
19
- beforeAll(() => {
20
- const Highcharts = {
21
- opt: {},
22
- setOptions: function(value) {Highcharts.opt = value;},
23
- numberFormat: function(value) { return value ;},
24
- getOptions: function() { return Highcharts.opt; }
25
- };
26
- _window.DataFormatter = DataFormatter;
27
- initPivotTable($, _window, _document);
28
- initDRPivotTable($, _window, _document);
29
-
30
- highchartsRenderer = getHighchartsRenderer($, _document, Highcharts, DEFAULT_USER_COLORS, highchartsRenderer,
31
- DataFormatter, lodash, moment, true)
32
- })
33
-
34
- describe('function isSystemField', () => {
35
- it('system name', () => {
36
- const field = {
37
- name: 'Doc_ID'
38
- };
39
- expect(highchartsRenderer.isSystemField(field)).toBe(true)
40
- });
41
- it('not system name', () => {
42
- const field = {
43
- name: 'field name'
44
- };
45
- expect(highchartsRenderer.isSystemField(field)).toBe(false)
46
- });
47
- });
48
- });