@datarailsshared/dr_renderer 1.2.346 → 1.2.348

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.346",
3
+ "version": "1.2.348",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -143,7 +143,10 @@ const FEATURES = {
143
143
  ENABLE_NEW_WIDGET_VALUE_FORMATTING: 'enable_new_widget_value_formatting',
144
144
  ENABLE_SERVER_TOTALS_CALCULATION: 'enable_server_totals_calculation',
145
145
  FORMAT_AXIS: 'use_default_table_format_for_axis',
146
+ FORMAT_DATES_AS_OTHER_AXIS_TYPES: 'format_dates_as_other_axis_types',
146
147
  DASHBOARD_INSIGHT_TOOLTIP_RELATIVE_POSITION: 'dashboard_insight_tooltip_relative_position',
148
+ MULTIPLE_DIMENSION_TAGS: 'multiple_dimension_tags',
149
+ USE_NEW_SCENARIO_TAG: 'use_new_scenario_tag',
147
150
  }
148
151
 
149
152
  const TICKS_COUNT = 5;
@@ -178,11 +181,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
178
181
  highchartsRenderer.enabledNewWidgetValueFormatting = false;
179
182
  highchartsRenderer.relativePositionForInsightTooltips = false;
180
183
  let disableAnimation = false;
181
- if (document.ReportHippo && document.ReportHippo && document.ReportHippo.user) {
182
- highchartsRenderer.useTotalsCalculation = lodash.includes(document.ReportHippo.user.features, FEATURES.ENABLE_SERVER_TOTALS_CALCULATION);
184
+
185
+ highchartsRenderer.hasFeature = function(featureFlagKey) {
186
+ return lodash.includes(lodash.get(document, 'ReportHippo.user.features', []), featureFlagKey);
187
+ }
188
+
189
+ if (!!lodash.get(document, 'ReportHippo.user')) {
190
+ highchartsRenderer.useTotalsCalculation = highchartsRenderer.hasFeature(FEATURES.ENABLE_SERVER_TOTALS_CALCULATION);
183
191
  disableAnimation = document.ReportHippo.user.organization && document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.disable_animation
184
- highchartsRenderer.enabledNewWidgetValueFormatting = lodash.includes(document.ReportHippo.user.features, FEATURES.ENABLE_NEW_WIDGET_VALUE_FORMATTING);
185
- highchartsRenderer.relativePositionForInsightTooltips = lodash.includes(document.ReportHippo.user.features, FEATURES.DASHBOARD_INSIGHT_TOOLTIP_RELATIVE_POSITION);
192
+ highchartsRenderer.enabledNewWidgetValueFormatting = highchartsRenderer.hasFeature(FEATURES.ENABLE_NEW_WIDGET_VALUE_FORMATTING);
193
+ highchartsRenderer.relativePositionForInsightTooltips = highchartsRenderer.hasFeature(FEATURES.DASHBOARD_INSIGHT_TOOLTIP_RELATIVE_POSITION);
186
194
  }
187
195
 
188
196
  // fix issue of use tootip.stickOnContact with tooltip.outside , source: https://github.com/highcharts/highcharts/pull/15960
@@ -774,7 +782,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
774
782
  ? isWaterfallWalkthrough
775
783
  ? this.key
776
784
  : cols[0]
777
- : highchartsRenderer.isFormattingAxis(pivotData) && lodash.get(this, 'point.name') || cols
785
+ : highchartsRenderer.isFormattingAxisFeatureOn() && lodash.get(this, 'point.name') || cols
778
786
  );
779
787
 
780
788
  highchartsRenderer.replaceDrOthersKeys(cols, rows, drOthersInAxis, othersName);
