@datarailsshared/dr_renderer 1.2.234-rocket → 1.2.235-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,6 +31,12 @@ 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
34
40
  - run:
35
41
  name: Publish package
36
42
  command: npm publish . --access=public
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
3
+ };
package/jest.config.js ADDED
@@ -0,0 +1,27 @@
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.2.234-rocket",
3
+ "version": "1.2.235-dragons",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -9,7 +9,8 @@
9
9
  "tables"
10
10
  ],
11
11
  "scripts": {
12
- "login": "npm login"
12
+ "login": "npm login",
13
+ "test": "jest --coverage"
13
14
  },
14
15
  "author": "Sergey Spivakov",
15
16
  "repository": {
@@ -17,6 +18,21 @@
17
18
  "url": "git+https://bitbucket.org/datarails/dr_renderer.git"
18
19
  },
19
20
  "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
+ },
20
36
  "bugs": {
21
37
  "url": ""
22
38
  },
@@ -24,5 +40,10 @@
24
40
  "whitelistedNonPeerDependencies": [],
25
41
  "main": "src/index.js",
26
42
  "module": "src/index.js",
27
- "sideEffects": false
43
+ "sideEffects": false,
44
+ "jest": {
45
+ "setupFiles": [
46
+ "./setup-jest.js"
47
+ ]
48
+ }
28
49
  }
@@ -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',
@@ -466,7 +468,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
466
468
  highchartsRenderer.getOthersName(opts) :
467
469
  undefined;
468
470
  var drOthersInColumn = lodash.find(
469
- pivotData.getColKeys(),
471
+ pivotData.getColKeys(),
470
472
  keys => keys.length && (lodash.includes(keys, 'DR_Others') || lodash.includes(keys, othersName))
471
473
  );
472
474
 
@@ -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
  }
@@ -494,7 +496,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
494
496
  if (!cols && is_drill_down_pie) {
495
497
  cols = this.point.name;
496
498
  }
