@datarailsshared/dr_renderer 1.2.400 → 1.2.401

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.2.400",
3
+ "version": "1.2.401",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -158,11 +158,6 @@ let initDRPivotTable = function($, window, document) {
158
158
  return key;
159
159
  };
160
160
 
161
- DRPivotData.prototype.getInsight = function(colKey, rowKey) {
162
- const key = [rowKey, colKey].join(delim);
163
- return this.insights.get(key);
164
- }
165
-
166
161
  DRPivotData.prototype.getAttrsKeys = function(record, attrs) {
167
162
  const keys = [];
168
163
  for (let k = 0; k < attrs.length; k++) {
@@ -179,53 +174,7 @@ let initDRPivotTable = function($, window, document) {
179
174
  return keys.join(delim);
180
175
  }
181
176
 
182
- DRPivotData.prototype.buildInsights = function(rows, useServerTotalsCalculation) {
183
- for (let index = 0; index < rows.length; index++) {
184
- const record = rows[index];
185
- const insight = record.insight;
186
- delete record.insight;
187
-
188
- if (!insight) continue;
189
-
190
- if (useServerTotalsCalculation) {
191
- const flatRowKey = this.getFlatKey(record, this.rowAttrs);
192
- const flatColKey = this.getFlatKey(record, this.colAttrs);
193
-
194
- if (flatRowKey || flatColKey) {
195
- this.insights.set([flatRowKey, flatColKey].join(delim), insight);
196
- }
197
- continue;
198
- }
199
-
200
- const recordValues = _.values(record);
201
- const containsAverage = _.includes(recordValues, 'DR_Average');
202
- const containsOthers = _.includes(recordValues, 'DR_Others');
203
-
204
- const rowKey = processKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, containsAverage, containsOthers, (function(_this) {
205
- return function(key) {
206
- return _this.aggregator(_this, key, []);
207
- };
208
- })(this));
209
-
210
- const colKey = processKey(record, this.colTotals, this.colKeys, this.colAttrs, containsAverage, containsOthers, (function(_this) {
211
- return function(key) {
212
- return _this.aggregator(_this, [], key);
213
- };
214
- })(this));
215
-
216
- const flatRowKey = rowKey.join(delim);
217
- const flatColKey = colKey.join(delim);
218
-
219
- if (flatRowKey || flatColKey) {
220
- this.insights.set([flatRowKey, flatColKey].join(delim), insight);
221
- }
222
- }
223
- }
224
-
225
177
  DRPivotData.prototype.processRecord = function(record, useTotalsCalculation) {
226
- const insight = record.insight;
227
- delete record.insight;
228
-
229
178
  if (useTotalsCalculation) {
230
179
  if (!this.notFirst) {
231
180
  this.keysLength = _.filter(_.keys(record), key => !_.includes(['data_types', 'formats', 'values_formats'], key)).length - 1;
@@ -277,9 +226,6 @@ let initDRPivotTable = function($, window, document) {
277
226
  this.tree[flatRowKey][flatColKey].push(record);
278
227
  }
279
228
 
280
- if (insight && (flatRowKey || flatColKey)) {
281
- this.insights.set([flatRowKey, flatColKey].join(delim), insight);
282
- }
283
229
  return;
284
230
  }
285
231
 
@@ -303,15 +249,6 @@ let initDRPivotTable = function($, window, document) {
303
249
  };
304
250
  })(this));
305
251
 
306
- if (insight) {
307
- const flatRowKeyForInsight = rowKey.join(delim);
308
- const flatColKeyForInsight = colKey.join(delim);
309
-
310
- if (flatRowKeyForInsight || flatColKeyForInsight) {
311
- this.insights.set([flatRowKeyForInsight, flatColKeyForInsight].join(delim), insight);
312
- }
313
- }
314
-
315
252
  m = rowKey.length - 1;
316
253
  n = colKey.length - 1;
