@datarailsshared/dr_renderer 1.5.124 → 1.5.126
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];
|
|
@@ -6218,6 +6218,119 @@ describe('highcharts_renderer', () => {
|
|
|
6218
6218
|
]);
|
|
6219
6219
|
});
|
|
6220
6220
|
});
|
|
6221
|
+
|
|
6222
|
+
describe('cases for date in rows (timestamp row keys)', () => {
|
|
6223
|
+
const inputs = [
|
|
6224
|
+
{
|
|
6225
|
+
"Date": 1653955200,
|
|
6226
|
+
"Type": 'Food',
|
|
6227
|
+
"Amount": 2849521.69
|
|
6228
|
+
},
|
|
6229
|
+
{
|
|
6230
|
+
"Date": 1653955200,
|
|
6231
|
+
"Type": 'Technology',
|
|
6232
|
+
"Amount": 321123
|
|
6233
|
+
},
|
|
6234
|
+
{
|
|
6235
|
+
"Date": 1653177600,
|
|
6236
|
+
"Type": 'Food',
|
|
6237
|
+
"Amount": 3141257.27
|
|
6238
|
+
},
|
|
6239
|
+
{
|
|
6240
|
+
"Date": 1653177600,
|
|
6241
|
+
"Type": 'Technology',
|
|
6242
|
+
"Amount": 4321
|
|
6243
|
+
},
|
|
6244
|
+
{
|
|
6245
|
+
"Date": 1653955200,
|
|
6246
|
+
"Amount": 123
|
|
6247
|
+
},
|
|
6248
|
+
{
|
|
6249
|
+
"Type": 'Technology',
|
|
6250
|
+
"Amount": 1
|
|
6251
|
+
},
|
|
6252
|
+
{
|
|
6253
|
+
"Type": 'Food',
|
|
6254
|
+
"Amount": 2
|
|
6255
|
+
},
|
|
6256
|
+
{
|
|
6257
|
+
"Date": 1653177600,
|
|
6258
|
+
"Amount": 321
|
|
6259
|
+
},
|
|
6260
|
+
{
|
|
6261
|
+
"Amount": 9834311.05
|
|
6262
|
+
},
|
|
6263
|
+
{
|
|
6264
|
+
"col_keys": [
|
|
6265
|
+
['Food'],
|
|
6266
|
+
['Technology'],
|
|
6267
|
+
],
|
|
6268
|
+
"row_keys": [
|
|
6269
|
+
[1653177600],
|
|
6270
|
+
[1653955200]
|
|
6271
|
+
]
|
|
6272
|
+
}
|
|
6273
|
+
];
|
|
6274
|
+
const subOptions = {
|
|
6275
|
+
"cols": ["Type"],
|
|
6276
|
+
"rows": ["Date"],
|
|
6277
|
+
"keysObject": {
|
|
6278
|
+
"row_keys": [[1653177600], [1653955200]],
|
|
6279
|
+
"col_keys": [["Food"], ["Technology"]],
|
|
6280
|
+
},
|
|
6281
|
+
"colFormats": [
|
|
6282
|
+
{
|
|
6283
|
+
"type": "Text",
|
|
6284
|
+
"name": "Type",
|
|
6285
|
+
"val_not_convert": []
|
|
6286
|
+
},
|
|
6287
|
+
],
|
|
6288
|
+
"rowFormats": [
|
|
6289
|
+
{
|
|
6290
|
+
"type": "Date",
|
|
6291
|
+
"name": "Date",
|
|
6292
|
+
"val_not_convert": []
|
|
6293
|
+
},
|
|
6294
|
+
],
|
|
6295
|
+
"rendererOptions": {
|
|
6296
|
+
},
|
|
6297
|
+
};
|
|
6298
|
+
|
|
6299
|
+
it('should format timestamp row keys as dates in csv export', () => {
|
|
6300
|
+
const chartOptions = {
|
|
6301
|
+
table_options: {
|
|
6302
|
+
show_column_total: true,
|
|
6303
|
+
show_row_total: true,
|
|
6304
|
+
},
|
|
6305
|
+
};
|
|
6306
|
+
const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
|
|
6307
|
+
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6308
|
+
expect(csvJson).toEqual([
|
|
6309
|
+
["Type", "Food", "Technology", "Totals"],
|
|
6310
|
+
["Date"],
|
|
6311
|
+
["05/22/2022", 1, 1, 1],
|
|
6312
|
+
["05/31/2022", 1, 1, 1],
|
|
6313
|
+
["Totals", 1, 1, 2]
|
|
6314
|
+
]);
|
|
6315
|
+
});
|
|
6316
|
+
|
|
6317
|
+
it('should format timestamp row keys as dates without totals', () => {
|
|
6318
|
+
const chartOptions = {
|
|
6319
|
+
table_options: {
|
|
6320
|
+
show_column_total: false,
|
|
6321
|
+
show_row_total: false,
|
|
6322
|
+
},
|
|
6323
|
+
};
|
|
6324
|
+
const pivotData = $.pivotUtilities.getPivotDataModel(inputs, subOptions);
|
|
6325
|
+
const csvJson = highchartsRenderer.tableCSVExportRenderer(pivotData, chartOptions);
|
|
6326
|
+
expect(csvJson).toEqual([
|
|
6327
|
+
["Type", "Food", "Technology"],
|
|
6328
|
+
["Date"],
|
|
6329
|
+
["05/22/2022", 1, 1],
|
|
6330
|
+
["05/31/2022", 1, 1],
|
|
6331
|
+
]);
|
|
6332
|
+
});
|
|
6333
|
+
});
|
|
6221
6334
|
});
|
|
6222
6335
|
|
|
6223
6336
|
describe("Function returnRawDataValue", () => {
|