497
-
499
+
498
500
  if (drOthersInColumn) {
499
501
  if (!lodash.isArray(cols) && othersName === cols) {
500
502
  cols = ['DR_Others'];
@@ -619,6 +621,8 @@ 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;
625
+ const isTrendSeries = this.series.options.className === SERIES_CLASSNAMES.TREND_SERIES;
622
626
 
623
627
  var y = parseFloat(this.y);
624
628
  if (pivotData) {
@@ -629,10 +633,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
629
633
  }
630
634
  if (pivotData.rowAttrs.length == 0
631
635
  || this.series.options.className === 'totalSeries'
632
- || this.series.options.className === 'trendSeries') {
636
+ || isTrendSeries) {
633
637
  rows = [];
634
638
  }
635
- var cols = this.key;
639
+
640
+ var cols = lodash.get(this, 'point.options.colsForTotal') || this.key;
636
641
  if (!cols && is_drill_down_pie) {
637
642
  cols = this.name;
638
643
  }
@@ -647,7 +652,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
647
652
  if (variant_name && rows && rows[0] && variant_name == rows[0]) {
648
653
  rows[0] = variant_name_default_name;
649
654
  }
650
-
651
655
  try {
652
656
  if (is_drill_down_pie && !highchartsRenderer.selfStartsWith(series_name,"Series ")) {
653
657
  let temp = cols;
@@ -655,7 +659,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
655
659
  rows = temp;
656
660
  }
657
661
 
658
- var category_text = `<span style="font-weight: bold;">${ cols }${ isWaterfallBreakdown ? ': ' : ' ' }</span>`;
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>`;
659
665
  if (this.category) {
660
666
  category_text = '';
661
667
  }
@@ -664,7 +670,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
664
670
  series_text += ': '
665
671
  }
666
672
 
667
- if (pivotData.rowAttrs.length == 0) {
673
+ if (pivotData.rowAttrs.length == 0 && !isTrendSeries) {
668
674
  series_text = ': ';
669
675
  }
670
676
 
@@ -672,13 +678,15 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
672
678
  const modifiedRowsAndCols = highchartsRenderer.transformRowsAndColsForBreakdown(rows, cols, this.point, opts);
673
679
  rows = modifiedRowsAndCols.rows;
674
680
  cols = modifiedRowsAndCols.cols;
675
- }
681
+ }
676
682
 
677
683
  var aggr = pivotData.getAggregator(rows, cols);
678
684
 
679
685
  let formatted_value_to_return = $.pivotUtilities.getFormattedNumber(y, null, opts);
680
686
  if (aggr.value() || isWaterfallBreakdown) {
681
- formatted_value_to_return = $.pivotUtilities.getFormattedNumber(isWaterfallBreakdown ? y : aggr.value(), aggr, opts);
687
+ formatted_value_to_return = $.pivotUtilities.getFormattedNumber(
688
+ isWaterfallBreakdown || isWaterfallWalkthrough || isTrendSeries ? y : aggr.value(), aggr, opts
689
+ );
682
690
  }
683
691
 
684
692
  let wrappedFormattedValue = highchartsRenderer.getSpanWrapper(formatted_value_to_return);
@@ -1085,7 +1093,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1085
1093
 
1086
1094
  const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
1087
1095
  trendSeries.className = 'trendSeries';
1088
- trendSeries.name = 'Trend Line (' + trendSeries.name + ')';
1096
+ trendSeries.name = highchartsRenderer.getTrendSeriesName(trendSeries);
1089
1097
  trendSeries.dashStyle = 'shortdot';
1090
1098
  trendSeries.type = 'line';
1091
1099
  trendSeries.data = trendSeries.data.map((el, index) => a + b * (index + 1));
@@ -1254,7 +1262,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1254
1262
 
1255
1263
  const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
1256
1264
  trendSeries.className = 'trendSeries';
1257
- trendSeries.name = 'Trend Line (' + trendSeries.name + ')';
1265
+ trendSeries.name = highchartsRenderer.getTrendSeriesName(trendSeries);
1258
1266
  trendSeries.dashStyle = 'shortdot';
1259
1267
  trendSeries.type = 'line';
1260
1268
  trendSeries.data = trendSeries.data.map((data, index) => ({name: data.name, y: a + b * (index + 1)}));
@@ -1414,6 +1422,86 @@ 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.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
+
1417
1505
  highchartsRenderer.setChartTypeBySeriesType = function (type, series) {
1418
1506
  const types = {
1419
1507
  'line-chart': 'line',
@@ -1617,7 +1705,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1617
1705
  highchartsRenderer.getDataLabelsStylesForDrillDown = function(additionOptions) {
1618
1706
  let result = highchartsRenderer.getDataLabelsOptions(additionOptions, { dataLabels: {} });
1619
1707
 
1620
- if (!result.dataLabels) return {};
1708
+ if (!result.dataLabels) return {};
1621
1709
  return {
1622
1710
  activeDataLabelStyle: {
1623
1711
  color: result.dataLabels.color,
@@ -3173,7 +3261,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3173
3261
 
3174
3262
  highchartsRenderer.ptRenderWaterfallBreakdown = function (pivotData, opts, drilldownFunc, chartType) {
3175
3263
  let chartOptions = {};
3176
- const additionOptions = opts.chartOptions
3264
+ const additionOptions = opts.chartOptions
3177
3265
  ? opts.chartOptions
3178
3266
  : highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN);
3179
3267
 
@@ -3272,6 +3360,121 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3272
3360
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3273
3361
  };
3274
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
+
3275
3478
  highchartsRenderer.formatFieldValue = function (field, value) {
3276
3479
  let currentType = '';
3277
3480
  let format = field.format;
@@ -4340,6 +4543,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4340
4543
  }
4341
4544
  };
4342
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
+
4343
4557
  highchartsRenderer.rhPivotView = function (rowData, options, isTable = false, widget = null) {
4344
4558
  if (!rowData || !rowData) {
4345
4559
  if (options.onlyOptions) {
@@ -4348,16 +4562,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4348
4562
  return null;
4349
4563
  }
4350
4564
 
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;
4355
- const uniqueCategories = lodash.filter(
4356
- lodash.uniq(
4357
- lodash.map(rowData, row => row[widget.cols[0].name])
4358
- ),
4359
- value => !!value
4360
- );
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
+ }
4361
4587
 
4362
4588
  if (uniqueCategories && (uniqueCategories.length > maxCategories || uniqueCategories.length < minCategories )) {
4363
4589
  options.error_has_occurred = true;
@@ -4609,19 +4835,25 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4609
4835
  return highchartsRenderer.getWeekNumber(dateObj);
4610
4836
  };
4611
4837
 
4612
- highchartsRenderer.check_value_not_for_convert = function (currentgraph, field_name) {
4613
- let val_not_convert = null;
4838
+ highchartsRenderer.check_values_not_for_convert = function (currentgraph, field_name) {
4839
+ let vals_not_convert = [];
4614
4840
  if (lodash.has(currentgraph, "options.chartOptions.delta_column") && currentgraph.options.chartOptions.delta_column) {
4615
4841
  let delta_options = currentgraph.options.chartOptions.delta_column;
4616
4842
  if (delta_options.field == 'series' && currentgraph.rows && currentgraph.rows[0] &&
4617
4843
  currentgraph.rows[0].name == field_name) {
4618
- val_not_convert = delta_options.name;
4844
+ vals_not_convert = [delta_options.name];
4619
4845
  } else if (delta_options.field == 'category' && currentgraph.rows && currentgraph.cols[0] &&
4620
4846
  currentgraph.cols[0].name == field_name) {
4621
- val_not_convert = delta_options.name;
4847
+ vals_not_convert = [delta_options.name];
4622
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
+ });
4623
4855
  }
4624
- return val_not_convert;
4856
+ return vals_not_convert;
4625
4857
  };
4626
4858
 
4627
4859
  highchartsRenderer.updateFiltersShowNames = function (filters) {
@@ -4641,8 +4873,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4641
4873
  })
4642
4874
  };
4643
4875
 
4644
- highchartsRenderer.returnRawDataValue = function (type, value, format, field_name, val_not_for_convert) {
4645
- if (val_not_for_convert && val_not_for_convert == value) {
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)) {
4646
4878
  return value;
4647
4879
  }
4648
4880
 
@@ -4738,7 +4970,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4738
4970
  };
4739
4971
 
4740
4972
  highchartsRenderer.isSystemField = function (field) {
4741
- var regex = new RegExp("^(Calc_Model_Name|Calc_Model_ID|Parent_Name|Parent_Id|FileBox_ID|FileBox_Name|DataMapper_Name|Doc_ID|Doc_version|Label|Submission_Date|User|table_id|Latest_In_Dim|Tab_name|CP_Name|DT_.+|VT_.+|System_.+)$", "m");
4973
+ var regex = new RegExp("^(Parent_Name|Parent_Id|FileBox_ID|FileBox_Name|DataMapper_Name|Doc_ID|Doc_version|Label|Submission_Date|User|table_id|Latest_In_Dim|Tab_name|CP_Name|DT_.+|VT_.+|System_.+)$", "m");
4742
4974
 
4743
4975
  return (field.category && field.category.includes("")) || regex.test(field.name)
4744
4976
  };
@@ -5101,102 +5333,34 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5101
5333
 
5102
5334
  highchartsRenderer.addTemplateDataToCalcModel = function (selectedTemplate, calcModelOptions) {
5103
5335
  highchartsRenderer.setWidgetFieldsToTemplate(selectedTemplate);
5336
+
5337
+ const scenarioName = 'scenario';
5104
5338
  const fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplate.fields);
5339
+ const fieldScenarioAlias = _.find(fields, field => (field.alias || '').toLowerCase() === scenarioName)
5340
+ const fieldScenario = _.find(fields, field => (field.name || '').toLowerCase() === scenarioName)
5341
+ const filters = calcModelOptions.config && calcModelOptions.config.filters;
5105
5342
 
5106
- const fillData = (fieldsArr, ignoreFieldsIdToRemove = []) => {
5107
- const destinationArr = [];
5343
+ const filterFields = [];
5344
+ const valueFields = [];
5345
+ const dateFields = [];
5346
+ const dataTypeFields = [];
5347
+ const dataSeriesFields = [];
5348
+
5349
+ let scenarioField = lodash.get(calcModelOptions, 'config.scenario', undefined) || fieldScenarioAlias || fieldScenario;
5350
+ let fieldOb;
5351
+
5352
+ const fillData = (fieldsArr, destinationArr) => {
5108
5353
  lodash.forEach(fieldsArr, function (valObj) {
5109
- const fieldOb = lodash.find(fields, { id: valObj.id });
5354
+ fieldOb = lodash.find(fields, { id: valObj.id });
5110
5355
  if (fieldOb) {
5111
5356
  destinationArr.push(fieldOb);
5112
- !ignoreFieldsIdToRemove.includes(fieldOb.id) && lodash.remove(fields, { id: fieldOb.id });
5357
+ lodash.remove(fields, { id: fieldOb.id });
5113
5358
  }
5114
5359
  });
5115
-
5116
- return destinationArr;
5117
5360
  }
5118
5361
 
5119
- const canAssignPredefinedField = (() => {
5120
- const assignedFields = {};
5121
-
5122
- return function (predefinedData, type, field, bindValue, oppositeValue) {
5123
- if (!assignedFields[type]) {
5124
- assignedFields[type] = [];
5125
- }
5126
-
5127
- const isFieldMatch = predefinedData.regex.test((field[bindValue] || ''));
5128
-
5129
- const isFieldTypeCorrect = predefinedData.allowedFieldTypes
5130
- ? predefinedData.allowedFieldTypes.includes(field.type) : true;
5131
-
5132
- const isFieldAssigned = assignedFields[type].includes(field[bindValue].toLowerCase())
5133
- || assignedFields[type].includes(field[oppositeValue].toLowerCase());
5134
-
5135
- if (!(isFieldMatch && isFieldTypeCorrect)) return false;
5136
-
5137
- const loweredFieldValue = field[bindValue].toLowerCase();
5138
- assignedFields[type].push(loweredFieldValue, loweredFieldValue.replaceAll('_', ' '));
5139
-
5140
- return !isFieldAssigned;
5141
- }
5142
- })();
5143
-
5144
- const predefinedField = {
5145
- value: {
5146
- regex: /posting[_\s]amount/i,
5147
- allowedFieldTypes: ['Float', 'Integer'],
5148
- fields: [],
5149
- },
5150
- dataType: {
5151
- regex: /data[_\s]type/i,
5152
- allowedFieldTypes: ['Text'],
5153
- fields: [],
5154
- },
5155
- date: {
5156
- regex: /reporting[_\s]month/i,
5157
- allowedFieldTypes: ['Date'],
5158
- fields: [],
5159
- },
5160
- filters: {
5161
- isMultipleFields: true,
5162
- regex: /^(scenario|DR_ACC_L0)$/i,
5163
- fields: [],
5164
- },
5165
- dataSeries: {
5166
- isMultipleFields: true,
5167
- 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,
5168
- fields: [],
5169
- },
5170
- };
5171
-
5172
- if (!lodash.get(calcModelOptions, 'config', false)) {
5173
- /**
5174
- * alias stronger than name (order in array is important)
5175
- * Firstly we try to get predefined field by aliases and then fill in by names
5176
- * */
5177
- const fieldsDataQueueConfig = [
5178
- { value: 'alias', opposite: 'name' },
5179
- { value: 'name', opposite: 'alias' }
5180
- ];
5181
-
5182
- for (const key in predefinedField) {
5183
- lodash.forEach(fieldsDataQueueConfig, ({value, opposite}) => {
5184
- const ignoredFields = predefinedField[key].ignoreAssignedFields;
5185
- const result = predefinedField[key].isMultipleFields
5186
- ? lodash.filter(fields, field => canAssignPredefinedField(predefinedField[key], key, field, value, opposite, ignoredFields))
5187
- : [lodash.find(fields, field => canAssignPredefinedField(predefinedField[key], key, field, value, opposite, ignoredFields))].filter(f => !!f);
5188
-
5189
- if (result && result.length) {
5190
- predefinedField[key].fields.push(...result);
5191
- }
5192
- });
5193
- }
5194
- }
5195
-
5196
- const filters = lodash.get(calcModelOptions, 'config.filters', predefinedField.filters.fields);
5197
-
5198
5362
  lodash.forEach(filters, function (filterObj) {
5199
- const fieldOb = lodash.find(fields, { id: filterObj.id });
5363
+ fieldOb = lodash.find(fields, { id: filterObj.id });
5200
5364
  if (!fieldOb) return;
5201
5365
 
5202
5366
  filterObj.values = filterObj.values && lodash.map(filterObj.values, highchartsRenderer.decodeFunc);
@@ -5214,23 +5378,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5214
5378
  }
5215
5379
  });
5216
5380
 
5217
- const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by', predefinedField.dataSeries.fields);
5218
- const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field', predefinedField.date.fields[0])].filter(f => !!f);
5219
- const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field', predefinedField.value.fields[0])].filter(f => !!f);
5220
- const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field', predefinedField.dataType.fields[0])].filter(f => !!f);
5221
- const scenarioField = lodash.get(calcModelOptions, 'config.scenario', lodash.find(predefinedField.filters.fields, filter => [filter.name, filter.alias].includes('scenario')));
5222
-
5223
- /**
5224
- * We can have several common fields, so we should ignore deleting during fillData
5225
- * */
5226
- const commonFieldsId = [scenarioField.id];
5227
- const filterFields = fillData(filters, commonFieldsId);
5228
- const valueFields = fillData(storedAggFields, commonFieldsId);
5229
- const dateFields = fillData(storedDateFields, commonFieldsId);
5230
- const dataTypeFields = fillData(storedDataTypeFields, commonFieldsId);
5231
- const dataSeriesFields = fillData(storedGroupByFields, commonFieldsId);
5381
+ const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by', []);
5382
+ const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field', undefined)].filter(f => !!f);
5383
+ const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field', undefined)].filter(f => !!f);
5384
+ const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field', undefined)].filter(f => !!f);
5232
5385
 
5233
- lodash.remove(fields, _field => commonFieldsId.includes(_field.id));
5386
+ fillData(storedGroupByFields, dataSeriesFields);
5387
+ fillData(storedDateFields, dateFields);
5388
+ fillData(storedAggFields, valueFields);
5389
+ fillData(storedDataTypeFields, dataTypeFields);
5390
+ fillData(filters, filterFields);
5234
5391
 
5235
5392
  calcModelOptions.pivot = {
5236
5393
  fieldsArray: fields,
@@ -5738,7 +5895,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5738
5895
  return valToReturn;
5739
5896
  };
5740
5897
 
5741
-
5898
+
5742
5899
  highchartsRenderer.getChartAxisLabel = function(type) {
5743
5900
  return highchartsRenderer.chartsTypesInfo[type] ? highchartsRenderer.chartsTypesInfo[type].axisName : CHART_AXIS_DEFAULT_LABEL;
5744
5901
  };
@@ -6573,7 +6730,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6573
6730
  value_name: 'show',
6574
6731
  default_value: true,
6575
6732
  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',
6576
- disabled_fn: (value) => !value.show_out_of_x_axis
6733
+ disabled_fn: (value) => !value.show_out_of_x_axis
6577
6734
  && !value.show_out_of_data_series
6578
6735
  && !value.show_value
6579
6736
  && !value.show_x_axis
@@ -6614,8 +6771,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6614
6771
  element_label: '[X Axis]',
6615
6772
  value_name: 'show_x_axis',
6616
6773
  default_value: true,
6617
- clickFn: (value) => value.show = value.show
6618
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6774
+ clickFn: (value) => value.show = value.show
6775
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6619
6776
  : value.show,
6620
6777
  },
6621
6778
  {
@@ -6623,8 +6780,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6623
6780
  element_label: '[Data Series]',
6624
6781
  value_name: 'show_data_series',
6625
6782
  default_value: true,
6626
- clickFn: (value) => value.show = value.show
6627
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6783
+ clickFn: (value) => value.show = value.show
6784
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6628
6785
  : value.show,
6629
6786
  },
6630
6787
  {
@@ -6632,8 +6789,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6632
6789
  element_label: 'Value',
6633
6790
  value_name: 'show_value',
6634
6791
  default_value: true,
6635
- clickFn: (value) => value.show = value.show
6636
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6792
+ clickFn: (value) => value.show = value.show
6793
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6637
6794
  : value.show,
6638
6795
  },
6639
6796
  {
@@ -6641,8 +6798,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6641
6798
  element_label: '% Out of [X Axis]',
6642
6799
  value_name: 'show_out_of_x_axis',
6643
6800
  default_value: false,
6644
- clickFn: (value) => value.show = value.show
6645
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6801
+ clickFn: (value) => value.show = value.show
6802
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6646
6803
  : value.show,
6647
6804
  },
6648
6805
  {
@@ -6650,8 +6807,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6650
6807
  element_label: '% Out of [Data Series]',
6651
6808
  value_name: 'show_out_of_data_series',
6652
6809
  default_value: false,
6653
- clickFn: (value) => value.show = value.show
6654
- ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6810
+ clickFn: (value) => value.show = value.show
6811
+ ? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
6655
6812
  : value.show,
6656
6813
  },
6657
6814
  ]
@@ -6825,16 +6982,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6825
6982
  value_name: 'name',
6826
6983
  element_label: 'Name',
6827
6984
  default_value: '_Variance'
6828
- }, {
6829
- element_type: 'input',
6830
- value_name: 'formula',
6831
- element_label: 'Formula',
6832
- default_value: 'x2-x1'
6833
6985
  }, {
6834
6986
  element_type: 'input',
6835
- value_name: 'color',
6836
- element_label: 'Color',
6837
- default_value: ''
6987
+ value_name: 'formula',
6988
+ element_label: 'Formula',
6989
+ default_value: 'x2-x1'
6990
+ }, {
6991
+ element_type: 'input',
6992
+ value_name: 'color',
6993
+ element_label: 'Color',
6994
+ default_value: ''
6838
6995
  }, {
6839
6996
  element_type: 'radio',
6840
6997
  value_name: 'chart',
@@ -6957,7 +7114,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6957
7114
  axisTooltipDescription: 'The category (usually an independent variable) is shown on the x-axis and should be between 2 to 5 total columns. ',
6958
7115
  legendTooltipTitle: 'Drag one field to further configure your x-axis.',
6959
7116
  legendTooltipDescription: 'The breakdown subdivides the chart by a category field for further analysis of what’s contributing to the increase or decrease.',
6960
- },
7117
+ },
7118
+ [highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH]: {
7119
+ name: 'Waterfall Walkthrough Chart ',
7120
+ label: 'Waterfall Walkthrough Chart ',
7121
+ title: 'TODO: add text',
7122
+ description: 'TODO: add text',
7123
+ axisName: 'Category',
7124
+ startedMessage: 'TODO: add text',
7125
+ axisTooltipTitle: 'TODO: add text',
7126
+ legendTooltipTitle: 'TODO: add text',
7127
+ },
6961
7128
  'combo-chart': {
6962
7129
  name: 'Combo Chart ',
6963
7130
  label: 'Combo Chart ',
@@ -7613,6 +7780,24 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7613
7780
  highchartsRenderer.suboptions["legends"],
7614
7781
  ]
7615
7782
  },
7783
+ {
7784
+ type: highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH,
7785
+ name: highchartsRenderer.chartsTypesInfo[highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH].name,
7786
+ class: 'google-visualization-charteditor-thumbs-columnchart',
7787
+ render: highchartsRenderer.ptRenderWaterfallWalkthrough,
7788
+ suboptions: [
7789
+ highchartsRenderer.suboptions["axisX"],
7790
+ highchartsRenderer.suboptions["tooltips"],
7791
+ highchartsRenderer.suboptions["label"],
7792
+ highchartsRenderer.suboptions["subtitle"],
7793
+ highchartsRenderer.suboptions["widget_library"],
7794
+ highchartsRenderer.suboptions["chart"],
7795
+ highchartsRenderer.suboptions["negative_number_format"],
7796
+ highchartsRenderer.suboptions["advanced"],
7797
+ highchartsRenderer.suboptions["legends"],
7798
+ ],
7799
+ hidden: true,
7800
+ },
7616
7801
  ]
7617
7802
  },
7618
7803
  ];
@@ -7769,7 +7954,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7769
7954
  _.forEach(Object.keys(dates), key => {
7770
7955
  const dateConfiguration = dates[key];
7771
7956
  const timestamp = dateConfiguration.timestamp;
7772
- if (timestamp) {
7957
+ if (timestamp) {
7773
7958
  const dateTzOffsetInSeconds = new Date(timestamp * 1000).getTimezoneOffset() * 60;
7774
7959
  dateConfiguration.displayedValue = new Date((timestamp + dateTzOffsetInSeconds) * 1000)
7775
7960
  .toLocaleDateString();
@@ -8068,7 +8253,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8068
8253
  if (!(format && highchartsRenderer.isDateFormat(dateString, format) || highchartsRenderer.isDate(dateString))) {
8069
8254
  return null;
8070
8255
  }
8071
- const utcDate = format
8256
+ const utcDate = format
8072
8257
  ? moment_lib.utc(dateString, format, true)
8073
8258
  : moment_lib.utc(dateString);
8074
8259
  return utcDate.startOf('day').unix();
@@ -8086,7 +8271,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8086
8271
  }
8087
8272
 
8088
8273
  let filters = [];
8089
-
8274
+
8090
8275
  if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
8091
8276
  const colFilter = highchartsRenderer.createFilterObject(widget.cols[0]);
8092
8277
  const labels = [];
@@ -8114,7 +8299,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8114
8299
  col_value,
8115
8300
  highchartsRenderer.getDateFieldFormat(widget, widget.cols[index])
8116
8301
  );
8117
-
8302
+
8118
8303
  if ($.isEmptyObject(datetrange)) {
8119
8304
  return;
8120
8305
  }
@@ -8357,7 +8542,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8357
8542
  var data = res;
8358
8543
 
8359
8544
  lodash.forEach(datesFields, function (row) {
8360
- row.val_not_convert = highchartsRenderer.check_value_not_for_convert(widget, row.name);
8545
+ row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
8361
8546
  });
8362
8547
 
8363
8548
  if (datesFields.length > 0) {
@@ -8763,14 +8948,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8763
8948
  return rightPosition;
8764
8949
  case 'none':
8765
8950
  return none;
8951
+ }
8952
+ } else if (isLine) {
8953
+ return useNewUx ? leftPosition : rightPosition;
8954
+ } else if (isPie) {
8955
+ return useNewUx ? rightPosition : topPosition;
8766
8956
  }
8767
- } else if (isLine) {
8768
- return useNewUx ? leftPosition : rightPosition;
8769
- } else if (isPie) {
8770
- return useNewUx ? rightPosition : topPosition;
8771
- }
8772
8957
 
8773
- return useNewUx ? topPosition : bottomPosition;
8958
+ return useNewUx ? topPosition : bottomPosition;
8774
8959
  }
8775
8960
 
8776
8961
  highchartsRenderer.setYAxisMinMax = function (yAxis, axisYOptions) {
@@ -8785,7 +8970,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8785
8970
  }
8786
8971
 
8787
8972
  highchartsRenderer.getDateFieldFormat = function(widget, dateField) {
8788
- const aggregationConfig = widget.options && widget.options.date_aggregation_configs
8973
+ const aggregationConfig = widget.options && widget.options.date_aggregation_configs
8789
8974
  ? _.find(widget.options.date_aggregation_configs, { field_id: dateField.id })
8790
8975
  : null;
8791
8976
 
@@ -8835,6 +9020,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8835
9020
  }
8836
9021
  }
8837
9022
 
9023
+ highchartsRenderer.getTrendSeriesName = function(series) {
9024
+ return series.name ? 'Trend Line (' + series.name + ')' : 'Trend Line';
9025
+ }
9026
+
8838
9027
  return highchartsRenderer;
8839
9028
  };
8840
9029
 
@@ -0,0 +1,48 @@
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
+ });