@@ -1634,7 +1642,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1634
1642
  lodash.forEach(waterfallOptions.values.walkthrough, function(value, index) {
1635
1643
 
1636
1644
  let keys = [];
1637
- if (value.trend === 'total') {
1645
+ if (value.trend === 'total' || highchartsRenderer.isFormattingDatesAsOtherAxisTypes()) {
1638
1646
  keys = value.key;
1639
1647
  } else {
1640
1648
  lodash.forEach(value.key, (item) => {
@@ -1668,6 +1676,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1668
1676
  };
1669
1677
 
1670
1678
  let initialName = value.trend === 'total' ? value.formattedKey || value.key[0] : keys.join(highchartsRenderer.delimer);
1679
+ initialName = lodash.replace(
1680
+ lodash.unescape(initialName), highchartsRenderer.DR_OTHERS_KEY, highchartsRenderer.getOthersName(opts)
1681
+ )
1671
1682
  let name = value.trend === 'total' ? initialName : highchartsRenderer.getFormattedColKey(initialName, pivotData);
1672
1683
 
1673
1684
  let color = '';
@@ -1684,9 +1695,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1684
1695
  if (val !== 0) {
1685
1696
  resultObject.data.push({
1686
1697
  y: val,
1687
- name: lodash.replace(
1688
- lodash.unescape(name), highchartsRenderer.DR_OTHERS_KEY, highchartsRenderer.getOthersName(opts)
1689
- ),
1698
+ name,
1699
+ initialName,
1690
1700
  totalIndex: value.trend === 'total' ? index : undefined,
1691
1701
  isSum: value.trend === 'total',
1692
1702
  isTotal: value.trend === 'total',
@@ -3498,7 +3508,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3498
3508
  color: lodash.get(additionOptions, `${ highchartsRenderer.getLabelOptionKey(additionOptions) }.font_color`)
3499
3509
  || LABEL_DEFAULT_OPTIONS.color,
3500
3510
  },
3501
- highchartsRenderer.getDataLabelsStyle(additionOptions),
3511
+ highchartsRenderer.getDataLabelsStyle(additionOptions)
3502
3512
  ),
3503
3513
  },
3504
3514
  labels: {
@@ -4853,13 +4863,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4853
4863
  if (!pivotOptions) {
4854
4864
  return;
4855
4865
  }
4866
+
4856
4867
  var subopts = {
4857
4868
  sorters: pivotOptions ? pivotOptions.sorters : null,
4858
4869
  sortByValueAttrs: pivotOptions ? pivotOptions.sortByValueAttrs : null,
4859
4870
  cols: lodash.map(pivotOptions.axisArray, 'name'),
4860
4871
  rows: lodash.map(pivotOptions.legendArray, 'name'),
4861
- colFormats: highchartsRenderer.getTableFormatInfosForWidgetFields(widget.cols),
4862
- rowFormats: highchartsRenderer.getTableFormatInfosForWidgetFields(widget.rows),
4872
+ colFormats: highchartsRenderer.getTableFormatInfosForWidgetFields(widget, pivotOptions, widget.cols),
4873
+ rowFormats: highchartsRenderer.getTableFormatInfosForWidgetFields(widget, pivotOptions, widget.rows),
4863
4874
  rendererOptions: widget.options,
4864
4875
  dateValuesDictionary: pivotOptions ? pivotOptions.dateValuesDictionary : null,
4865
4876
  };
@@ -5123,11 +5134,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5123
5134
  };
5124
5135
 
5125
5136
  highchartsRenderer.isSystemField = function (field) {
5126
- const features = lodash.get(document, 'ReportHippo.user.features', []);
5127
5137
  const dynamicSystemFields = [];
5128
5138
 
5129
- const areMultipleAndScenarioTags = lodash.includes(features, 'multiple_dimension_tags')
5130
- && lodash.includes(features, 'use_new_scenario_tag');
5139
+ const areMultipleAndScenarioTags = highchartsRenderer.hasFeature(FEATURES.MULTIPLE_DIMENSION_TAGS)
5140
+ && highchartsRenderer.hasFeature(FEATURES.USE_NEW_SCENARIO_TAG);
5131
5141
 
5132
5142
  if (areMultipleAndScenarioTags) {
5133
5143
  dynamicSystemFields.push('Scenario', 'Budget Cycle');
@@ -8371,7 +8381,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8371
8381
 
8372
8382
  const fiscalYearMonthsModifier = highchartsRenderer.getFiscalYearMonthModifier();
8373
8383
 
8374
- const initialDateString = fieldnametoFilter;
8375
8384
  if (format) {
8376
8385
  format = format.replace(/y/g, 'Y');
8377
8386
  format = format.replace(/d/g, 'D');
@@ -8379,78 +8388,86 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8379
8388
  format = 'MMM YYYY';
8380
8389
  }
8381
8390
 
8382
- var range = {datetype: "range", val: {todate: 0, fromdate: 0}}
8391
+ const range = { datetype: "range", val: { todate: 0, fromdate: 0 } };
8392
+ const timeframe = highchartsRenderer.getTimeframeByFormat(format);
8383
8393
 
8384
- if (format) {
8385
- if (!highchartsRenderer.isDateFormat(fieldnametoFilter, format)) {
8386
- return {};
8387
- } else {
8394
+ const isFormattedDate = format && highchartsRenderer.isDateFormat(fieldnametoFilter, format);
8395
+ if (isFormattedDate || highchartsRenderer.isDate(fieldnametoFilter)) {
8396
+ const initialDateString = fieldnametoFilter;
8397
+ if (isFormattedDate) {
8388
8398
  fieldnametoFilter = moment_lib(fieldnametoFilter, format, true).toISOString();
8389
8399
  }
8390
- } else if (!highchartsRenderer.isDate(fieldnametoFilter))
8391
- return {};
8392
-
8393
- var dt = new Date(fieldnametoFilter);
8394
-
8395
- const timeframe = highchartsRenderer.getTimeframeByFormat(format);
8396
- switch (timeframe) {
8397
- case 'day':
8398
- range.val.fromdate = Math.round(Date.UTC(
8399
- dt.getFullYear(),
8400
- dt.getMonth(),
8401
- dt.getDate(),
8402
- 0,
8403
- 0,
8404
- 0
8405
- ) / 1000);
8406
- range.val.todate = range.val.fromdate + 60 * 60 * 24 - 1;
8407
- return range;
8408
- break;
8409
- case 'month':
8410
- range.val.fromdate = Math.round(
8411
- Date.UTC(
8400
+ const dt = new Date(fieldnametoFilter);
8401
+ switch (timeframe) {
8402
+ case 'day':
8403
+ range.val.fromdate = Math.round(Date.UTC(
8412
8404
  dt.getFullYear(),
8413
8405
  dt.getMonth(),
8406
+ dt.getDate(),
8407
+ 0,
8408
+ 0,
8409
+ 0
8410
+ ) / 1000);
8411
+ range.val.todate = range.val.fromdate + 60 * 60 * 24 - 1;
8412
+ return range;
8413
+ case 'month':
8414
+ range.val.fromdate = Math.round(
8415
+ Date.UTC(
8416
+ dt.getFullYear(),
8417
+ dt.getMonth(),
8418
+ 1,
8419
+ 0, 0, 0, 0
8420
+ ) / 1000)
8421
+ let lastDay = new Date(dt.getFullYear(), dt.getMonth() + 1, 0);
8422
+ range.val.todate = Math.round(
8423
+ Date.UTC(
8424
+ lastDay.getFullYear(),
8425
+ lastDay.getMonth(),
8426
+ lastDay.getDate(),
8427
+ 23,
8428
+ 59,
8429
+ 59) / 1000)
8430
+ return range;
8431
+ case 'year':
8432
+ range.val.fromdate = Math.round(Date.UTC(
8433
+ dt.getFullYear(),
8434
+ fiscalYearMonthsModifier || dt.getMonth(),
8414
8435
  1,
8415
8436
  0, 0, 0, 0
8437
+ ) / 1000);
8438
+
8439
+ let lastDay2 = new Date(dt.getFullYear() + 1, fiscalYearMonthsModifier || 0, 0);
8440
+ range.val.todate = Math.round(Date.UTC(
8441
+ lastDay2.getFullYear(),
8442
+ lastDay2.getMonth(),
8443
+ lastDay2.getDate(),
8444
+ 23, 59, 59
8416
8445
  ) / 1000)
8417
- let lastDay = new Date(dt.getFullYear(), dt.getMonth() + 1, 0);
8418
- range.val.todate = Math.round(
8419
- Date.UTC(
8420
- lastDay.getFullYear(),
8421
- lastDay.getMonth(),
8422
- lastDay.getDate(),
8423
- 23,
8424
- 59,
8425
- 59) / 1000)
8426
- return range;
8427
- break;
8428
- case 'year':
8429
- range.val.fromdate = Math.round(Date.UTC(
8430
- dt.getFullYear(),
8431
- fiscalYearMonthsModifier || dt.getMonth(),
8432
- 1,
8433
- 0, 0, 0, 0
8434
- ) / 1000);
8435
-
8436
- let lastDay2 = new Date(dt.getFullYear() + 1, fiscalYearMonthsModifier || 0, 0);
8437
- range.val.todate = Math.round(Date.UTC(
8438
- lastDay2.getFullYear(),
8439
- lastDay2.getMonth(),
8440
- lastDay2.getDate(),
8441
- 23, 59, 59
8442
- ) / 1000)
8443
- return range;
8444
- break;
8445
- case 'quarter':
8446
- const utcDate = moment_lib.utc(initialDateString, format, true);
8447
- range.val.fromdate = lodash.cloneDeep(utcDate).startOf(timeframe).add(fiscalYearMonthsModifier, 'M').unix();
8448
- range.val.todate = lodash.cloneDeep(utcDate).endOf(timeframe).add(fiscalYearMonthsModifier, 'M').endOf('M').unix();
8449
- return range;
8450
- default:
8451
- return "";
8446
+ return range;
8447
+ case 'quarter':
8448
+ const utcDate = moment_lib.utc(initialDateString, format, true);
8449
+ range.val.fromdate = lodash.cloneDeep(utcDate).startOf(timeframe).add(fiscalYearMonthsModifier, 'M').unix();
8450
+ range.val.todate = lodash.cloneDeep(utcDate).endOf(timeframe).add(fiscalYearMonthsModifier, 'M').endOf('M').unix();
8451
+ return range;
8452
+ default:
8453
+ return "";
8454
+ }
8455
+ } else if (!lodash.isNaN(fieldnametoFilter)) {
8456
+ const utcDate = moment_lib.unix(fieldnametoFilter).utc();
8457
+ const fromDateMoment = lodash.cloneDeep(utcDate).startOf(timeframe);
8458
+ const toDateMoment = lodash.cloneDeep(utcDate).endOf(timeframe);
8459
+
8460
+ if (lodash.includes(['year', 'quarter'], timeframe)) {
8461
+ fromDateMoment.add(fiscalYearMonthsModifier, 'M');
8462
+ toDateMoment.add(fiscalYearMonthsModifier, 'M').endOf('M');
8463
+ }
8464
+
8465
+ range.val.fromdate = fromDateMoment.unix();
8466
+ range.val.todate = toDateMoment.unix();
8467
+ return range;
8452
8468
  }
8453
8469
 
8470
+ return {};
8454
8471
  };
8455
8472
 
8456
8473
  highchartsRenderer.createDateFromString = function (dateString, format) {
@@ -8464,6 +8481,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8464
8481
  }
8465
8482
 
8466
8483
  highchartsRenderer.prepareDrillDownFilters = function (r_keys, c_keys, widget) {
8484
+ const isFormattingDatesAsOtherAxisTypes = highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
8467
8485
  let row_key = r_keys;
8468
8486
  let col_key = c_keys;
8469
8487
  if (widget.options &&
@@ -8481,16 +8499,18 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8481
8499
  const labels = [];
8482
8500
  colFilter.values = [];
8483
8501
  lodash.forEach(col_key, function (col_value) {
8502
+ let label = col_value;
8484
8503
  if (widget.cols[0].type === 'Date' && col_value !== NULL_VALUE) {
8485
- let date = highchartsRenderer.createDateFromString(
8486
- col_value,
8487
- highchartsRenderer.getDateFieldFormat(widget, widget.cols[0])
8488
- );
8504
+ const format = highchartsRenderer.getDateFieldFormat(widget, widget.cols[0]);
8505
+ let date = isFormattingDatesAsOtherAxisTypes ? +col_value : highchartsRenderer.createDateFromString(col_value, format);
8489
8506
  colFilter.values.push(date);
8507
+ label = isFormattingDatesAsOtherAxisTypes
8508
+ ? highchartsRenderer.returnRawDataValue(widget.cols[0].type, +col_value, format, widget.cols[0].name)
8509
+ : col_value;
8490
8510
  } else {
8491
8511
  colFilter.values.push(col_value);
8492
8512
  }
8493
- labels.push(col_value);
8513
+ labels.push(label);
8494
8514
  });
8495
8515
  colFilter.value_to_show = labels.join(', ');
8496
8516
  filters.push(colFilter);
@@ -8508,17 +8528,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8508
8528
  if (widget && widget.cols[index]) {
8509
8529
  let temp = highchartsRenderer.createFilterObject(widget.cols[index]);
8510
8530
  if (widget.cols[index].type === 'Date' && col_value !== NULL_VALUE) {
8511
- let datetrange = highchartsRenderer.createDateTypeFromValue(
8512
- col_value,
8513
- highchartsRenderer.getDateFieldFormat(widget, widget.cols[index]),
8514
- null
8515
- );
8531
+ const format = highchartsRenderer.getDateFieldFormat(widget, widget.cols[index]);
8532
+ let datetrange = highchartsRenderer.createDateTypeFromValue(col_value, format);
8516
8533
 
8517
8534
  if ($.isEmptyObject(datetrange)) {
8518
8535
  return;
8519
8536
  }
8520
8537
  temp.values = datetrange;
8521
- temp.values.label = col_value;
8538
+ temp.values.label = isFormattingDatesAsOtherAxisTypes
8539
+ ? highchartsRenderer.returnRawDataValue(widget.cols[index].type, +col_value, format, widget.cols[index].name)
8540
+ : col_value;
8522
8541
  } else {
8523
8542
  temp.values = [col_value];
8524
8543
  }
@@ -8534,15 +8553,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8534
8553
  if (widget.rows[index].type === 'Date' && row_value !== NULL_VALUE) {
8535
8554
  let datetrange = highchartsRenderer.createDateTypeFromValue(
8536
8555
  row_value,
8537
- highchartsRenderer.getDateFieldFormat(widget, widget.rows[index]),
8538
- null
8556
+ highchartsRenderer.getDateFieldFormat(widget, widget.rows[index])
8539
8557
  );
8540
8558
 
8541
8559
  if ($.isEmptyObject(datetrange)) {
8542
8560
  return;
8543
8561
  }
8544
8562
  temp.values = datetrange;
8545
- temp.values.label = row_value;
8563
+ temp.values.label = isFormattingDatesAsOtherAxisTypes
8564
+ ? highchartsRenderer.returnRawDataValue(widget.rows[index].type, +row_value, format, widget.rows[index].name)
8565
+ : row_value;
8546
8566
  } else {
8547
8567
  temp.values = [row_value];
8548
8568
  }
@@ -8592,6 +8612,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8592
8612
  };
8593
8613
 
8594
8614
  highchartsRenderer.prepareDrillDownGraphFilters = function (r_key, c_key, widget) {
8615
+ const isFormattingDatesAsOtherAxisTypes = highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
8595
8616
  let rowKey = r_key;
8596
8617
  let colKey = c_key;
8597
8618
  let widgetOptions = typeof widget.options === 'string' ? JSON.parse(widget.options) : widget.options;
@@ -8605,9 +8626,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8605
8626
  let filter = lodash.find(filters, {name: widget.rows[i].name});
8606
8627
  if (filter) {
8607
8628
  filter.is_excluded = false;
8608
- filter.values = widget.rows[i].type === 'Date' && rowKey[i] !== NULL_VALUE ?
8609
- highchartsRenderer.createDateTypeFromValue(rowKey[i], highchartsRenderer.getDateFieldFormat(widget, widget.rows[i])) :
8610
- [rowKey[i]];
8629
+ filter.values = widget.rows[i].type === 'Date' && rowKey[i] !== NULL_VALUE
8630
+ ? highchartsRenderer.createDateTypeFromValue(
8631
+ rowKey[i],
8632
+ highchartsRenderer.getDateFieldFormat(widget, widget.rows[i])
8633
+ )
8634
+ : [rowKey[i]];
8611
8635
  } else {
8612
8636
  filters.push(highchartsRenderer.createDrillDownFilterObject(widget, widget.rows[i], rowKey[i]))
8613
8637
  }
@@ -8624,12 +8648,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8624
8648
  filter.values = [];
8625
8649
  for (let i = 0; i < colKey.length; i++) {
8626
8650
  filter.values.push(
8627
- widget.cols[0].type === 'Date' && colKey[i] !== NULL_VALUE
8651
+ widget.cols[0].type === 'Date' && colKey[i] !== NULL_VALUE && !isFormattingDatesAsOtherAxisTypes
8628
8652
  ? highchartsRenderer.createDateFromString(
8629
8653
  colKey[i],
8630
8654
  highchartsRenderer.getDateFieldFormat(widget, widget.cols[0])
8631
8655
  )
8632
- : colKey[i]
8656
+ : +colKey[i]
8633
8657
  );
8634
8658
  }
8635
8659
  } else if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_WALKTHROUGH) {
@@ -8652,9 +8676,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8652
8676
  let filter = lodash.find(filters, {name: widget.cols[i].name});
8653
8677
  if (filter) {
8654
8678
  filter.is_excluded = false;
8655
- filter.values = widget.cols[i].type === 'Date' && colKey[i] !== NULL_VALUE ?
8656
- highchartsRenderer.createDateTypeFromValue(colKey[i], highchartsRenderer.getDateFieldFormat(widget, widget.cols[i])) :
8657
- [colKey[i]];
8679
+ filter.values = widget.cols[i].type === 'Date' && colKey[i] !== NULL_VALUE
8680
+ ? highchartsRenderer.createDateTypeFromValue(
8681
+ colKey[i],
8682
+ highchartsRenderer.getDateFieldFormat(widget, widget.cols[i])
8683
+ )
8684
+ : [colKey[i]];
8658
8685
  } else {
8659
8686
  filters.push(highchartsRenderer.createDrillDownFilterObject(widget, widget.cols[i], colKey[i]))
8660
8687
  }
@@ -8674,7 +8701,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8674
8701
  filtOb.field = field.id;
8675
8702
  filtOb.name = highchartsRenderer.decodeFunc(field.name);
8676
8703
  if (field.type === 'Date' && value !== NULL_VALUE) {
8677
- filtOb.values = highchartsRenderer.createDateTypeFromValue(value, highchartsRenderer.getDateFieldFormat(widget, field));
8704
+ filtOb.values = highchartsRenderer.createDateTypeFromValue(
8705
+ value,
8706
+ highchartsRenderer.getDateFieldFormat(widget, field)
8707
+ );
8678
8708
  }
8679
8709
 
8680
8710
  return filtOb;
@@ -8745,6 +8775,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8745
8775
  };
8746
8776
 
8747
8777
  highchartsRenderer.getWidgetDataSorters = function (res, widget, defaultDateFormat) {
8778
+
8779
+ const isFormattingDatesAsOtherAxisTypes = highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
8780
+
8748
8781
  if ($.pivotUtilities && !$.pivotUtilities.additionalFieldsList) {
8749
8782
  $.pivotUtilities.additionalFieldsList = [
8750
8783
  {key: 'DR_Average', name: 'DR_Average'},
@@ -8767,35 +8800,47 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8767
8800
  }
8768
8801
 
8769
8802
  datesFields = lodash.map(datesFields, function (row) {
8770
- return { "format": highchartsRenderer.getDateFieldFormat(widget, row), "name": row.name, "type": row.type, "values": [], "sorting": row.sorting } //'MMM - yyyy' format
8803
+ return {
8804
+ "format": isFormattingDatesAsOtherAxisTypes ? null : highchartsRenderer.getDateFieldFormat(widget, row),
8805
+ "name": row.name,
8806
+ "type": row.type,
8807
+ "values": [],
8808
+ "sorting": row.sorting
8809
+ } //'MMM - yyyy' format
8771
8810
  });
8772
8811
 
8773
8812
  var data = res;
8774
8813
 
8775
- lodash.forEach(datesFields, function (row) {
8776
- row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
8777
- });
8778
-
8814
+ if (!isFormattingDatesAsOtherAxisTypes) {
8815
+ lodash.forEach(datesFields, function (row) {
8816
+ row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
8817
+ });
8818
+ }
8819
+
8779
8820
  if (datesFields.length > 0) {
8780
8821
  lodash.forEach(data, function (element) {
8781
8822
  for (var i in datesFields) {
8782
8823
  if (element.hasOwnProperty(datesFields[i].name)) {
8783
8824
  datesFields[i].values.push(element[datesFields[i].name]);
8784
- const dateStringValue = highchartsRenderer.returnRawDataValue(
8785
- datesFields[i].type, element[datesFields[i].name],
8786
- defaultDateFormat ? defaultDateFormat : datesFields[i].format,
8787
- datesFields[i].name, datesFields[i].val_not_convert);
8788
- if (widget.pivot) {
8789
- if (!widget.pivot.dateValuesDictionary) {
8790
- widget.pivot.dateValuesDictionary = {}
8825
+
8826
+ if (!isFormattingDatesAsOtherAxisTypes) {
8827
+ const dateStringValue = highchartsRenderer.returnRawDataValue(
8828
+ datesFields[i].type, element[datesFields[i].name],
8829
+ defaultDateFormat ? defaultDateFormat : datesFields[i].format,
8830
+ datesFields[i].name, datesFields[i].val_not_convert);
8831
+ if (widget.pivot) {
8832
+ if (!widget.pivot.dateValuesDictionary) {
8833
+ widget.pivot.dateValuesDictionary = {}
8834
+ }
8835
+ widget.pivot.dateValuesDictionary[dateStringValue] = element[datesFields[i].name];
8791
8836
  }
8792
- widget.pivot.dateValuesDictionary[dateStringValue] = element[datesFields[i].name];
8837
+ element[datesFields[i].name] = dateStringValue;
8793
8838
  }
8794
- element[datesFields[i].name] = dateStringValue;
8795
8839
  }
8796
8840
  }
8797
8841
  });
8798
8842
  }
8843
+
8799
8844
  lodash.forEach(datesFields, function (row) {
8800
8845
  row.values = lodash.uniq(row.values);
8801
8846
 
@@ -8817,10 +8862,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8817
8862
  row.values = lodash.reverse(row.values);
8818
8863
  }
8819
8864
  delete row.sorting;
8820
- row.values = lodash.map(row.values, function (val) {
8821
- return highchartsRenderer.returnRawDataValue(row.type, val, row.format, row.name, row.val_not_convert) + "";
8822
- })
8823
8865
 
8866
+ if (!isFormattingDatesAsOtherAxisTypes) {
8867
+ row.values = lodash.map(row.values, function (val) {
8868
+ return highchartsRenderer.returnRawDataValue(row.type, val, row.format, row.name, row.val_not_convert) + "";
8869
+ });
8870
+ }
8824
8871
  });
8825
8872
 
8826
8873
  /* date string */
@@ -8903,7 +8950,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8903
8950
  } else if (field.sorting && field.sorting.type == "largestToSmallest") {
8904
8951
  if (field.sorting.is_absolute)
8905
8952
  return $.pivotUtilities.largeToSmallSortByAbsolute;
8906
-
8907
8953
  return $.pivotUtilities.largeToSmallSort;
8908
8954
  } else {
8909
8955
  return $.pivotUtilities.sortAs(field.values);
@@ -9255,10 +9301,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9255
9301
  filter.values.push(colValue);
9256
9302
  });
9257
9303
  } else {
9304
+ const format = highchartsRenderer.getDateFieldFormat(widget, field);
9258
9305
  filter.values = field.type === 'Date' && colKey !== NULL_VALUE
9259
- ? highchartsRenderer.createDateTypeFromValue(colKey, highchartsRenderer.getDateFieldFormat(widget, field))
9306
+ ? highchartsRenderer.createDateTypeFromValue(colKey, format)
9260
9307
  : [colKey];
9261
- filter.value_to_show = colKey;
9308
+ filter.value_to_show = field.type === 'Date' && highchartsRenderer.isFormattingDatesAsOtherAxisTypes()
9309
+ ? highchartsRenderer.returnRawDataValue(field.type, +colKey, format, field.name)
9310
+ : colKey;
9262
9311
  }
9263
9312
  }
9264
9313
 
@@ -9343,29 +9392,40 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9343
9392
  return !highchartsRenderer.enabledNewWidgetValueFormatting || !highchartsRenderer.isChartWithMultiValues(pivotData) || !isSecondaryAxis || isCustomFormat;
9344
9393
  }
9345
9394
 
9346
- highchartsRenderer.isFormattingAxis = function (pivotData) {
9395
+ highchartsRenderer.isFormattingNumberAxis = function (pivotData) {
9347
9396
  return highchartsRenderer.isFormattingAxisFeatureOn() && pivotData.isFormattingAxisLabels;
9348
9397
  }
9349
9398
 
9399
+ highchartsRenderer.isFormattingDatesAsOtherAxisTypes = function () {
9400
+ return highchartsRenderer.isFormattingAxisFeatureOn() && highchartsRenderer.hasFeature(FEATURES.FORMAT_DATES_AS_OTHER_AXIS_TYPES);
9401
+ }
9402
+
9350
9403
  highchartsRenderer.isFormattingAxisFeatureOn = function () {
9351
- return lodash.includes(lodash.get(document, 'ReportHippo.user.features', []), FEATURES.FORMAT_AXIS);
9404
+ return highchartsRenderer.hasFeature(FEATURES.FORMAT_AXIS);
9352
9405
  }
9353
9406
 
9354
9407
  // Method for getting formatted kyes for Axis (cols, rows)
9355
- // TODO: Move here dates formatting from highchartsRenderer.getWidgetDataSorters. Ticket created: DR-22009
9356
9408
  highchartsRenderer.getFormattedKey = function (initialKey, pivotData, type) {
9357
9409
  const isFlatKey = lodash.isString(initialKey) || lodash.isNumber(initialKey);
9358
- if (highchartsRenderer.isFormattingAxis(pivotData) && (isFlatKey || lodash.isArray(initialKey))) {
9410
+ if (isFlatKey || lodash.isArray(initialKey)) {
9359
9411
  let values = isFlatKey ? initialKey.toString().split(highchartsRenderer.delimer) : lodash.cloneDeep(initialKey);
9360
9412
  if (values) {
9361
9413
  lodash.forEach(values, (value, key) => {
9362
- const formatInfo = pivotData[type][key];
9363
- if (formatInfo && formatInfo.type !== 'Date') {
9364
- const format = formatInfo.format;
9365
- const valueToFloat = parseFloat(value);
9366
- values[key] = !isNaN(valueToFloat) && format
9367
- ? highchartsRenderer.formatValue('n', format, valueToFloat).value
9368
- : value;
9414
+ const formatInfo = pivotData[type][key] || {};
9415
+ const valueToFloat = parseFloat(value);
9416
+ const isDate = formatInfo.type === 'Date';
9417
+ const isDateFormatting = isDate && highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
9418
+ const isNumberFormatting = !isDate && formatInfo.format && highchartsRenderer.isFormattingNumberAxis(pivotData);
9419
+ const isApplyingFormat = !isNaN(valueToFloat) && (isNumberFormatting || isDateFormatting);
9420
+ if (isApplyingFormat) {
9421
+ values[key] = highchartsRenderer.returnRawDataValue(
9422
+ formatInfo.type,
9423
+ valueToFloat,
9424
+ formatInfo.format,
9425
+ formatInfo.name,
9426
+ formatInfo.val_not_convert,
9427
+ true
9428
+ );
9369
9429
  }
9370
9430
  });
9371
9431
  return isFlatKey ? values.join(highchartsRenderer.delimer) : values;
@@ -9384,7 +9444,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9384
9444
 
9385
9445
  highchartsRenderer.getFormattedKeys = function(pivotData, isCols, keys) {
9386
9446
  keys = keys || (isCols ? pivotData.getColKeys() : pivotData.getRowKeys());
9387
- return highchartsRenderer.isFormattingAxis(pivotData)
9447
+ return highchartsRenderer.isFormattingAxisFeatureOn()
9388
9448
  ? lodash.map(keys, key => highchartsRenderer.getFormattedKey(key, pivotData, isCols ? 'colFormats' : 'rowFormats'))
9389
9449
  : keys;
9390
9450
  }
@@ -9398,7 +9458,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9398
9458
  }
9399
9459
 
9400
9460
  highchartsRenderer.modifyEventPointForDrilldown = function(e, pivotData) {
9401
- if (!highchartsRenderer.isFormattingAxis(pivotData)) {
9461
+ if (!highchartsRenderer.isFormattingAxisFeatureOn()) {
9402
9462
  return;
9403
9463
  }
9404
9464
  e.point = lodash.cloneDeep(e.point);
@@ -9408,19 +9468,23 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9408
9468
  }
9409
9469
 
9410
9470
  highchartsRenderer.getSeriesNameInFormatterContext = function(context, pivotData) {
9411
- return ((highchartsRenderer.isFormattingAxis(pivotData) && lodash.get(context, 'series.userOptions.initialName')) || context.series.name || '') + "";
9471
+ return ((highchartsRenderer.isFormattingAxisFeatureOn() && lodash.get(context, 'series.userOptions.initialName')) || context.series.name || '') + "";
9412
9472
  }
9413
9473
 
9414
9474
  highchartsRenderer.getColsInFormatterContext = function(context, pivotData) {
9415
9475
  return lodash.get(context, 'point.options.colsForTotal')
9416
- || highchartsRenderer.isFormattingAxis(pivotData) && (lodash.get(context, 'point.initialName') || lodash.get(context, 'options.initialName'))
9476
+ || highchartsRenderer.isFormattingAxisFeatureOn() && (lodash.get(context, 'point.initialName') || lodash.get(context, 'options.initialName'))
9417
9477
  || context.key;
9418
9478
  }
9419
9479
 
9420
- highchartsRenderer.getTableFormatInfosForWidgetFields = function(fields) {
9480
+ highchartsRenderer.getTableFormatInfosForWidgetFields = function(widget, pivotOptions, fields) {
9421
9481
  return lodash.map(fields, field => ({
9422
9482
  type: field.type,
9423
- format: highchartsRenderer.decodeFunc(field.format),
9483
+ name: field.name,
9484
+ format: field.type === 'Date'
9485
+ ? highchartsRenderer.getDateFieldFormat(widget, field) || pivotOptions.defaultDateFormat
9486
+ : highchartsRenderer.decodeFunc(field.format),
9487
+ val_not_convert: highchartsRenderer.check_values_not_for_convert(widget, field.name),
9424
9488
  }));
9425
9489
  }
9426
9490
 
@@ -4840,23 +4840,23 @@ describe('highcharts_renderer', () => {
4840
4840
  });
4841
4841
  });
4842
4842
 
4843
- describe('Function isFormattingAxis', () => {
4843
+ describe('Function isFormattingNumberAxis', () => {
4844
4844
  it('should return true if FF is true', () => {
4845
4845
  const pivotData = { isFormattingAxisLabels: true };
4846
4846
  lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
4847
- expect(highchartsRenderer.isFormattingAxis(pivotData)).toEqual(true);
4847
+ expect(highchartsRenderer.isFormattingNumberAxis(pivotData)).toEqual(true);
4848
4848
  });
4849
4849
 
4850
4850
  it('should return false if FF is false', () => {
4851
4851
  const pivotData = { isFormattingAxisLabels: true };
4852
4852
  lodash.set(document, 'ReportHippo.user.features', []);
4853
- expect(highchartsRenderer.isFormattingAxis(pivotData)).toEqual(false);
4853
+ expect(highchartsRenderer.isFormattingNumberAxis(pivotData)).toEqual(false);
4854
4854
  });
4855
4855
 
4856
4856
  it('should return false if FF is true but isFormattingAxisLabels for chart is false', () => {
4857
4857
  const pivotData = { isFormattingAxisLabels: false };
4858
4858
  lodash.set(document, 'ReportHippo.user.features', []);
4859
- expect(highchartsRenderer.isFormattingAxis(pivotData)).toEqual(false);
4859
+ expect(highchartsRenderer.isFormattingNumberAxis(pivotData)).toEqual(false);
4860
4860
  });
4861
4861
  });
4862
4862
 
@@ -4959,7 +4959,32 @@ describe('highcharts_renderer', () => {
4959
4959
  });
4960
4960
 
4961
4961
  describe('formatting Dates', () => {
4962
- it('should return NOT formatted multivalue colKey as array', () => {
4962
+ it('should return formatted multivalue colKey as array (format_dates_as_other_axis_types is ON)', () => {
4963
+ lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types', 'use_default_table_format_for_axis']);
4964
+ const initialKey = [1687277052, 1687277052];
4965
+ const pivotData = {
4966
+ colFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
4967
+ isFormattingAxisLabels: true,
4968
+ };
4969
+ const type = 'colFormats';
4970
+ const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
4971
+ expect(formattedKey).toEqual(['06/20/2023', 'Jun-23']);
4972
+ });
4973
+
4974
+ it('should return formatted multivalue rowKey as array (format_dates_as_other_axis_types is ON)', () => {
4975
+ lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types', 'use_default_table_format_for_axis']);
4976
+ const initialKey = [1687277052, 1687277052];
4977
+ const pivotData = {
4978
+ rowFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
4979
+ isFormattingAxisLabels: true,
4980
+ };
4981
+ const type = 'rowFormats';
4982
+ const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
4983
+ expect(formattedKey).toEqual(['06/20/2023', 'Jun-23']);
4984
+ });
4985
+
4986
+ it('should return NOT formatted multivalue colKey as array (format_dates_as_other_axis_types is OFF)', () => {
4987
+ lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
4963
4988
  const initialKeyAlreadyFormatted = ['10/10/2020', '10/10/2021'];
4964
4989
  const pivotData = {
4965
4990
  colFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
@@ -4970,7 +4995,8 @@ describe('highcharts_renderer', () => {
4970
4995
  expect(formattedKey).toEqual(initialKeyAlreadyFormatted);
4971
4996
  });
4972
4997
 
4973
- it('should return NOT formatted multivalue rowKey as array', () => {
4998
+ it('should return NOT formatted multivalue rowKey as array (format_dates_as_other_axis_types is OFF)', () => {
4999
+ lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
4974
5000
  const initialKeyAlreadyFormatted = ['10/10/2020', '10/10/2021'];
4975
5001
  const pivotData = {
4976
5002
  rowFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],