@datarailsshared/dr_renderer 1.2.379 → 1.2.383

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.379",
3
+ "version": "1.2.383",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -2575,7 +2575,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2575
2575
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, 1, false, true);
2576
2576
  if (drilldownFunc)
2577
2577
  chartOptions.drilldown = {}
2578
- else
2578
+ else if (!pivotData.isDrillDownDisabled)
2579
2579
  chartOptions.drilldown = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(pivotData, chartOptions, additionOptions, opts);
2580
2580
 
2581
2581
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
@@ -3102,7 +3102,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3102
3102
 
3103
3103
  highchartsRenderer.handleGridLines(additionOptions, chartOptions);
3104
3104
 
3105
- var isNotDrilldown = !(colAttrs && colAttrs.length > 1);
3105
+ var isNotDrilldown = !(colAttrs && colAttrs.length > 1) || pivotData.isDrillDownDisabled;
3106
3106
  if (lodash.get(opts, 'paletteOptions.widgetPalette', null)) {
3107
3107
  const mc_palette = lodash.find(lodash.get(opts.paletteOptions, 'monochromePalettes', []), { selected: true });
3108
3108
  chartOptions.colors = mc_palette ? mc_palette.colors : opts.paletteOptions.widgetPalette;
@@ -4881,6 +4881,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4881
4881
  rendererOptions: widget.options,
4882
4882
  dateValuesDictionary: pivotOptions ? pivotOptions.dateValuesDictionary : null,
4883
4883
  keysObject: pivotOptions ? pivotOptions.keysObject : null,
4884
+ isDrillDownDisabled: pivotOptions ? pivotOptions.isDrillDownDisabled : false,
4884
4885
  };
4885
4886
 
4886
4887
  if (!subopts.rendererOptions) {
@@ -6017,16 +6018,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6017
6018
  ];
6018
6019
 
6019
6020
  highchartsRenderer.getDefaultValueForChart = function (type, existing_options) {
6020
- var chartOpt;
6021
- if (type == highchartsRenderer.richTextSubType.type) {
6022
- chartOpt = highchartsRenderer.richTextSubType;
6023
- } else {
6024
- chartOpt = highchartsRenderer.getChartOptionsBySubType(type);
6025
- }
6026
- var valToReturn = {};
6021
+ const chartOpt = type === highchartsRenderer.richTextSubType.type
6022
+ ? highchartsRenderer.richTextSubType
6023
+ : highchartsRenderer.getChartOptionsBySubType(type);
6024
+
6025
+ let valToReturn = {};
6027
6026
  if (chartOpt) {
6028
- lodash.forEach(chartOpt.suboptions, function (suboption) {
6029
- valToReturn[suboption.category_type] = highchartsRenderer.getDefaultValueForSubOptions(suboption.category_type, existing_options);
6027
+ lodash.forEach(chartOpt.suboptions, (suboption) => {
6028
+ valToReturn[suboption.category_type] = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
6030
6029
  });
6031
6030
  }
6032
6031
 
@@ -6107,10 +6106,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6107
6106
  return key
6108
6107
  };
6109
6108
 
6110
- highchartsRenderer.getDefaultValueForSubOptions = function (type, existing_options) {
6111
- var valToReturn = {};
6112
- var option = highchartsRenderer.suboptions[type] || lodash.find(highchartsRenderer.suboptions, suboption => suboption.category_type === type);
6109
+ highchartsRenderer.getDefaultValueForSubOptions = function (option, existing_options) {
6110
+ const valToReturn = {};
6111
+
6113
6112
  if (option) {
6113
+ const type = option.category_type;
6114
6114
  lodash.forEach(option.elements, function (elem) {
6115
6115
  if (existing_options && lodash.has(existing_options, type + '.' + elem.value_name)) {
6116
6116
  valToReturn[elem.value_name] = lodash.get(existing_options, type + '.' + elem.value_name);
package/src/pivottable.js CHANGED
@@ -711,6 +711,7 @@ let initPivotTable = function($, window, document) {
711
711
  this.isFormattingAxisLabels = opts.rendererOptions && opts.rendererOptions.isFormattingAxisLabels;
712
712
  this.getFormattedColKeys = (keys) => opts.getFormattedColKeys(this, keys);
713
713
  this.getFormattedRowKeys = (keys) => opts.getFormattedRowKeys(this, keys);
714
+ this.isDrillDownDisabled = opts.isDrillDownDisabled;
714
715
 
715
716
  PivotData.forEachRecord(this.input, this.derivedAttributes, (function(_this) {
716
717
  return function(record) {
@@ -3436,17 +3436,19 @@ describe('highcharts_renderer', () => {
3436
3436
  highchartsRenderer.suboptions = tempSubOptions;
3437
3437
  });
3438
3438
 
3439
- it('should return an empty object if option type is not found', () => {
3440
- const type = 'invalid_type';
3439
+ it('should return an empty object if passed suboption is falsy', () => {
3441
3440
  const existing_options = {};
3442
- const result = highchartsRenderer.getDefaultValueForSubOptions(type, existing_options);
3443
- expect(result).toEqual({});
3441
+ const result1 = highchartsRenderer.getDefaultValueForSubOptions(null, existing_options);
3442
+ expect(result1).toEqual({});
3443
+
3444
+ const result2 = highchartsRenderer.getDefaultValueForSubOptions(undefined, existing_options);
3445
+ expect(result2).toEqual({});
3444
3446
  });
3445
3447
 
3446
3448
  it('should return default values for all elements in suboption', () => {
3447
- const type = 'type1';
3449
+ const suboption = suboptions.option1;
3448
3450
  const existing_options = {};
3449
- const result = highchartsRenderer.getDefaultValueForSubOptions(type, existing_options);
3451
+ const result = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
3450
3452
  expect(result).toEqual({
3451
3453
  value1: 'default1',
3452
3454
  value2: 42,
@@ -3454,14 +3456,14 @@ describe('highcharts_renderer', () => {
3454
3456
  });
3455
3457
 
3456
3458
  it('should use existing options if available', () => {
3457
- const type = 'type1';
3459
+ const suboption = suboptions.option1;
3458
3460
  const existing_options = {
3459
3461
  type1: {
3460
3462
  value1: 'existing1',
3461
3463
  value2: 99,
3462
3464
  },
3463
3465
  };
3464
- const result = highchartsRenderer.getDefaultValueForSubOptions(type, existing_options);
3466
+ const result = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
3465
3467
  expect(result).toEqual({
3466
3468
  value1: 'existing1',
3467
3469
  value2: 99,
@@ -3469,16 +3471,16 @@ describe('highcharts_renderer', () => {
3469
3471
  });
3470
3472
 
3471
3473
  it('should ignore elements with type "devider"', () => {
3472
- const type = 'type1';
3474
+ const suboption = suboptions.option1;
3473
3475
  const existing_options = {};
3474
- const result = highchartsRenderer.getDefaultValueForSubOptions(type, existing_options);
3476
+ const result = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
3475
3477
  expect(result).not.toHaveProperty('value3');
3476
3478
  });
3477
3479
 
3478
3480
  it('should clone default value if it is an object', () => {
3479
- const type = 'type3';
3481
+ const suboption = suboptions.option3;
3480
3482
  const existing_options = {};
3481
- const result = highchartsRenderer.getDefaultValueForSubOptions(type, existing_options);
3483
+ const result = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
3482
3484
  expect(result.value1).toEqual(suboptions.option3.elements[0].default_value);
3483
3485
  expect(result.value1).not.toBe(suboptions.option3.elements[0].default_value);
3484
3486
  });