@datarailsshared/dr_renderer 1.5.88 → 1.5.89

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.5.88",
3
+ "version": "1.5.89",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -9877,7 +9877,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9877
9877
  lodash.forEach(values, (value, key) => {
9878
9878
  const formatInfo = pivotData[type][key] || {};
9879
9879
  const valueToFloat = parseFloat(value);
9880
- const isDate = formatInfo.type === 'Date';
9880
+ const isDate = formatInfo.type === 'Date' && (moment_lib(valueToFloat).isValid() || moment_lib(value).isValid());
9881
9881
  const isDateFormatting = isDate && highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
9882
9882
  const isNumberFormatting = !isDate && formatInfo.format && highchartsRenderer.isFormattingNumberAxis(pivotData);
9883
9883
 
@@ -5089,6 +5089,10 @@ describe('highcharts_renderer', () => {
5089
5089
  });
5090
5090
 
5091
5091
  describe('formatting Dates', () => {
5092
+ afterEach(() => {
5093
+ lodash.set(document, 'ReportHippo.user.features', []);
5094
+ });
5095
+
5092
5096
  it('should return formatted multivalue colKey as array (format_dates_as_other_axis_types is ON)', () => {
5093
5097
  lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types']);
5094
5098
  const initialKey = [1687277052, 1687277052];
@@ -5136,6 +5140,29 @@ describe('highcharts_renderer', () => {
5136
5140
  const formattedKey = highchartsRenderer.getFormattedKey(initialKeyAlreadyFormatted, pivotData, type);
5137
5141
  expect(formattedKey).toEqual(initialKeyAlreadyFormatted);
5138
5142
  });
5143
+
5144
+ it('should return NOT formatted value when type is Date but value is not a valid moment date', () => {
5145
+ lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types']);
5146
+ const initialKey = ['Some Text Value', 'Another Text'];
5147
+ const pivotData = {
5148
+ colFormats: [{ type: 'Date' }, { type: 'Date' }],
5149
+ isFormattingAxisLabels: true,
5150
+ };
5151
+ const type = 'colFormats';
5152
+ const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
5153
+ expect(formattedKey).toEqual(initialKey);
5154
+ });
5155
+
5156
+ it('should return formatted value when type is Date and value is a valid moment date (format_dates_as_other_axis_types is OFF)', () => {
5157
+ const initialKey = ['Feb-24', 'Jan-24'];
5158
+ const pivotData = {
5159
+ colFormats: [{ type: 'Date' }, { type: 'Date' }],
5160
+ isFormattingAxisLabels: true,
5161
+ };
5162
+ const type = 'colFormats';
5163
+ const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
5164
+ expect(formattedKey).toEqual(initialKey);
5165
+ });
5139
5166
  });
5140
5167
  });
5141
5168
 
@@ -6152,6 +6179,14 @@ describe('highcharts_renderer', () => {
6152
6179
  describe('Function tableCSVExportRenderer', () => {
6153
6180
  window._ = lodash;
6154
6181
 
6182
+ beforeEach(() => {
6183
+ lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types']);
6184
+ });
6185
+
6186
+ afterEach(() => {
6187
+ lodash.set(document, 'ReportHippo.user.features', []);
6188
+ });
6189
+
6155
6190
  it('should create csv json object representation based on pivot data (only cols)', () => {
6156
6191
  const chartOptions = {
6157
6192
  table_options: {
@@ -6226,7 +6261,7 @@ describe('highcharts_renderer', () => {
6226
6261
  const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
6227
6262
  expect(csvJson).toEqual(
6228
6263
  [
6229
- [ 1651363200, 1652400000, 1653177600, 1653955200, 'Totals' ],
6264
+ [ '05/01/2022', '05/13/2022', '05/22/2022', '05/31/2022', 'Totals' ],
6230
6265
  [ undefined, undefined, undefined, undefined, 'Totals' ],
6231
6266
  [],
6232
6267
  [ 1, 1, 1, 1, 2 ],
@@ -6329,7 +6364,7 @@ describe('highcharts_renderer', () => {
6329
6364
  const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
6330
6365
  expect(csvJson).toEqual(
6331
6366
  [
6332
- ["Date", 1653177600, 1653955200, "Totals"],
6367
+ ["Date", "05/22/2022", "05/31/2022", "Totals"],
6333
6368
  ["Type"],
6334
6369
  ["Food", 1, 1, 1],
6335
6370
  ["Technology", 1, 1, 1],
@@ -6348,7 +6383,7 @@ describe('highcharts_renderer', () => {
6348
6383
  const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
6349
6384
  const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
6350
6385
  expect(csvJson).toEqual([
6351
- ["Date", 1653177600, 1653955200, "Totals"],
6386
+ ["Date", "05/22/2022", "05/31/2022", "Totals"],
6352
6387
  ["Type"],
6353
6388
  ["Food", 1, 1, 1],
6354
6389
  ["Technology", 1, 1, 1]
@@ -6366,7 +6401,7 @@ describe('highcharts_renderer', () => {
6366
6401
  const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
6367
6402
  const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
6368
6403
  expect(csvJson).toEqual([
6369
- ["Date", 1653177600, 1653955200],
6404
+ ["Date", "05/22/2022", "05/31/2022"],
6370
6405
  ["Type"],
6371
6406
  ["Food", 1, 1],
6372
6407
  ["Technology", 1, 1],
@@ -6385,7 +6420,7 @@ describe('highcharts_renderer', () => {
6385
6420
  const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
6386
6421
  const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
6387
6422
  expect(csvJson).toEqual([
6388
- ["Date", 1653177600, 1653955200],
6423
+ ["Date", "05/22/2022", "05/31/2022"],
6389
6424
  ["Type"],
6390
6425
  ["Food", 1, 1],
6391
6426
  ["Technology", 1, 1],