317
254
  if (m < 0 || n < 0) {
@@ -15,7 +15,6 @@
15
15
 
16
16
  /**
17
17
  * @typedef {Object} PivotModel
18
- * @property {(rows: Rows, useTotalsCalculation: boolean) => void} buildInsights
19
18
  */
20
19
 
21
20
  /**
@@ -713,33 +713,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
713
713
  return func;
714
714
  };
715
715
 
716
- highchartsRenderer.customFormatterTooltipInsights = function(pivotData, opts) {
717
- return {
718
- useHTML: true,
719
- outside: true,
720
- backgroundColor: 'transparent',
721
- borderWidth: 0,
722
- borderRadius: 0,
723
- shadow: false,
724
- shape: 'square',
725
- padding: 0,
726
- stickOnContact: true,
727
- hideDelay: 300,
728
- destroyWhenHiding: true,
729
- formatter: function () {
730
- const rowKey = pivotData.rowAttrs.length ? lodash.get(this.point, 'series.name') || "" : "";
731
- const colKey = lodash.get(this.point, 'initialName') || lodash.get(this.point, 'name') || this.x.name[0] || "";
732
-
733
- const insight = pivotData.getInsight(colKey, rowKey) || {};
734
- setTimeout(() => {
735
- var aggr = highchartsRenderer.defaultFormatterToTooltip(pivotData, opts);
736
- const formatted_value_to_return = aggr.bind(this)();
737
- opts.insightsTooltipFunc(lodash.merge(lodash.cloneDeep(this), { formatted_value_to_return }, insight));
738
- });
739
- }
740
- }
741
- }
742
-
743
716
  highchartsRenderer.defaultFormatterToTooltip = function (pivotData, opts, is_drill_down_pie) {
744
717
  var variant_name = null;
745
718
  var variant_name_default_name = null;
@@ -2679,17 +2652,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2679
2652
  };
2680
2653
  }
2681
2654
 
2682
- if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
2683
- chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
2684
- chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
2685
- }
2686
-
2687
- chartOptions.tooltip = opts.insightsTooltipFunc
2688
- ? highchartsRenderer.customFormatterTooltipInsights(pivotData, opts)
2689
- : {
2690
- formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
2691
- valueDecimals: 2,
2692
- };
2655
+ chartOptions.tooltip = {
2656
+ formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
2657
+ valueDecimals: 2,
2658
+ };
2693
2659
 
2694
2660
  chartOptions.xAxis = {
2695
2661
  categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
@@ -2765,11 +2731,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2765
2731
  };
2766
2732
  }
2767
2733
 
2768
- if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
2769
- chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
2770
- chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
2771
- }
2772
-
2773
2734
  chartOptions.tooltip = {
2774
2735
  formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
2775
2736
  valueDecimals: 2,
@@ -2862,11 +2823,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2862
2823
  };
2863
2824
  }
2864
2825
 
2865
- if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
2866
- chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
2867
- chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
2868
- }
2869
-
2870
2826
  chartOptions.tooltip = {
2871
2827
  formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
2872
2828
  valueDecimals: 2,
@@ -3103,12 +3059,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3103
3059
  }
3104
3060
 
3105
3061
 
3106
- chartOptions.tooltip = opts.insightsTooltipFunc
3107
- ? highchartsRenderer.customFormatterTooltipInsights(pivotData, opts)
3108
- : {
3109
- formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
3110
- valueDecimals: 2,
3111
- };
3062
+ chartOptions.tooltip = {
3063
+ formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
3064
+ valueDecimals: 2,
3065
+ };
3112
3066
 
3113
3067
  highchartsRenderer.handleGridLines(additionOptions, chartOptions);
3114
3068
 
@@ -3148,11 +3102,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3148
3102
  };
3149
3103
  }
3150
3104
 
3151
- if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
3152
- chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
3153
- chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
3154
- }
3155
-
3156
3105
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, rowAttrs.length, false);
3157
3106
 
3158
3107
  chartOptions.drilldown = highchartsRenderer.getDataLabelsStylesForDrillDown(additionOptions);
@@ -3236,12 +3185,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3236
3185
 
3237
3186
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, rowAttrs.length, false);
3238
3187
 
3239
- chartOptions.tooltip = opts.insightsTooltipFunc
3240
- ? highchartsRenderer.customFormatterTooltipInsights(pivotData, opts)
3241
- : {
3242
- formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
3243
- valueDecimals: 2,
3244
- };
3188
+ chartOptions.tooltip = {
3189
+ formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
3190
+ valueDecimals: 2,
3191
+ };
3245
3192
 
3246
3193
  if (additionOptions && additionOptions.chart) {
3247
3194
  chartOptions.colors = highchartsRenderer.getColorsWithOffset(additionOptions.chart.colors_offset);
@@ -3282,11 +3229,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3282
3229
  };
3283
3230
  }
3284
3231
 
3285
- if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
3286
- chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
3287
- chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
3288
- }
3289
-
3290
3232
  chartOptions.xAxis = {
3291
3233
  type: 'category',
3292
3234
  crosshair: true,
@@ -3423,12 +3365,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3423
3365
  if (additionOptions) {
3424
3366
  highchartsRenderer.setYAxisMinMax(chartOptions.yAxis, additionOptions.axisY);
3425
3367
  }
3426
- chartOptions.tooltip = opts.insightsTooltipFunc
3427
- ? highchartsRenderer.customFormatterTooltipInsights(pivotData, opts)
3428
- : {
3429
- formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
3430
- valueDecimals: 2,
3431
- };
3368
+ chartOptions.tooltip = {
3369
+ formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts),
3370
+ valueDecimals: 2,
3371
+ };
3432
3372
 
3433
3373
  if (additionOptions && additionOptions.chart) {
3434
3374
  chartOptions.colors = highchartsRenderer.getColorsWithOffset(additionOptions.chart.colors_offset);
@@ -3474,11 +3414,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3474
3414
  };
3475
3415
  }
3476
3416
 
3477
- if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
3478
- chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
3479
- chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
3480
- }
3481
-
3482
3417
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, rowAttrs.length, false);
3483
3418
 
3484
3419
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
@@ -3537,11 +3472,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3537
3472
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, rowAttrs.length, false);
3538
3473
  chartOptions.legend.reversed = true;
3539
3474
 
3540
- chartOptions.tooltip = opts.insightsTooltipFunc
3541
- ? highchartsRenderer.customFormatterTooltipInsights(pivotData, opts)
3542
- : {
3543
- formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts)
3544
- };
3475
+ chartOptions.tooltip = {
3476
+ formatter: highchartsRenderer.defaultFormatterToTooltip(pivotData, opts)
3477
+ };
3545
3478
 
3546
3479
  if (additionOptions && additionOptions.chart) {
3547
3480
  chartOptions.colors = highchartsRenderer.getColorsWithOffset(additionOptions.chart.colors_offset);
@@ -3563,11 +3496,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3563
3496
  };
3564
3497
  }
3565
3498
 
3566
- if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
3567
- chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
3568
- chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
3569
- }
3570
-
3571
3499
  chartOptions.xAxis = {
3572
3500
  categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
3573
3501
  title: {
@@ -3679,11 +3607,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3679
3607
  };
3680
3608
  }
3681
3609
 
3682
- if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
3683
- chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
3684
- chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
3685
- }
3686
-
3687
3610
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, 3, false);
3688
3611
  chartOptions.legend.useHTML = true;
3689
3612
  chartOptions.legend.labelFormatter = function() {
@@ -3800,11 +3723,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3800
3723
  };
3801
3724
  }
3802
3725
 
3803
- if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
3804
- chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
3805
- chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
3806
- }
3807
-
3808
3726
  if (waterfallOptions.colors) {
3809
3727
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, 3, false);
3810
3728
  chartOptions.legend.useHTML = true;
@@ -5530,7 +5448,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5530
5448
  options.chartOptions = lodash.merge(defaultOptions, options.chartOptions);
5531
5449
  };
5532
5450
 
5533
- highchartsRenderer.addPivotOptions = function (selectedTemplateWOData, widgetOptions, drilldownFunction, drillDownListFunction, insightsTooltipFunction, trackUserInsightsTooltipFunction) {
5451
+ highchartsRenderer.addPivotOptions = function (selectedTemplateWOData, widgetOptions, drilldownFunction, drillDownListFunction) {
5534
5452
  // Check if not rendered data, than it will render
5535
5453
 
5536
5454
  var fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplateWOData.fields);
@@ -5540,8 +5458,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5540
5458
  var valuesFields = [];
5541
5459
  var drilldownFunc = drilldownFunction;
5542
5460
  var drillDownListFunc = drillDownListFunction;
5543
- var insightsTooltipFunc = insightsTooltipFunction;
5544
- var trackUserInsightsTooltipFunc = trackUserInsightsTooltipFunction;
5545
5461
 
5546
5462
  // fill value fields
5547
5463
  lodash.forEach(widgetOptions.vals, function (valObj) {
@@ -5596,7 +5512,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5596
5512
  widgetOptions.pivot.valuesArray = valuesFields;
5597
5513
  widgetOptions.pivot.chartType = widgetOptions.chart_type;
5598
5514
  widgetOptions.pivot.chartOptions = widgetOptions.options;
5599
- widgetOptions.pivot.chartRender = highchartsRenderer.getChartRendererFunction(widgetOptions.pivot.chartType, drilldownFunc, drillDownListFunc, insightsTooltipFunc, trackUserInsightsTooltipFunc);
5515
+ widgetOptions.pivot.chartRender = highchartsRenderer.getChartRendererFunction(widgetOptions.pivot.chartType, drilldownFunc, drillDownListFunc);
5600
5516
 
5601
5517
  if (highchartsRenderer.isSortingOnBackendEnabled) return;
5602
5518
  // TODO: remove this logic after BE sort is implemented
@@ -6125,7 +6041,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6125
6041
  return toReturn;
6126
6042
  };
6127
6043
 
6128
- highchartsRenderer.getChartRendererFunction = function (newChartType, drilldownFunc, drillDownListFunc, insightsTooltipFunc, trackUserInsightsTooltipFunc) {
6044
+ highchartsRenderer.getChartRendererFunction = function (newChartType, drilldownFunc, drillDownListFunc) {
6129
6045
  var fnToReturn = null;
6130
6046
 
6131
6047
  if (newChartType == highchartsRenderer.richTextSubType.type) {
@@ -6156,8 +6072,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6156
6072
  highchartsRenderer.modifyEventPointForDrilldown(e, pivotData);
6157
6073
  drillDownListFunc(e);
6158
6074
  };
6159
- opt.insightsTooltipFunc = insightsTooltipFunc;
6160
- opt.trackUserInsightsTooltipFunc = trackUserInsightsTooltipFunc;
6161
6075
  } else {
6162
6076
  opt.drillDownListFunc = null;
6163
6077
  }
package/src/pivottable.js CHANGED
@@ -688,7 +688,6 @@ let initPivotTable = function($, window, document) {
688
688
  return true;
689
689
  });
690
690
  this.tree = {};
691
- this.insights = new Map();
692
691
 
693
692
  this.isKeysSortingDoneOnBackendSide = opts.keysObject && typeof opts.keysObject === 'object' && helpers.backendSortingKeysAreNotEmpty(opts.keysObject);
694
693
  if (this.isKeysSortingDoneOnBackendSide) {
@@ -345,7 +345,6 @@
345
345
  "variance_color": "#3DC5AA"
346
346
  }
347
347
  },
348
- "insightsTooltipFunc": null,
349
348
  "chart_series": [
350
349
  "Actuals"
351
350
  ],
@@ -12,7 +12,6 @@
12
12
  */
13
13
  /**
14
14
  * @typedef {Object} PivotModel
15
- * @property {(rows: Rows, useTotalsCalculation: boolean) => void} buildInsights
16
15
  */
17
16
  /**
18
17
  * @typedef {Object} GTROptions
@@ -57,9 +56,7 @@ export type PivotUtilities = {
57
56
  export type JQuery = {
58
57
  pivotUtilities: PivotUtilities;
59
58
  };
60
- export type PivotModel = {
61
- buildInsights: (rows: Rows, useTotalsCalculation: boolean) => void;
62
- };
59
+ export type PivotModel = Object;
63
60
  export type GTROptions = Object;
64
61
  /**
65
62
  * - BE data response