@datarailsshared/dr_renderer 1.5.124 → 1.5.129
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
|
@@ -1038,7 +1038,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1038
1038
|
tempAr[temp_len - 1] = highchartsRenderer.getFieldName(colAttrs[j]);
|
|
1039
1039
|
}
|
|
1040
1040
|
|
|
1041
|
-
const formattedColKeys = highchartsRenderer.getFormattedColKeys(pivotData, null
|
|
1041
|
+
const formattedColKeys = highchartsRenderer.getFormattedColKeys(pivotData, null);
|
|
1042
1042
|
tempAr = tempAr.concat(lodash.map(formattedColKeys, function (row) {
|
|
1043
1043
|
return row[j];
|
|
1044
1044
|
}));
|
|
@@ -1057,11 +1057,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1057
1057
|
}
|
|
1058
1058
|
forExport.push(tempAr);
|
|
1059
1059
|
|
|
1060
|
+
const formattedRowKeys = highchartsRenderer.getFormattedRowKeys(pivotData, null);
|
|
1061
|
+
|
|
1060
1062
|
for (i in rowKeys) {
|
|
1061
1063
|
if (!hasProp.call(rowKeys, i)) continue;
|
|
1062
1064
|
tempAr = [];
|
|
1063
1065
|
rowKey = rowKeys[i];
|
|
1064
|
-
|
|
1066
|
+
const formattedRowKey = formattedRowKeys[i];
|
|
1067
|
+
tempAr = tempAr.concat(formattedRowKey);
|
|
1065
1068
|
for (j in colKeys) {
|
|
1066
1069
|
if (!hasProp.call(colKeys, j)) continue;
|
|
1067
1070
|
colKey = colKeys[j];
|
|
@@ -8235,10 +8238,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8235
8238
|
lodash.forEach(values, (value, key) => {
|
|
8236
8239
|
const formatInfo = pivotData[type][key] || {};
|
|
8237
8240
|
const valueToFloat = parseFloat(value);
|
|
8241
|
+
const isBlankDate = formatInfo.type === 'Date' && (value === '' || value === '[blank]');
|
|
8238
8242
|
const isDate = formatInfo.type === 'Date' && (moment_lib(valueToFloat).isValid() || moment_lib(value, formatInfo.format).isValid());
|
|
8239
8243
|
const isNumberFormatting = !isDate && formatInfo.format && highchartsRenderer.isFormattingNumberAxis(pivotData);
|
|
8240
8244
|
|
|
8241
|
-
if (isNumberFormatting || isDate) {
|
|
8245
|
+
if (isNumberFormatting || isDate || isBlankDate) {
|
|
8242
8246
|
values[key] = highchartsRenderer.returnRawDataValue(
|
|
8243
8247
|
formatInfo.type,
|
|
8244
8248
|
!isNaN(valueToFloat) ? valueToFloat : value,
|
|
@@ -5120,6 +5120,17 @@ describe('highcharts_renderer', () => {
|
|
|
5120
5120
|
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
|
5121
5121
|
expect(formattedKey).toEqual(initialKey);
|
|
5122
5122
|
});
|
|
5123
|
+
|
|
5124
|
+
// some e2e tests exist that expects this behavior
|
|
5125
|
+
it('should format blank value with [blank] text', () => {
|
|
5126
|
+
const initialKey = ['DR_Others', ''];
|
|
5127
|
+
const pivotData = {
|
|
5128
|
+
colFormats: [{ type: "Text", name: "Month" }, { type: 'Date', name: "Date" }],
|
|
5129
|
+
};
|
|
5130
|
+
const type = 'colFormats';
|
|
5131
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
|
5132
|
+
expect(formattedKey).toEqual(['DR_Others', '[blank]']);
|
|
5133
|
+
});
|
|
5123
5134
|
});
|
|
5124
5135
|
});
|
|
5125
5136
|
|
|
@@ -6218,6 +6229,119 @@ describe('highcharts_renderer', () => {
|
|
|
6218
6229
|
]);
|
|
6219
6230
|
});
|
|
6220
6231
|
});
|
|
6232
|
+
|
|
6233
|
+
describe('cases for date in rows (timestamp row keys)', () => {
|
|
6234
|
+
const inputs = [
|
|
6235
|
+
{
|
|
6236
|
+
"Date": 1653955200,
|
|
6237
|
+
"Type": 'Food',
|
|
6238
|
+
"Amount": 2849521.69
|
|
6239
|
+
},
|
|
6240
|
+
{
|
|
6241
|
+
"Date": 1653955200,
|
|
6242
|
+
"Type": 'Technology',
|
|
6243
|
+
"Amount": 321123
|
|
6244
|
+
},
|
|
6245
|
+
{
|
|
6246
|
+
"Date": 1653177600,
|
|
6247
|
+
"Type": 'Food',
|
|
6248
|
+
"Amount": 3141257.27
|
|
6249
|
+
},
|
|
6250
|
+
{
|
|
6251
|
+
"Date": 1653177600,
|
|
6252
|
+
"Type": 'Technology',
|
|
6253
|
+
"Amount": 4321
|
|
6254
|
+
},
|
|
6255
|
+
{
|
|
6256
|
+
"Date": 1653955200,
|
|
6257
|
+
"Amount": 123
|
|
6258
|
+
},
|
|
6259
|
+
{
|
|
6260
|
+
"Type": 'Technology',
|
|
6261
|
+
"Amount": 1
|
|
6262
|
+
},
|
|
6263
|
+
{
|
|
6264
|
+
"Type": 'Food',
|
|
6265
|
+
"Amount": 2
|
|
6266
|
+
},
|
|
6267
|
+
{
|
|
6268
|
+
"Date": 1653177600,
|
|
6269
|
+
"Amount": 321
|
|
6270
|
+
},
|
|
6271
|
+
{
|
|
6272
|
+
"Amount": 9834311.05
|
|
6273
|
+
},
|
|
6274
|
+
{
|
|
6275
|
+
"col_keys": [
|
|
6276
|
+
['Food'],
|
|
6277
|
+
['Technology'],
|
|
6278
|
+
],
|
|
6279
|
+
"row_keys": [
|
|
6280
|
+
[1653177600],
|
|
6281
|
+
[1653955200]
|
|
6282
|
+
]
|
|
6283
|
+
}
|
|
6284
|
+
];
|
|
6285
|
+
const subOptions = {
|
|
6286
|
+
"cols": ["Type"],
|
|
6287
|
+
"rows": ["Date"],
|
|
6288
|
+
"keysObject": {
|
|
6289
|
+
"row_keys": [[1653177600], [1653955200]],
|
|
6290
|
+
"col_keys": [["Food"], ["Technology"]],
|
|
6291
|
+
},
|
|
6292
|
+
"colFormats": [
|
|
6293
|
+
{
|
|
6294
|
+
"type": "Text",
|
|
6295
|
+
"name": "Type",
|
|
6296
|
+
"val_not_convert": []
|
|
6297
|
+
},
|
|
6298
|
+
],
|
|
6299
|
+
"rowFormats": [
|
|
6300
|
+
{
|
|
6301
|
+
"type": "Date",
|
|
6302
|
+
"name": "Date",
|
|
6303
|
+
"val_not_convert": []
|
|
6304
|
+
},
|
|
6305
|
+
],
|
|
6306
|
+
"rendererOptions": {
|
|
6307
|
+
},
|
|
6308
|
+
};
|
|
6309
|
+
|
|
6310
|
+
it('should format timestamp row keys as dates in csv export', () => {
|
|
6311
|
+
const chartOptions = {
|
|
6312
|
+
table_options: {
|
|
6313
|
+
show_column_total: true,
|
|
6314
|
+
show_row_total: true,
|
|
6315
|
+
},
|
|
6316
|
+
};
|
|
6317
|
+
const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
|
|
6318
|
+
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6319
|
+
expect(csvJson).toEqual([
|
|
6320
|
+
["Type", "Food", "Technology", "Totals"],
|
|
6321
|
+
["Date"],
|
|
6322
|
+
["05/22/2022", 1, 1, 1],
|
|
6323
|
+
["05/31/2022", 1, 1, 1],
|
|
6324
|
+
["Totals", 1, 1, 2]
|
|
6325
|
+
]);
|
|
6326
|
+
});
|
|
6327
|
+
|
|
6328
|
+
it('should format timestamp row keys as dates without totals', () => {
|
|
6329
|
+
const chartOptions = {
|
|
6330
|
+
table_options: {
|
|
6331
|
+
show_column_total: false,
|
|
6332
|
+
show_row_total: false,
|
|
6333
|
+
},
|
|
6334
|
+
};
|
|
6335
|
+
const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
|
|
6336
|
+
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6337
|
+
expect(csvJson).toEqual([
|
|
6338
|
+
["Type", "Food", "Technology"],
|
|
6339
|
+
["Date"],
|
|
6340
|
+
["05/22/2022", 1, 1],
|
|
6341
|
+
["05/31/2022", 1, 1],
|
|
6342
|
+
]);
|
|
6343
|
+
});
|
|
6344
|
+
});
|
|
6221
6345
|
});
|
|
6222
6346
|
|
|
6223
6347
|
describe("Function returnRawDataValue", () => {
|