@datarailsshared/dr_renderer 1.4.10 → 1.4.23

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.
@@ -8,7 +8,6 @@ on:
8
8
  push:
9
9
  branches:
10
10
  - 'master'
11
- - 'DEVOPS-239-GH-Actions'
12
11
 
13
12
  concurrency:
14
13
  group: '${{ github.ref }}-${{ github.workflow }}'
@@ -23,8 +22,8 @@ jobs:
23
22
  branch_postfix: false
24
23
  main_branch: 'master'
25
24
  version_prefix: '1.4'
26
- skip_publish: ${{ github.event_name != 'pull_request' }}
25
+ skip_publish: ${{ github.event_name == 'pull_request' }}
27
26
  secrets:
28
27
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
29
- SSH_PRIVATE_KEY: ${{ secrets.GITHUB_PRIVATE_KEY }}
28
+ SSH_PRIVATE_KEY: ${{ secrets.GH_PRIVATE_KEY }}
30
29
 
package/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @Datarails/RnD_Team_Dragons @Datarails/Admins @Datarails/devops_agent
1
+ * @Datarails/RnD_Team_Dragons
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.4.10",
3
+ "version": "1.4.23",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -1417,21 +1417,25 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1417
1417
  chart_series = chart_series.concat(trendSerieses);
1418
1418
 
1419
1419
  highchartsRenderer.moveSeriesToSecondYAxisIfNeeded(chart_series, pivotData, chartOptions, additionOptions, opts, opts.total && opts.totalSeriesSettings && opts.totalSeriesSettings.secondaryAxis);
1420
-
1421
1420
  const chartType = chartOptions && chartOptions.chart && chartOptions.chart.type ? chartOptions.chart.type : null;
1421
+ const isCombiLineForecastChart = opts.chartOptions.isSmartQueriesEnabled;
1422
1422
  const smartQuerySeries = isChartTypeSupportedForSmartQuery(chartType)
1423
- ? smartQueriesHelper.createSingleDataSeriesForForecast(chart_series, opts.chartOptions, pivotData)
1423
+ ? smartQueriesHelper.createSingleDataSeriesForForecast(chart_series, opts.chartOptions, pivotData, isCombiLineForecastChart)
1424
1424
  : null;
1425
1425
 
1426
1426
  if (smartQuerySeries) {
1427
1427
  if (chart_series.length > 1) {
1428
- lodash.remove(chart_series, s =>
1429
- (s.name && lodash.includes(s.name, 'SQ_Actuals')) || s.name === 'Forecast'
1430
- );
1428
+ if (isCombiLineForecastChart) {
1429
+ chart_series = smartQuerySeries;
1430
+ } else {
1431
+ lodash.remove(chart_series, s =>
1432
+ (s.name && lodash.includes(s.name, 'SQ_Actuals')) || s.name === 'Forecast'
1433
+ );
1434
+ chart_series.push(smartQuerySeries);
1435
+ }
1431
1436
  } else {
1432
- chart_series = []
1437
+ chart_series = [smartQuerySeries];
1433
1438
  }
1434
- chart_series.push(smartQuerySeries);
1435
1439
  }
1436
1440
 
1437
1441
  return chart_series;
@@ -5,7 +5,7 @@ const DR_SCENARIO = {
5
5
  Forecast: 'Forecast',
6
6
  };
7
7
 
