@datarailsshared/dr_renderer 1.2.331 → 1.2.333
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 +1 -1
- package/src/dr_pivottable.js +10 -8
- package/src/highcharts_renderer.js +146 -44
- package/src/novix_renderer.js +13 -11
- package/src/pivottable.js +5 -0
- package/tests/highcharts_renderer.test.js +344 -0
package/package.json
CHANGED
package/src/dr_pivottable.js
CHANGED
@@ -920,7 +920,7 @@ let initDRPivotTable = function($, window, document) {
|
|
920
920
|
return string_val;
|
921
921
|
};
|
922
922
|
|
923
|
-
processKeys = function(keysArr, className, dimention, attrs) {
|
923
|
+
processKeys = function(keysArr, className, dimention, attrs, formattedKeys) {
|
924
924
|
for (let i = 0; i < keysArr.length; i++) {
|
925
925
|
const additionalField = _.find(additionalFieldsList, {key: keysArr[i][0]})
|
926
926
|
|
@@ -941,7 +941,7 @@ let initDRPivotTable = function($, window, document) {
|
|
941
941
|
lastCol = 0;
|
942
942
|
}
|
943
943
|
rMark = [];
|
944
|
-
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(
|
944
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(formattedKeys[0][0]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, 0, 0)));
|
945
945
|
key = [];
|
946
946
|
key.push(keysArr[0][0]);
|
947
947
|
nodePos = 0;
|
@@ -961,7 +961,7 @@ let initDRPivotTable = function($, window, document) {
|
|
961
961
|
rMark[0] = node;
|
962
962
|
c = 1;
|
963
963
|
while (c <= lastCol) {
|
964
|
-
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(
|
964
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(formattedKeys[0][c]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, 0, c)));
|
965
965
|
key = key.slice();
|
966
966
|
key.push(keysArr[0][c]);
|
967
967
|
++nodePos;
|
@@ -1027,7 +1027,7 @@ let initDRPivotTable = function($, window, document) {
|
|
1027
1027
|
}
|
1028
1028
|
|
1029
1029
|
|
1030
|
-
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(
|
1030
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(formattedKeys[r][c]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, r, c)));
|
1031
1031
|
++nodePos;
|
1032
1032
|
node = {
|
1033
1033
|
node: nodePos,
|
@@ -2451,7 +2451,7 @@ let initDRPivotTable = function($, window, document) {
|
|
2451
2451
|
return Array.from(wrapper.querySelectorAll(selectString));
|
2452
2452
|
}
|
2453
2453
|
|
2454
|
-
main = function(rowAttrs, rowKeys, colAttrs, colKeys) {
|
2454
|
+
main = function(rowAttrs, rowKeys, colAttrs, colKeys, pivotData) {
|
2455
2455
|
var c,rowspan, colHeaderCols, colHeaderHeaders, colHeaders, h, k, l, len, len1, result, rowHeaderHeaders, rowHeaderRows, rowHeaders, tbody, thead, tr;
|
2456
2456
|
rowHeaders = [];
|
2457
2457
|
colHeaders = [];
|
@@ -2460,10 +2460,12 @@ let initDRPivotTable = function($, window, document) {
|
|
2460
2460
|
colHeaderHeaders = [];
|
2461
2461
|
colHeaderCols = [];
|
2462
2462
|
if (rowAttrs.length > 0 && rowKeys.length > 0) {
|
2463
|
-
|
2463
|
+
const formattedKeys = pivotData.getFormattedRowKeys(rowKeys);
|
2464
|
+
rowHeaders = processKeys(rowKeys, "pvtRowLabel", 'rows', rowAttrs, formattedKeys);
|
2464
2465
|
}
|
2465
2466
|
if (colAttrs.length > 0 && colKeys.length > 0) {
|
2466
|
-
|
2467
|
+
const formattedKeys = pivotData.getFormattedColKeys(colKeys);
|
2468
|
+
colHeaders = processKeys(colKeys, "pvtColLabel", 'cols', colAttrs, formattedKeys);
|
2467
2469
|
}
|
2468
2470
|
var tableClasses = ['pvtTable'];
|
2469
2471
|
if (opts.chartOptions.table_options.use_new_table_design) {
|
@@ -2608,7 +2610,7 @@ let initDRPivotTable = function($, window, document) {
|
|
2608
2610
|
|
2609
2611
|
return wrapper;
|
2610
2612
|
};
|
2611
|
-
return main(rowAttrs, rowKeys, colAttrs, colKeys);
|
2613
|
+
return main(rowAttrs, rowKeys, colAttrs, colKeys, pivotData);
|
2612
2614
|
};
|
2613
2615
|
// $.pivotUtilities.subtotal_renderers = SubtotalRenderer;
|
2614
2616
|
$.pivotUtilities.subtotal_renderers = NovixRenderer;
|
@@ -142,6 +142,7 @@ const CHART_LEGEND_DEFAULT_LABEL = 'Legend (Series)';
|
|
142
142
|
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
|
+
FORMAT_AXIS: 'use_default_table_format_for_axis',
|
145
146
|
}
|
146
147
|
|
147
148
|
let getHighchartsRenderer = function ($, document, Highcharts, default_colors, highchartsRenderer,
|
@@ -1154,8 +1155,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1154
1155
|
let squareXSum = 0;
|
1155
1156
|
ob.data = [];
|
1156
1157
|
if (row_n_value && row_n_value.length > 0) {
|
1157
|
-
ob.
|
1158
|
+
ob.initialName = row_n_value.join(highchartsRenderer.delimer)
|
1158
1159
|
.replace(highchartsRenderer.DR_OTHERS_KEY, othersName);
|
1160
|
+
ob.name = highchartsRenderer.getFormattedRowKey(ob.initialName, pivotData);
|
1159
1161
|
}
|
1160
1162
|
lodash.forEach(col_n_keys, function (col_n_value, index) {
|
1161
1163
|
var agg = pivotData.getAggregator(row_n_value, col_n_value);
|
@@ -1196,7 +1198,15 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1196
1198
|
);
|
1197
1199
|
}
|
1198
1200
|
|
1199
|
-
ob.data.push(
|
1201
|
+
ob.data.push(
|
1202
|
+
key
|
1203
|
+
? {
|
1204
|
+
y: val,
|
1205
|
+
initialName: lodash.unescape(key),
|
1206
|
+
name: highchartsRenderer.getFormattedColKey(lodash.unescape(key), pivotData),
|
1207
|
+
}
|
1208
|
+
: val
|
1209
|
+
);
|
1200
1210
|
});
|
1201
1211
|
|
1202
1212
|
if (colors && colors[i]) {
|
@@ -1326,8 +1336,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1326
1336
|
var ob = {};
|
1327
1337
|
ob.data = [];
|
1328
1338
|
if (row_n_value && row_n_value.length > 0) {
|
1329
|
-
ob.
|
1339
|
+
ob.initialName = lodash.unescape(row_n_value.join(highchartsRenderer.delimer)
|
1330
1340
|
.replace(highchartsRenderer.DR_OTHERS_KEY, othersName));
|
1341
|
+
ob.name = highchartsRenderer.getFormattedRowKey(ob.initialName, pivotData);
|
1331
1342
|
}
|
1332
1343
|
|
1333
1344
|
ob.dataLabels = {
|
@@ -1364,15 +1375,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1364
1375
|
if (lodash.isArray(col_n_value)) {
|
1365
1376
|
key = col_n_value[0];
|
1366
1377
|
}
|
1367
|
-
tmoobj.
|
1378
|
+
tmoobj.initialName = lodash.unescape(key);
|
1368
1379
|
|
1369
|
-
if (tmoobj.
|
1370
|
-
tmoobj.
|
1380
|
+
if (tmoobj.initialName) {
|
1381
|
+
tmoobj.initialName = tmoobj.initialName.replace(highchartsRenderer.DR_OTHERS_KEY, othersName);
|
1371
1382
|
}
|
1372
1383
|
|
1373
|
-
if (lodash.isEmpty(String(tmoobj.
|
1374
|
-
tmoobj.
|
1384
|
+
if (lodash.isEmpty(String(tmoobj.initialName))) {
|
1385
|
+
tmoobj.initialName = "[blank]";
|
1375
1386
|
}
|
1387
|
+
tmoobj.name = highchartsRenderer.getFormattedColKey(tmoobj.initialName, pivotData);
|
1388
|
+
|
1376
1389
|
tmoobj.y = val;
|
1377
1390
|
if (!isNotDrilldown)
|
1378
1391
|
tmoobj.drilldown = true;
|
@@ -1528,10 +1541,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1528
1541
|
lodash.forEach(col_n_keys, function(col_n_value, col_index) {
|
1529
1542
|
|
1530
1543
|
const totalColumnValue = pivotData.getAggregator([], col_n_value).value();
|
1544
|
+
const totalName = lodash.unescape(col_n_value).replace(highchartsRenderer.DR_OTHERS_KEY, highchartsRenderer.getOthersName(opts));
|
1531
1545
|
resultObject.data.push({
|
1532
1546
|
y: totalColumnValue,
|
1533
|
-
name:
|
1534
|
-
|
1547
|
+
name: highchartsRenderer.getFormattedColKey(totalName, pivotData),
|
1548
|
+
initialName: totalName,
|
1535
1549
|
isSum: !!col_index,
|
1536
1550
|
isTotal: true,
|
1537
1551
|
color: colorOptions.total,
|
@@ -1546,18 +1560,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1546
1560
|
if (val) {
|
1547
1561
|
const tmoobj = {};
|
1548
1562
|
const key = lodash.isArray(row_n_value) ? row_n_value[0] : row_n_value;
|
1549
|
-
tmoobj.
|
1563
|
+
tmoobj.initialName = lodash.unescape(key);
|
1550
1564
|
|
1551
|
-
if (tmoobj.
|
1552
|
-
tmoobj.
|
1565
|
+
if (tmoobj.initialName) {
|
1566
|
+
tmoobj.initialName = tmoobj.initialName
|
1553
1567
|
.replace(highchartsRenderer.DR_OTHERS_KEY, highchartsRenderer.getOthersName(opts));
|
1554
1568
|
}
|
1555
1569
|
|
1556
|
-
if (lodash.isEmpty(String(tmoobj.
|
1557
|
-
tmoobj.
|
1570
|
+
if (lodash.isEmpty(String(tmoobj.initialName))) {
|
1571
|
+
tmoobj.initialName = lodash.unescape(col_n_value);
|
1558
1572
|
tmoobj.visible = false;
|
1559
1573
|
}
|
1560
1574
|
|
1575
|
+
tmoobj.name = highchartsRenderer.getFormattedRowKey(tmoobj.initialName, pivotData);
|
1561
1576
|
tmoobj.y = val;
|
1562
1577
|
tmoobj.colKeys = [lodash.unescape(col_n_value), lodash.unescape(col_n_keys[col_index + 1])];
|
1563
1578
|
resultObject.data.push(tmoobj);
|
@@ -1644,7 +1659,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1644
1659
|
increase: '#20A452',
|
1645
1660
|
};
|
1646
1661
|
|
1647
|
-
|
1662
|
+
let initialName = value.trend === 'total' ? value.formattedKey || value.key[0] : keys.join(highchartsRenderer.delimer);
|
1663
|
+
let name = value.trend === 'total' ? initialName : highchartsRenderer.getFormattedColKey(initialName, pivotData);
|
1664
|
+
|
1648
1665
|
let color = '';
|
1649
1666
|
|
1650
1667
|
if (!lodash.get(waterfallOptions, 'colors', {}) && value.color) {
|
@@ -1804,15 +1821,17 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1804
1821
|
|
1805
1822
|
var ob = {};
|
1806
1823
|
// check string contains hebrew
|
1807
|
-
ob.
|
1824
|
+
ob.initialName = (/[\u0590-\u05FF]/).test(key) ? ('\u200E' + key) : key;
|
1808
1825
|
if (lodash.isEmpty(String(ob.name))) {
|
1809
|
-
ob.
|
1826
|
+
ob.initialName = "[blank]";
|
1810
1827
|
}
|
1811
1828
|
|
1812
|
-
if (ob.
|
1813
|
-
ob.
|
1829
|
+
if (ob.initialName === highchartsRenderer.DR_OTHERS_KEY) {
|
1830
|
+
ob.initialName = othersName;
|
1814
1831
|
}
|
1815
1832
|
|
1833
|
+
ob.name = highchartsRenderer.getFormattedColKey(ob.initialName, pivotData);
|
1834
|
+
|
1816
1835
|
ob.y = val;
|
1817
1836
|
if (!isNaN(key))
|
1818
1837
|
key = Number(key)
|
@@ -1844,7 +1863,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1844
1863
|
var col_n = col_n_value[0];
|
1845
1864
|
if (col_n != undefined) {
|
1846
1865
|
col_ob.id = !isNaN(col_n) ? Number(col_n) : col_n;
|
1847
|
-
col_ob.
|
1866
|
+
col_ob.initialName = col_n === highchartsRenderer.DR_OTHERS_KEY ? othersName : col_n;
|
1867
|
+
col_ob.name = highchartsRenderer.getFormattedColKey(col_ob.initialName, pivotData);
|
1848
1868
|
col_ob.data = [];
|
1849
1869
|
lodash.forEach(row_n_keys, function (row_n_value) {
|
1850
1870
|
var agg = pivotData.getAggregator(row_n_value, col_n_value);
|
@@ -1859,8 +1879,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1859
1879
|
// }
|
1860
1880
|
}
|
1861
1881
|
|
1862
|
-
const
|
1863
|
-
|
1882
|
+
const row_initial_name = row_n_value[0] === highchartsRenderer.DR_OTHERS_KEY ? othersName : row_n_value[0];
|
1883
|
+
const row_name = highchartsRenderer.getFormattedRowKey(row_initial_name, pivotData);
|
1884
|
+
col_ob.data.push({
|
1885
|
+
name: row_name,
|
1886
|
+
initialName: row_initial_name,
|
1887
|
+
y: val
|
1888
|
+
});
|
1864
1889
|
}
|
1865
1890
|
});
|
1866
1891
|
if (col_ob.data.length) {
|
@@ -2024,9 +2049,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2024
2049
|
|
2025
2050
|
lodash.forEach(col_n_keys, function (key) {
|
2026
2051
|
var ob = {};
|
2027
|
-
ob.
|
2028
|
-
if (lodash.isEmpty(String(ob.
|
2029
|
-
ob.
|
2052
|
+
ob.initialName = key;
|
2053
|
+
if (lodash.isEmpty(String(ob.initialName))) {
|
2054
|
+
ob.initialName = "[blank]";
|
2030
2055
|
}
|
2031
2056
|
if (row_n_keys && row_n_keys.length > 0) {
|
2032
2057
|
agg = pivotData.getAggregator(row_n_keys[0], key); // tale first row
|
@@ -2034,6 +2059,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2034
2059
|
agg = pivotData.getAggregator([], key);
|
2035
2060
|
}
|
2036
2061
|
ob.y = agg.value();
|
2062
|
+
ob.name = highchartsRenderer.getFormattedColKey(ob.initialName, pivotData);
|
2037
2063
|
pie_series.push(ob);
|
2038
2064
|
});
|
2039
2065
|
|
@@ -2138,7 +2164,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2138
2164
|
}
|
2139
2165
|
};
|
2140
2166
|
|
2141
|
-
chartOptions.xAxis = {
|
2167
|
+
chartOptions.xAxis = {
|
2168
|
+
categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
|
2169
|
+
};
|
2142
2170
|
chartOptions.series = highchartsRenderer.ptCreateBasicLineSeries(pivotData, null, true, null, null, opts, chartOptions);
|
2143
2171
|
|
2144
2172
|
var total = [];
|
@@ -2280,7 +2308,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2280
2308
|
};
|
2281
2309
|
|
2282
2310
|
|
2283
|
-
chartOptions.xAxis = {
|
2311
|
+
chartOptions.xAxis = {
|
2312
|
+
categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
|
2313
|
+
};
|
2284
2314
|
chartOptions.series = highchartsRenderer.ptCreateBasicLineSeries(pivotData, null, true, null, null, opts, chartOptions);
|
2285
2315
|
|
2286
2316
|
var total = [];
|
@@ -2620,10 +2650,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2620
2650
|
};
|
2621
2651
|
|
2622
2652
|
chartOptions.xAxis = {
|
2623
|
-
categories:
|
2653
|
+
categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
|
2624
2654
|
title: {
|
2625
2655
|
text: additionOptions && additionOptions.axisX ? additionOptions.axisX.name : '',
|
2626
|
-
}
|
2656
|
+
},
|
2627
2657
|
};
|
2628
2658
|
chartOptions = highchartsRenderer.prepareAxisX(chartOptions, additionOptions, pivotData.getColKeys());
|
2629
2659
|
chartOptions.series = highchartsRenderer.ptCreateBasicLineSeries(pivotData, null, null, null, additionOptions, opts, chartOptions);
|
@@ -2704,7 +2734,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2704
2734
|
};
|
2705
2735
|
|
2706
2736
|
chartOptions.xAxis = {
|
2707
|
-
categories:
|
2737
|
+
categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
|
2708
2738
|
title: {
|
2709
2739
|
text: additionOptions && additionOptions.axisX ? additionOptions.axisX.name : '',
|
2710
2740
|
}
|
@@ -2805,7 +2835,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2805
2835
|
}
|
2806
2836
|
|
2807
2837
|
chartOptions.xAxis = {
|
2808
|
-
categories:
|
2838
|
+
categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
|
2809
2839
|
title: {
|
2810
2840
|
text: additionOptions && additionOptions.axisX ? additionOptions.axisX.name : '',
|
2811
2841
|
}
|
@@ -2853,7 +2883,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2853
2883
|
}
|
2854
2884
|
|
2855
2885
|
chartOptions.xAxis = {
|
2856
|
-
categories:
|
2886
|
+
categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
|
2857
2887
|
tickmarkPlacement: 'on',
|
2858
2888
|
title: {
|
2859
2889
|
text: additionOptions && additionOptions.axisX ? additionOptions.axisX.name : '',
|
@@ -2954,7 +2984,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2954
2984
|
}
|
2955
2985
|
|
2956
2986
|
chartOptions.xAxis = {
|
2957
|
-
categories:
|
2987
|
+
categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
|
2958
2988
|
tickmarkPlacement: 'on',
|
2959
2989
|
title: {
|
2960
2990
|
text: additionOptions && additionOptions.axisX ? additionOptions.axisX.name : '',
|
@@ -2979,6 +3009,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2979
3009
|
zoomType: additionOptions && additionOptions.chart && additionOptions.chart.zoom_type ? additionOptions.chart.zoom_type : 'None',
|
2980
3010
|
events: {
|
2981
3011
|
'drilldown': function (e) {
|
3012
|
+
highchartsRenderer.modifyEventPointForDrilldown(e);
|
2982
3013
|
if (drilldownFunc)
|
2983
3014
|
drilldownFunc(e, this, "drilldown");
|
2984
3015
|
|
@@ -3097,6 +3128,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3097
3128
|
zoomType: 'x',
|
3098
3129
|
events: {
|
3099
3130
|
'drilldown': function (e) {
|
3131
|
+
highchartsRenderer.modifyEventPointForDrilldown(e);
|
3100
3132
|
if (drilldownFunc)
|
3101
3133
|
drilldownFunc(e, this, "drilldown");
|
3102
3134
|
|
@@ -3254,6 +3286,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3254
3286
|
type: 'column',
|
3255
3287
|
events: {
|
3256
3288
|
'drilldown': function (e) {
|
3289
|
+
highchartsRenderer.modifyEventPointForDrilldown(e);
|
3257
3290
|
if (drilldownFunc)
|
3258
3291
|
drilldownFunc(e, this, "drilldown");
|
3259
3292
|
|
@@ -3316,7 +3349,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3316
3349
|
},
|
3317
3350
|
};
|
3318
3351
|
|
3319
|
-
chartOptions.xAxis = {
|
3352
|
+
chartOptions.xAxis = {
|
3353
|
+
type: 'category',
|
3354
|
+
};
|
3320
3355
|
chartOptions = highchartsRenderer.prepareAxisX(chartOptions, additionOptions, pivotData.getColKeys());
|
3321
3356
|
chartOptions.series = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, chartOptions, additionOptions, opts);
|
3322
3357
|
//if (drilldownFunc)
|
@@ -3365,11 +3400,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3365
3400
|
chartOptions.colors = highchartsRenderer.getColorsWithOffset(additionOptions.chart.colors_offset);
|
3366
3401
|
}
|
3367
3402
|
chartOptions.xAxis = {
|
3368
|
-
categories:
|
3403
|
+
categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
|
3369
3404
|
crosshair: true,
|
3370
3405
|
title: {
|
3371
3406
|
text: additionOptions && additionOptions.axisX ? additionOptions.axisX.name : ''
|
3372
|
-
}
|
3407
|
+
},
|
3373
3408
|
};
|
3374
3409
|
chartOptions = highchartsRenderer.prepareAxisX(chartOptions, additionOptions, pivotData.getColKeys());
|
3375
3410
|
chartOptions.series = highchartsRenderer.ptCreateBasicLineSeries(pivotData, null, null, null, null, opts, chartOptions);
|
@@ -3449,11 +3484,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3449
3484
|
return "";
|
3450
3485
|
},
|
3451
3486
|
style: lodash.merge(
|
3452
|
-
|
3487
|
+
LABEL_DEFAULT_OPTIONS.style,
|
3453
3488
|
{
|
3454
|
-
|
3455
|
-
|
3456
|
-
}
|
3489
|
+
color: lodash.get(additionOptions, `${ highchartsRenderer.getLabelOptionKey(additionOptions) }.font_color`)
|
3490
|
+
|| LABEL_DEFAULT_OPTIONS.color,
|
3491
|
+
},
|
3492
|
+
highchartsRenderer.getDataLabelsStyle(additionOptions),
|
3457
3493
|
),
|
3458
3494
|
},
|
3459
3495
|
labels: {
|
@@ -3499,10 +3535,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3499
3535
|
}
|
3500
3536
|
|
3501
3537
|
chartOptions.xAxis = {
|
3502
|
-
categories:
|
3538
|
+
categories: highchartsRenderer.getFormattedColKeys(pivotData, null),
|
3503
3539
|
title: {
|
3504
3540
|
text: additionOptions && additionOptions.axisX ? additionOptions.axisX.name : ''
|
3505
|
-
}
|
3541
|
+
},
|
3506
3542
|
};
|
3507
3543
|
chartOptions = highchartsRenderer.prepareAxisX(chartOptions, additionOptions, pivotData.getColKeys());
|
3508
3544
|
chartOptions.series = highchartsRenderer.ptCreateBasicLineSeries(pivotData, null, null, null, null, opts, chartOptions);
|
@@ -4771,6 +4807,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4771
4807
|
optsFiltered = $.extend(defaults, opts);
|
4772
4808
|
result = null;
|
4773
4809
|
try {
|
4810
|
+
const isTranspose = lodash.get(opts, 'rendererOptions.chartOptions.table_options.transpose_table', false);
|
4811
|
+
opts.getFormattedColKeys = isTranspose ? highchartsRenderer.getFormattedRowKeys : highchartsRenderer.getFormattedColKeys;
|
4812
|
+
opts.getFormattedRowKeys = isTranspose ? highchartsRenderer.getFormattedColKeys : highchartsRenderer.getFormattedRowKeys;
|
4813
|
+
|
4774
4814
|
pivotData = $.pivotUtilities.getPivotDataModel(rowData, opts);
|
4775
4815
|
pivotData.sortByValueAttrs = [];
|
4776
4816
|
try {
|
@@ -4823,6 +4863,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4823
4863
|
result = {};
|
4824
4864
|
}
|
4825
4865
|
}
|
4866
|
+
|
4826
4867
|
return result;
|
4827
4868
|
};
|
4828
4869
|
|
@@ -4852,6 +4893,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4852
4893
|
sortByValueAttrs: pivotOptions ? pivotOptions.sortByValueAttrs : null,
|
4853
4894
|
cols: lodash.map(pivotOptions.axisArray, 'name'),
|
4854
4895
|
rows: lodash.map(pivotOptions.legendArray, 'name'),
|
4896
|
+
colFormats: lodash.map(pivotOptions.axisArray, 'format'),
|
4897
|
+
rowFormats: lodash.map(pivotOptions.legendArray, 'format'),
|
4855
4898
|
rendererOptions: widget.options,
|
4856
4899
|
dateValuesDictionary: pivotOptions ? pivotOptions.dateValuesDictionary : null,
|
4857
4900
|
};
|
@@ -5930,7 +5973,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
5930
5973
|
if (!opt) {
|
5931
5974
|
opt = {};
|
5932
5975
|
}
|
5933
|
-
opt.drillDownListFunc =
|
5976
|
+
opt.drillDownListFunc = (e) => {
|
5977
|
+
highchartsRenderer.modifyEventPointForDrilldown(e);
|
5978
|
+
drillDownListFunc(e);
|
5979
|
+
};
|
5934
5980
|
opt.insightsTooltipFunc = insightsTooltipFunc;
|
5935
5981
|
opt.trackUserInsightsTooltipFunc = trackUserInsightsTooltipFunc;
|
5936
5982
|
} else {
|
@@ -9312,6 +9358,62 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9312
9358
|
return highchartsRenderer.enabledNewWidgetValueFormatting && (isCustomFormat || !isSecondaryAxis);
|
9313
9359
|
}
|
9314
9360
|
|
9361
|
+
highchartsRenderer.isFormattingAxis = function () {
|
9362
|
+
return lodash.includes(lodash.get(document, 'ReportHippo.user.features', []), FEATURES.FORMAT_AXIS);
|
9363
|
+
}
|
9364
|
+
|
9365
|
+
// Method for getting formatted kyes for Axis (cols, rows)
|
9366
|
+
// TODO: Move here dates formatting from highchartsRenderer.getWidgetDataSorters. Ticket created: DR-22009
|
9367
|
+
highchartsRenderer.getFormattedKey = function (initialKey, pivotData, type) {
|
9368
|
+
const isFlatKey = lodash.isString(initialKey) || lodash.isNumber(initialKey);
|
9369
|
+
if (highchartsRenderer.isFormattingAxis() && (isFlatKey || lodash.isArray(initialKey))) {
|
9370
|
+
let values = isFlatKey ? initialKey.toString().split(highchartsRenderer.delimer) : lodash.cloneDeep(initialKey);
|
9371
|
+
if (values) {
|
9372
|
+
lodash.forEach(values, (value, key) => {
|
9373
|
+
const format = pivotData[type][key];
|
9374
|
+
const valueToFloat = parseFloat(value);
|
9375
|
+
values[key] = !isNaN(valueToFloat) && format
|
9376
|
+
? highchartsRenderer.formatValue('n', format, valueToFloat).value
|
9377
|
+
: value;
|
9378
|
+
});
|
9379
|
+
return isFlatKey ? values.join(highchartsRenderer.delimer) : values;
|
9380
|
+
}
|
9381
|
+
}
|
9382
|
+
return initialKey;
|
9383
|
+
}
|
9384
|
+
|
9385
|
+
highchartsRenderer.getFormattedColKey = function (initialValue, pivotData) {
|
9386
|
+
return highchartsRenderer.getFormattedKey(initialValue, pivotData, 'colFormats')
|
9387
|
+
}
|
9388
|
+
|
9389
|
+
highchartsRenderer.getFormattedRowKey = function (initialValue, pivotData) {
|
9390
|
+
return highchartsRenderer.getFormattedKey(initialValue, pivotData, 'rowFormats')
|
9391
|
+
}
|
9392
|
+
|
9393
|
+
highchartsRenderer.getFormattedKeys = function(pivotData, isCols, keys) {
|
9394
|
+
keys = keys || (isCols ? pivotData.getColKeys() : pivotData.getRowKeys());
|
9395
|
+
return highchartsRenderer.isFormattingAxis()
|
9396
|
+
? lodash.map(keys, key => highchartsRenderer.getFormattedKey(key, pivotData, isCols ? 'colFormats' : 'rowFormats'))
|
9397
|
+
: keys;
|
9398
|
+
}
|
9399
|
+
|
9400
|
+
highchartsRenderer.getFormattedColKeys = function(pivotData, keys) {
|
9401
|
+
return highchartsRenderer.getFormattedKeys(pivotData, true, keys);
|
9402
|
+
}
|
9403
|
+
|
9404
|
+
highchartsRenderer.getFormattedRowKeys = function(pivotData, keys) {
|
9405
|
+
return highchartsRenderer.getFormattedKeys(pivotData, false, keys);
|
9406
|
+
}
|
9407
|
+
|
9408
|
+
highchartsRenderer.modifyEventPointForDrilldown = function(e) {
|
9409
|
+
if (!highchartsRenderer.isFormattingAxis()) {
|
9410
|
+
return;
|
9411
|
+
}
|
9412
|
+
e.point = lodash.cloneDeep(e.point);
|
9413
|
+
e.point.name = e.point.initialName;
|
9414
|
+
lodash.set(e, 'point.category.userOptions', e.point.initialName.toString().split(highchartsRenderer.delimer));
|
9415
|
+
}
|
9416
|
+
|
9315
9417
|
return highchartsRenderer;
|
9316
9418
|
};
|
9317
9419
|
|
package/src/novix_renderer.js
CHANGED
@@ -376,13 +376,14 @@ let initNovixRenderer = function($, window, document, Handsontable){
|
|
376
376
|
//data columns
|
377
377
|
if (pvtData.colKeys.length > 0) {
|
378
378
|
|
379
|
+
const formattedColKeys = pvtData.getFormattedColKeys(colKeys);
|
379
380
|
var aux = rowData.length;
|
380
381
|
var startCol = aux;
|
381
|
-
var prior =
|
382
|
+
var prior = formattedColKeys[0][nn];
|
382
383
|
var toMerge = 0;
|
383
|
-
for (var cc = 0; cc <
|
384
|
+
for (var cc = 0; cc < formattedColKeys.length; cc++) {
|
384
385
|
|
385
|
-
var textHeader =
|
386
|
+
var textHeader = formattedColKeys[cc][nn];
|
386
387
|
|
387
388
|
if (nn < pvtData.colAttrs.length - 1 && prior != textHeader) {
|
388
389
|
rowData.push(textHeader);
|
@@ -456,8 +457,9 @@ let initNovixRenderer = function($, window, document, Handsontable){
|
|
456
457
|
// DATA
|
457
458
|
|
458
459
|
var mergeDic = {};
|
460
|
+
const formattedRowKeys = pvtData.getFormattedRowKeys(rowKeys);
|
459
461
|
|
460
|
-
for (var rr = 0; rr <
|
462
|
+
for (var rr = 0; rr < formattedRowKeys.length; rr++) {
|
461
463
|
|
462
464
|
var rowData = [];
|
463
465
|
|
@@ -466,29 +468,29 @@ let initNovixRenderer = function($, window, document, Handsontable){
|
|
466
468
|
mergeDic[cc] = {
|
467
469
|
toMerge: 1,
|
468
470
|
row: 0,
|
469
|
-
priorText:
|
471
|
+
priorText: formattedRowKeys[rr][cc]
|
470
472
|
};
|
471
473
|
}
|
472
474
|
}
|
473
475
|
|
474
476
|
//column for row atts
|
475
477
|
for (var cc = 0; cc < pvtData.rowAttrs.length; cc++) {
|
476
|
-
rowData.push(
|
477
|
-
if (
|
478
|
+
rowData.push(formattedRowKeys[rr][cc]);
|
479
|
+
if (formattedRowKeys[rr][cc] === subtotal) {
|
478
480
|
addMergeCell(rr + pvtData.colAttrs.length + 1, cc, 1, dataSource.fixedColumns - cc, true, true);
|
479
|
-
} else if (cc ===
|
481
|
+
} else if (cc === formattedRowKeys[rr].length - 1 && hasColumnAttr) {
|
480
482
|
addMergeCell(rr + pvtData.colAttrs.length + 1, cc, 1, 2, true, true);
|
481
483
|
}
|
482
484
|
// merge cell (last column)
|
483
485
|
if (opts.chartOptions.table_options.show_column_total && rr != 0 && mergeDic[cc]) { // check for merge dic
|
484
|
-
if (
|
486
|
+
if (formattedRowKeys[rr][cc] == mergeDic[cc].priorText) {
|
485
487
|
mergeDic[cc].toMerge++;
|
486
|
-
} else if (cc <
|
488
|
+
} else if (cc < formattedRowKeys[rr].length - 1) {
|
487
489
|
//create merge cell for this column
|
488
490
|
addMergeCell(mergeDic[cc].row + pvtData.colAttrs.length + 1, cc, mergeDic[cc].toMerge, 1);
|
489
491
|
mergeDic[cc].row = rr;
|
490
492
|
mergeDic[cc].toMerge = 1;
|
491
|
-
mergeDic[cc].priorText =
|
493
|
+
mergeDic[cc].priorText = formattedRowKeys[rr][cc];
|
492
494
|
}
|
493
495
|
}
|
494
496
|
}
|
package/src/pivottable.js
CHANGED
@@ -694,6 +694,11 @@ let initPivotTable = function($, window, document) {
|
|
694
694
|
this.sorted = false;
|
695
695
|
this.dateValuesDictionary = opts.dateValuesDictionary;
|
696
696
|
this.sortByValueAttrs = opts.sortByValueAttrs || [];
|
697
|
+
this.colFormats = opts.colFormats || [];
|
698
|
+
this.rowFormats = opts.rowFormats || [];
|
699
|
+
this.getFormattedColKeys = (keys) => opts.getFormattedColKeys(this, keys);
|
700
|
+
this.getFormattedRowKeys = (keys) => opts.getFormattedRowKeys(this, keys);
|
701
|
+
|
697
702
|
PivotData.forEachRecord(this.input, this.derivedAttributes, (function(_this) {
|
698
703
|
return function(record) {
|
699
704
|
if (_this.filter(record)) {
|
@@ -4818,4 +4818,348 @@ describe('highcharts_renderer', () => {
|
|
4818
4818
|
expect(result).toEqual(expectedValue);
|
4819
4819
|
});
|
4820
4820
|
});
|
4821
|
+
|
4822
|
+
describe('Function isFormattingAxis', () => {
|
4823
|
+
it('should return true if FF is true', () => {
|
4824
|
+
lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
|
4825
|
+
expect(highchartsRenderer.isFormattingAxis()).toEqual(true);
|
4826
|
+
});
|
4827
|
+
|
4828
|
+
it('should return false if FF is false', () => {
|
4829
|
+
lodash.set(document, 'ReportHippo.user.features', []);
|
4830
|
+
expect(highchartsRenderer.isFormattingAxis()).toEqual(false);
|
4831
|
+
});
|
4832
|
+
});
|
4833
|
+
|
4834
|
+
describe('Function getFormattedKey', () => {
|
4835
|
+
describe('getFormattedKey with FF on', () => {
|
4836
|
+
beforeEach(() => {
|
4837
|
+
lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
|
4838
|
+
});
|
4839
|
+
|
4840
|
+
it('should return properly formatted colKey as array', () => {
|
4841
|
+
const initialKey = ['1000'];
|
4842
|
+
const pivotData = {
|
4843
|
+
colFormats: ['$####.##', '₪####.##'],
|
4844
|
+
rowFormats: ['€####.##', '£####.##'],
|
4845
|
+
};
|
4846
|
+
const type = 'colFormats';
|
4847
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4848
|
+
expect(formattedKey).toEqual(['$1000.0']);
|
4849
|
+
});
|
4850
|
+
|
4851
|
+
it('should return properly formatted rowKey as array', () => {
|
4852
|
+
const initialKey = ['1000'];
|
4853
|
+
const pivotData = {
|
4854
|
+
colFormats: ['€####.##', '£####.##'],
|
4855
|
+
rowFormats: ['$####.##', '₪####.##'],
|
4856
|
+
};
|
4857
|
+
const type = 'rowFormats';
|
4858
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4859
|
+
expect(formattedKey).toEqual(['$1000.0']);
|
4860
|
+
});
|
4861
|
+
|
4862
|
+
it('should return properly formatted colKey as string', () => {
|
4863
|
+
const initialKey = '1000';
|
4864
|
+
const pivotData = {
|
4865
|
+
colFormats: ['$####.##', '₪####.##'],
|
4866
|
+
rowFormats: ['€####.##', '£####.##'],
|
4867
|
+
};
|
4868
|
+
const type = 'colFormats';
|
4869
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4870
|
+
expect(formattedKey).toEqual('$1000.0');
|
4871
|
+
});
|
4872
|
+
|
4873
|
+
it('should return properly formatted rowKey as string', () => {
|
4874
|
+
const initialKey = '1000';
|
4875
|
+
const pivotData = {
|
4876
|
+
colFormats: ['€####.##', '£####.##'],
|
4877
|
+
rowFormats: ['$####.##', '₪####.##'],
|
4878
|
+
};
|
4879
|
+
const type = 'rowFormats';
|
4880
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4881
|
+
expect(formattedKey).toEqual('$1000.0');
|
4882
|
+
});
|
4883
|
+
|
4884
|
+
it('should return formatted multivalue colKey as string', () => {
|
4885
|
+
const initialKey = '1000 , 2000';
|
4886
|
+
const pivotData = {
|
4887
|
+
colFormats: ['$####.##', '₪####.##'],
|
4888
|
+
};
|
4889
|
+
const type = 'colFormats';
|
4890
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4891
|
+
expect(formattedKey).toEqual('$1000.0 , ₪2000.0');
|
4892
|
+
});
|
4893
|
+
|
4894
|
+
it('should return formatted multivalue colKey as array', () => {
|
4895
|
+
const initialKey = ['1000', '2000'];
|
4896
|
+
const pivotData = {
|
4897
|
+
colFormats: ['$####.##', '₪####.##'],
|
4898
|
+
};
|
4899
|
+
const type = 'colFormats';
|
4900
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4901
|
+
expect(formattedKey).toEqual(['$1000.0', '₪2000.0']);
|
4902
|
+
});
|
4903
|
+
|
4904
|
+
it('should return not formatted second value (test as array)', () => {
|
4905
|
+
const initialKey = ['1000', '2000'];
|
4906
|
+
const pivotData = {
|
4907
|
+
colFormats: ['$####.##', null],
|
4908
|
+
};
|
4909
|
+
const type = 'colFormats';
|
4910
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4911
|
+
expect(formattedKey).toEqual(['$1000.0', '2000']);
|
4912
|
+
});
|
4913
|
+
|
4914
|
+
it('should return not formatted first value (test as array)', () => {
|
4915
|
+
const initialKey = ['1000', '2000'];
|
4916
|
+
const pivotData = {
|
4917
|
+
colFormats: [null, '$####.##'],
|
4918
|
+
};
|
4919
|
+
const type = 'colFormats';
|
4920
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4921
|
+
expect(formattedKey).toEqual(['1000', '$2000.0']);
|
4922
|
+
});
|
4923
|
+
});
|
4924
|
+
|
4925
|
+
describe('getFormattedKey with FF off', () => {
|
4926
|
+
beforeEach(() => {
|
4927
|
+
lodash.set(document, 'ReportHippo.user.features', []);
|
4928
|
+
});
|
4929
|
+
|
4930
|
+
it('should return NOT formatted colKey as array', () => {
|
4931
|
+
const initialKey = ['1000'];
|
4932
|
+
const pivotData = {
|
4933
|
+
colFormats: ['$####.##', '₪####.##'],
|
4934
|
+
rowFormats: ['€####.##', '£####.##'],
|
4935
|
+
};
|
4936
|
+
const type = 'colFormats';
|
4937
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type,);
|
4938
|
+
expect(formattedKey).toEqual(['1000']);
|
4939
|
+
});
|
4940
|
+
|
4941
|
+
it('should return NOT formatted rowKey as array', () => {
|
4942
|
+
const initialKey = ['1000'];
|
4943
|
+
const pivotData = {
|
4944
|
+
colFormats: ['€####.##', '£####.##'],
|
4945
|
+
rowFormats: ['$####.##', '₪####.##'],
|
4946
|
+
};
|
4947
|
+
const type = 'rowFormats';
|
4948
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4949
|
+
expect(formattedKey).toEqual(['1000']);
|
4950
|
+
});
|
4951
|
+
|
4952
|
+
it('should return NOT formatted colKey as string', () => {
|
4953
|
+
const initialKey = '1000';
|
4954
|
+
const pivotData = {
|
4955
|
+
colFormats: ['$####.##', '₪####.##'],
|
4956
|
+
rowFormats: ['€####.##', '£####.##'],
|
4957
|
+
};
|
4958
|
+
const type = 'colFormats';
|
4959
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4960
|
+
expect(formattedKey).toEqual('1000');
|
4961
|
+
});
|
4962
|
+
|
4963
|
+
it('should return NOT formatted rowKey as string', () => {
|
4964
|
+
const initialKey = '1000';
|
4965
|
+
const pivotData = {
|
4966
|
+
colFormats: ['€####.##', '£####.##'],
|
4967
|
+
rowFormats: ['$####.##', '₪####.##'],
|
4968
|
+
};
|
4969
|
+
const type = 'rowFormats';
|
4970
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4971
|
+
expect(formattedKey).toEqual('1000');
|
4972
|
+
});
|
4973
|
+
|
4974
|
+
it('should return NOT formatted multivalue colKey as string', () => {
|
4975
|
+
const initialKey = '1000 , 2000';
|
4976
|
+
const pivotData = {
|
4977
|
+
colFormats: ['$####.##', '₪####.##'],
|
4978
|
+
};
|
4979
|
+
const type = 'colFormats';
|
4980
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4981
|
+
expect(formattedKey).toEqual('1000 , 2000');
|
4982
|
+
});
|
4983
|
+
|
4984
|
+
it('should return NOT formatted multivalue colKey as array', () => {
|
4985
|
+
const initialKey = ['1000', '2000'];
|
4986
|
+
const pivotData = {
|
4987
|
+
colFormats: ['$####.##', '₪####.##'],
|
4988
|
+
};
|
4989
|
+
const type = 'colFormats';
|
4990
|
+
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
4991
|
+
expect(formattedKey).toEqual(['1000', '2000']);
|
4992
|
+
});
|
4993
|
+
});
|
4994
|
+
});
|
4995
|
+
|
4996
|
+
describe('Functions getFormattedColKey/getFormattedRowKey', () => {
|
4997
|
+
beforeEach(() => {
|
4998
|
+
spyOn(highchartsRenderer, 'getFormattedKey').and.returnValue(null);
|
4999
|
+
});
|
5000
|
+
|
5001
|
+
it('should getFormattedColKey call getFormattedKey for colFormats', () => {
|
5002
|
+
highchartsRenderer.getFormattedColKey('test1', 'test2');
|
5003
|
+
expect(highchartsRenderer.getFormattedKey).toHaveBeenCalledWith('test1', 'test2', 'colFormats');
|
5004
|
+
});
|
5005
|
+
|
5006
|
+
it('should getFormattedRowKey call getFormattedKey for rowFormats', () => {
|
5007
|
+
highchartsRenderer.getFormattedRowKey('test1', 'test2');
|
5008
|
+
expect(highchartsRenderer.getFormattedKey).toHaveBeenCalledWith('test1', 'test2', 'rowFormats');
|
5009
|
+
});
|
5010
|
+
});
|
5011
|
+
|
5012
|
+
describe('Function getFormattedKeys', () => {
|
5013
|
+
|
5014
|
+
const testKeys = [['1', '11'], ['2', '32'], ['[null]', '43'], ['5', '54'], ['Others', '33'], ['6', '98']];
|
5015
|
+
const pivotData = {
|
5016
|
+
getColKeys: () => testKeys,
|
5017
|
+
getRowKeys: () => testKeys,
|
5018
|
+
};
|
5019
|
+
|
5020
|
+
beforeEach(() => {
|
5021
|
+
spyOn(highchartsRenderer, 'getFormattedKey').and.callThrough();
|
5022
|
+
});
|
5023
|
+
|
5024
|
+
describe('getFormattedKeys with FF on', () => {
|
5025
|
+
|
5026
|
+
beforeEach(() => {
|
5027
|
+
lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
|
5028
|
+
});
|
5029
|
+
|
5030
|
+
it('should call getFormattedKey 6 times', () => {
|
5031
|
+
pivotData.colFormats = ['$####.##', '₪####.##'];
|
5032
|
+
const isCols = true;
|
5033
|
+
highchartsRenderer.getFormattedKeys(pivotData, isCols, null);
|
5034
|
+
expect(highchartsRenderer.getFormattedKey).toHaveBeenCalledTimes(6);
|
5035
|
+
});
|
5036
|
+
|
5037
|
+
it('should return properly formatted colKeys as arrays [Dataset 1]', () => {
|
5038
|
+
pivotData.colFormats = ['$####.##', '₪####.##'];
|
5039
|
+
const isCols = true;
|
5040
|
+
const formattedKeys = highchartsRenderer.getFormattedKeys(pivotData, isCols, null);
|
5041
|
+
expect(formattedKeys).toEqual(
|
5042
|
+
[['$1.0', '₪11.0'], ['$2.0', '₪32.0'], ['[null]', '₪43.0'], ['$5.0', '₪54.0'], ['Others', '₪33.0'], ['$6.0', '₪98.0']]
|
5043
|
+
);
|
5044
|
+
});
|
5045
|
+
|
5046
|
+
it('should return properly formatted colKeys as arrays [Dataset 2]', () => {
|
5047
|
+
pivotData.colFormats = [null, '₪####.##'];
|
5048
|
+
const isCols = true;
|
5049
|
+
const formattedKeys = highchartsRenderer.getFormattedKeys(pivotData, isCols, null);
|
5050
|
+
expect(formattedKeys).toEqual(
|
5051
|
+
[['1', '₪11.0'], ['2', '₪32.0'], ['[null]', '₪43.0'], ['5', '₪54.0'], ['Others', '₪33.0'], ['6', '₪98.0']]
|
5052
|
+
);
|
5053
|
+
});
|
5054
|
+
|
5055
|
+
it('should return properly formatted colKeys as arrays [Dataset 3]', () => {
|
5056
|
+
pivotData.colFormats = ['$####.##', null];
|
5057
|
+
const isCols = true;
|
5058
|
+
const formattedKeys = highchartsRenderer.getFormattedKeys(pivotData, isCols, null);
|
5059
|
+
expect(formattedKeys).toEqual(
|
5060
|
+
[['$1.0', '11'], ['$2.0', '32'], ['[null]', '43'], ['$5.0', '54'], ['Others', '33'], ['$6.0', '98']]
|
5061
|
+
);
|
5062
|
+
});
|
5063
|
+
|
5064
|
+
it('should return properly formatted rowKeys as arrays [Dataset 1]', () => {
|
5065
|
+
pivotData.rowFormats = ['$####.##', '₪####.##'];
|
5066
|
+
const isCols = false;
|
5067
|
+
const formattedKeys = highchartsRenderer.getFormattedKeys(pivotData, isCols, null);
|
5068
|
+
expect(formattedKeys).toEqual(
|
5069
|
+
[['$1.0', '₪11.0'], ['$2.0', '₪32.0'], ['[null]', '₪43.0'], ['$5.0', '₪54.0'], ['Others', '₪33.0'], ['$6.0', '₪98.0']]
|
5070
|
+
);
|
5071
|
+
});
|
5072
|
+
|
5073
|
+
it('should return properly formatted rowKeys as arrays [Dataset 2]', () => {
|
5074
|
+
pivotData.rowFormats = [null, '₪####.##'];
|
5075
|
+
const isCols = false;
|
5076
|
+
const formattedKeys = highchartsRenderer.getFormattedKeys(pivotData, isCols, null);
|
5077
|
+
expect(formattedKeys).toEqual(
|
5078
|
+
[['1', '₪11.0'], ['2', '₪32.0'], ['[null]', '₪43.0'], ['5', '₪54.0'], ['Others', '₪33.0'], ['6', '₪98.0']]
|
5079
|
+
);
|
5080
|
+
});
|
5081
|
+
|
5082
|
+
it('should return properly formatted rowKeys as arrays [Dataset 3]', () => {
|
5083
|
+
pivotData.rowFormats = ['$####.##', null];
|
5084
|
+
const isCols = false;
|
5085
|
+
const formattedKeys = highchartsRenderer.getFormattedKeys(pivotData, isCols, null);
|
5086
|
+
expect(formattedKeys).toEqual(
|
5087
|
+
[['$1.0', '11'], ['$2.0', '32'], ['[null]', '43'], ['$5.0', '54'], ['Others', '33'], ['$6.0', '98']]
|
5088
|
+
);
|
5089
|
+
});
|
5090
|
+
});
|
5091
|
+
|
5092
|
+
describe('getFormattedKey with FF off', () => {
|
5093
|
+
|
5094
|
+
pivotData.colFormats = ['$####.##', '₪####.##'];
|
5095
|
+
const isCols = true;
|
5096
|
+
|
5097
|
+
beforeEach(() => {
|
5098
|
+
lodash.set(document, 'ReportHippo.user.features', []);
|
5099
|
+
});
|
5100
|
+
|
5101
|
+
it('should not call getFormattedKey', () => {
|
5102
|
+
highchartsRenderer.getFormattedKeys(pivotData, isCols, null);
|
5103
|
+
expect(highchartsRenderer.getFormattedKey).not.toHaveBeenCalled();
|
5104
|
+
});
|
5105
|
+
|
5106
|
+
it('should return NOT formatted colKeys', () => {
|
5107
|
+
const formattedKeys = highchartsRenderer.getFormattedKeys(pivotData, isCols, null);
|
5108
|
+
expect(formattedKeys).toEqual(
|
5109
|
+
[['1', '11'], ['2', '32'], ['[null]', '43'], ['5', '54'], ['Others', '33'], ['6', '98']]
|
5110
|
+
);
|
5111
|
+
});
|
5112
|
+
});
|
5113
|
+
});
|
5114
|
+
|
5115
|
+
describe('Functions getFormattedColKeys/getFormattedRowKeys', () => {
|
5116
|
+
beforeEach(() => {
|
5117
|
+
spyOn(highchartsRenderer, 'getFormattedKeys').and.returnValue(null);
|
5118
|
+
});
|
5119
|
+
|
5120
|
+
it('should getFormattedColKeys call getFormattedKeys for colFormats', () => {
|
5121
|
+
highchartsRenderer.getFormattedColKeys('test1', 'test2');
|
5122
|
+
expect(highchartsRenderer.getFormattedKeys).toHaveBeenCalledWith('test1', true, 'test2');
|
5123
|
+
});
|
5124
|
+
|
5125
|
+
it('should getFormattedRowKeys call getFormattedKeys for rowFormats', () => {
|
5126
|
+
highchartsRenderer.getFormattedRowKeys('test1', 'test2', 'test3');
|
5127
|
+
expect(highchartsRenderer.getFormattedKeys).toHaveBeenCalledWith('test1', false, 'test2');
|
5128
|
+
});
|
5129
|
+
});
|
5130
|
+
|
5131
|
+
describe('Function modifyEventPointForDrilldown', () => {
|
5132
|
+
|
5133
|
+
const event = {
|
5134
|
+
point: {
|
5135
|
+
initialName: 'key1',
|
5136
|
+
name: 'key2',
|
5137
|
+
category: {
|
5138
|
+
userOptions: ['key4'],
|
5139
|
+
},
|
5140
|
+
}
|
5141
|
+
};
|
5142
|
+
|
5143
|
+
beforeEach(() => {
|
5144
|
+
spyOn(highchartsRenderer, 'getFormattedKeys').and.returnValue(null);
|
5145
|
+
});
|
5146
|
+
|
5147
|
+
it('should not modify if FF is off', () => {
|
5148
|
+
const e = lodash.cloneDeep(event);
|
5149
|
+
lodash.set(document, 'ReportHippo.user.features', []);
|
5150
|
+
|
5151
|
+
highchartsRenderer.modifyEventPointForDrilldown(e);
|
5152
|
+
expect(e.point.name).toEqual(event.point.name);
|
5153
|
+
expect(e.point.category.userOptions).toEqual(event.point.category.userOptions);
|
5154
|
+
});
|
5155
|
+
|
5156
|
+
it('should modify if FF is on', () => {
|
5157
|
+
const e = lodash.cloneDeep(event);
|
5158
|
+
lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
|
5159
|
+
|
5160
|
+
highchartsRenderer.modifyEventPointForDrilldown(e);
|
5161
|
+
expect(e.point.name).toEqual(event.point.initialName);
|
5162
|
+
expect(e.point.category.userOptions).toEqual([event.point.initialName]);
|
5163
|
+
});
|
5164
|
+
});
|
4821
5165
|
});
|