8
- function createSingleDataSeriesForForecast(chart_series, chartOptions, pivotData) {
8
+ function createSingleDataSeriesForForecast(chart_series, chartOptions, pivotData, isChartCombiLine) {
9
9
  const { actuals, forecast, smart_query } = chartOptions.chart;
10
10
  const input = pivotData.input;
11
11
 
@@ -14,12 +14,14 @@ function createSingleDataSeriesForForecast(chart_series, chartOptions, pivotData
14
14
  if (!smart_query || !hasSQActuals) return null;
15
15
 
16
16
  const midMonthOffset = 0.5
17
- return chart_series.length === 1
18
- ? buildChartSeriesFromPivotInputOnly(input, actuals, forecast, midMonthOffset)
19
- : buildChartSeriesFromSeries(chart_series, actuals, forecast, midMonthOffset);
17
+ return chart_series.length === 1
18
+ ? buildChartSeriesFromPivotInputOnly(input, actuals, forecast, midMonthOffset, chart_series[0].name)
19
+ : (isChartCombiLine ?
20
+ buildChartSeriesForMultipleSeriesCombinedLine(chart_series, input, actuals, forecast, midMonthOffset) :
21
+ buildChartSeriesFromSeries(chart_series, actuals, forecast, midMonthOffset));
20
22
  }
21
23
 
22
- function buildChartSeriesFromPivotInputOnly(input, actuals, forecast, midMonthOffset) {
24
+ function buildChartSeriesFromPivotInputOnly(input, actuals, forecast, midMonthOffset, name) {
23
25
  const filtered = input.filter(item =>
24
26
  (item.Scenario === DR_SCENARIO.SQ_Actuals || item.Scenario === DR_SCENARIO.Forecast) &&
25
27
  item.Amount !== 0
@@ -27,15 +29,15 @@ function buildChartSeriesFromPivotInputOnly(input, actuals, forecast, midMonthOf
27
29
 
28
30
  const data = filtered.map(item => ({
29
31
  y: item.Amount,
30
- name: item.Reporting_Month,
31
- initialName: item.Reporting_Month,
32
+ name: item['Reporting Month'],
33
+ initialName: item['Reporting Month'],
32
34
  type: item.Scenario,
33
35
  })).sort((a, b) => new Date(a.name) - new Date(b.name));
34
36
 
35
37
  const sqCount = input.filter(item => item.Scenario === DR_SCENARIO.SQ_Actuals).length;
36
38
 
37
39
  return {
38
- name: "Forecast Smart Query",
40
+ name,
39
41
  data,
40
42
  zoneAxis: "x",
41
43
  zones: [
@@ -45,6 +47,42 @@ function buildChartSeriesFromPivotInputOnly(input, actuals, forecast, midMonthOf
45
47
  };
46
48
  }
47
49
 
50
+ function buildChartSeriesForMultipleSeriesCombinedLine(chart_series, input, actuals, forecast, midMonthOffset) {
51
+ const resultingSeries = [];
52
+ for (let i = 0; i < chart_series.length; i++) {
53
+ const series = chart_series[i];
54
+ if (!series || !series.data || !series.data.length) continue;
55
+
56
+ const data = input.filter(item => item['Scenario Cycle'] === series.name &&
57
+ (item['Scenario'] === DR_SCENARIO.SQ_Actuals || item['Scenario'] === DR_SCENARIO.Forecast))
58
+ .map(item => ({
59
+ y: item.Amount,
60
+ name: item['Reporting Month'],
61
+ initialName: item['Reporting Month'],
62
+ type: item.Scenario,
63
+ })).sort((a, b) => new Date(a.name) - new Date(b.name));
64
+
65
+ if (!data.length) {
66
+ resultingSeries.push(series);
67
+ continue;
68
+ }
69
+
70
+ const sqCount = data.filter(item => item.type === DR_SCENARIO.SQ_Actuals).length;
71
+ resultingSeries.push(
72
+ {
73
+ name: series.name,
74
+ data,
75
+ zoneAxis: "x",
76
+ zones: [
77
+ { value: sqCount - midMonthOffset, dashStyle: actuals },
78
+ { dashStyle: forecast },
79
+ ],
80
+ }
81
+ )
82
+ }
83
+ return resultingSeries;
84
+ }
85
+
48
86
  function buildChartSeriesFromSeries(chart_series, actuals, forecast, midMonthOffset) {
49
87
  const seriesA = lodash.find(chart_series, s => s.name && lodash.includes(s.name, DR_SCENARIO.SQ_Actuals));
50
88
  const seriesB = lodash.find(chart_series, s => s.name && lodash.includes(s.name, DR_SCENARIO.Forecast));
@@ -6854,7 +6854,9 @@ describe('highcharts_renderer', () => {
6854
6854
  ]);
6855
6855
  });
6856
6856
  it('should prepare appropriate chart series for standard input', () => {
6857
- opts = {};
6857
+ opts = {
6858
+ chartOptions: {}
6859
+ };
6858
6860
  chartType = null;
6859
6861
  const value = highchartsRenderer.ptCreateColumnSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, isNotDrillDown, additionalOptionsMock, opts, chartOptions, chartType);
6860
6862
  expect(value).toEqual([
@@ -7083,7 +7085,9 @@ describe('highcharts_renderer', () => {
7083
7085
  "#b3060e",
7084
7086
  "#70000a"
7085
7087
  ];
7086
- opts = {};
7088
+ opts = {
7089
+ chartOptions: {}
7090
+ };
7087
7091
  chartOptions = {
7088
7092
  chart: {
7089
7093
  type: '',
@@ -7241,7 +7245,8 @@ describe('highcharts_renderer', () => {
7241
7245
 
7242
7246
  it('should prepare appropriate chart series, when opts \'total\' configuration is set to true', ()=> {
7243
7247
  opts = {
7244
- total: true
7248
+ total: true,
7249
+ chartOptions: {}
7245
7250
  };
7246
7251
  pivotDataMock.colTotals = {
7247
7252
  'col 1': {value: () => 123450},
@@ -7310,6 +7315,7 @@ describe('highcharts_renderer', () => {
7310
7315
 
7311
7316
  it('should prepare appropriate chart series, when opts \'trendLine\' configuration is set to true', ()=> {
7312
7317
  opts = {
7318
+ chartOptions: {},
7313
7319
  trendLine: true
7314
7320
  };
7315
7321
  const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);