@datarailsshared/dr_renderer 1.2.442 → 1.2.445
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/highcharts_renderer.js +46 -30
- package/tests/highcharts_renderer.test.js +168 -1
package/package.json
CHANGED
@@ -1567,6 +1567,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1567
1567
|
totalSeries.className = 'totalSeries';
|
1568
1568
|
totalSeries.name = 'Total';
|
1569
1569
|
totalSeries.data = [];
|
1570
|
+
|
1571
|
+
// DEV_FF: DR-31422
|
1572
|
+
if (opts.devFixDrollDownByTotal) {
|
1573
|
+
totalSeries.initialName = 'Total';
|
1574
|
+
totalSeries.isTotal = true;
|
1575
|
+
}
|
1570
1576
|
|
1571
1577
|
if (colors && colors[i]) {
|
1572
1578
|
totalSeries.color = colors[i];
|
@@ -8120,8 +8126,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8120
8126
|
}
|
8121
8127
|
|
8122
8128
|
// TODO: refactor, too many conditions, unreadable
|
8123
|
-
highchartsRenderer.getFilterLabel = function (fieldFilter, showTemplateName, isFormattingNumbers, isGlobalFilter = false) {
|
8129
|
+
highchartsRenderer.getFilterLabel = function (fieldFilter, showTemplateName, isFormattingNumbers, isGlobalFilter = false, isPermissionFilter = false) {
|
8124
8130
|
var displayname;
|
8131
|
+
const isPermissionOrGlobalFilter = (isGlobalFilter || isPermissionFilter);
|
8132
|
+
const separator = isGlobalFilter ? ': ' : isPermissionFilter ? highchartsRenderer.getPermissionFilterSeparatorHighlighter(` ${fieldFilter.excludes ? 'exclude': 'include'} `) : '';
|
8133
|
+
|
8125
8134
|
if (fieldFilter.new_name)
|
8126
8135
|
displayname = fieldFilter.new_name.replace('RH_DIM_', '');
|
8127
8136
|
else {
|
@@ -8133,7 +8142,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8133
8142
|
}
|
8134
8143
|
|
8135
8144
|
if (fieldFilter.template_name && fieldFilter.datetypevalues && (fieldFilter.datetypevalues.datetype == 'range' || fieldFilter.datetypevalues.datetype == 'frame')) {
|
8136
|
-
const label = displayname + (
|
8145
|
+
const label = displayname + (isPermissionOrGlobalFilter ? highchartsRenderer.getGlobalFilterValueHighlighter(fieldFilter.datetypevalues.datetype) : ' (' + fieldFilter.datetypevalues.datetype + ')');
|
8137
8146
|
return {
|
8138
8147
|
label,
|
8139
8148
|
tooltip: displayname + ' (' + fieldFilter.datetypevalues.datetype + ')'
|
@@ -8164,8 +8173,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8164
8173
|
if (all_vals) {
|
8165
8174
|
all_vals = all_vals.join(', ');
|
8166
8175
|
tooltip = ' (' + all_vals + ')';
|
8167
|
-
if (all_vals.split(',').length > highchartsRenderer.MAX_SELECTED_ITEMS_BEFORE_COLLAPSING &&
|
8168
|
-
|| all_vals.length > highchartsRenderer.MAX_SELECTED_ITEMS_CHARECHTERS_IN_LABEL && !
|
8176
|
+
if (all_vals.split(',').length > highchartsRenderer.MAX_SELECTED_ITEMS_BEFORE_COLLAPSING && isPermissionOrGlobalFilter
|
8177
|
+
|| all_vals.length > highchartsRenderer.MAX_SELECTED_ITEMS_CHARECHTERS_IN_LABEL && !isPermissionOrGlobalFilter) {
|
8169
8178
|
all_vals = 'Many';
|
8170
8179
|
}
|
8171
8180
|
all_vals = ' (' + all_vals + ')';
|
@@ -8176,9 +8185,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8176
8185
|
|
8177
8186
|
all_vals = highchartsRenderer.decodeFunc(all_vals);
|
8178
8187
|
tooltip = highchartsRenderer.decodeFunc(tooltip);
|
8179
|
-
if (
|
8188
|
+
if (isPermissionOrGlobalFilter) {
|
8180
8189
|
all_vals = highchartsRenderer.getGlobalFilterCounterString(all_vals);
|
8181
|
-
displayname = displayname +
|
8190
|
+
displayname = displayname + separator;
|
8182
8191
|
};
|
8183
8192
|
return {
|
8184
8193
|
label: displayname + all_vals,
|
@@ -8204,22 +8213,22 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8204
8213
|
|
8205
8214
|
if (all_vals) {
|
8206
8215
|
all_vals = all_vals.join(', ');
|
8207
|
-
tooltip = ' (Exclusions: ' + all_vals + ')';
|
8208
|
-
if (all_vals.split(',').length > highchartsRenderer.MAX_SELECTED_ITEMS_BEFORE_COLLAPSING &&
|
8209
|
-
|| all_vals.length > highchartsRenderer.MAX_SELECTED_ITEMS_CHARECHTERS_IN_LABEL && !
|
8216
|
+
tooltip = (isPermissionFilter ? ' (' : ' (Exclusions: ') + all_vals + ')';
|
8217
|
+
if (all_vals.split(',').length > highchartsRenderer.MAX_SELECTED_ITEMS_BEFORE_COLLAPSING && isPermissionOrGlobalFilter
|
8218
|
+
|| all_vals.length > highchartsRenderer.MAX_SELECTED_ITEMS_CHARECHTERS_IN_LABEL && !isPermissionOrGlobalFilter) {
|
8210
8219
|
all_vals = 'Many';
|
8211
8220
|
}
|
8212
|
-
all_vals = ' (Exclusions: ' + all_vals + ')';
|
8221
|
+
all_vals = (isPermissionFilter ? ' (' : ' (Exclusions: ') + all_vals + ')';
|
8213
8222
|
} else {
|
8214
|
-
tooltip =
|
8223
|
+
tooltip = isPermissionOrGlobalFilter ? separator + 'All' : ' (All)';
|
8215
8224
|
all_vals = 'All';
|
8216
8225
|
}
|
8217
8226
|
|
8218
8227
|
all_vals = highchartsRenderer.decodeFunc(all_vals);
|
8219
8228
|
tooltip = highchartsRenderer.decodeFunc(tooltip);
|
8220
|
-
if (
|
8229
|
+
if (isPermissionOrGlobalFilter) {
|
8221
8230
|
all_vals = highchartsRenderer.getGlobalFilterCounterString(all_vals);
|
8222
|
-
displayname = displayname +
|
8231
|
+
displayname = displayname + separator;
|
8223
8232
|
};
|
8224
8233
|
return {
|
8225
8234
|
label: displayname + all_vals,
|
@@ -8228,26 +8237,29 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8228
8237
|
} else {
|
8229
8238
|
if ((fieldFilter.includes && fieldFilter.includes.length == 0))
|
8230
8239
|
return {
|
8231
|
-
label: displayname + (
|
8232
|
-
tooltip: displayname + (
|
8240
|
+
label: displayname + (isPermissionOrGlobalFilter ? separator + 'None' : ' (None)'),
|
8241
|
+
tooltip: displayname + (isPermissionOrGlobalFilter ? ' None' : ' (None)'),
|
8233
8242
|
};
|
8234
8243
|
else if ((fieldFilter.excludes && fieldFilter.excludes.length == 0))
|
8235
8244
|
return {
|
8236
|
-
label: displayname + (
|
8237
|
-
tooltip: displayname + (
|
8245
|
+
label: displayname + (isPermissionOrGlobalFilter ? separator + 'All' : ' (All)'),
|
8246
|
+
tooltip: displayname + (isPermissionOrGlobalFilter ? (isPermissionFilter ? separator : ' ') + 'All' : ' (All)'),
|
8238
8247
|
};
|
8239
8248
|
else if ((fieldFilter.includes))
|
8240
8249
|
return {
|
8241
|
-
label: displayname + (
|
8250
|
+
label: displayname + (isPermissionOrGlobalFilter ? separator + highchartsRenderer.getGlobalFilterValueHighlighter('Many') : ' (Many)'),
|
8242
8251
|
tooltip: displayname + ' (' +
|
8243
8252
|
lodash.map(fieldFilter.includes, item => highchartsRenderer.returnRawDataValue(fieldFilter.type, item, fieldFilter.format)).join(', ') +
|
8244
8253
|
')'
|
8245
8254
|
};
|
8246
8255
|
else {
|
8247
|
-
|
8248
|
-
|
8256
|
+
let label = displayname + (isGlobalFilter ? separator + highchartsRenderer.getGlobalFilterValueHighlighter('Exclusions: Many') : ' (Exclusions Many)');
|
8257
|
+
if (isPermissionFilter) {
|
8258
|
+
label = displayname + separator + ' Many';
|
8259
|
+
}
|
8260
|
+
return {
|
8249
8261
|
label,
|
8250
|
-
tooltip: displayname + ' (Exclusions: ' +
|
8262
|
+
tooltip: displayname + (isPermissionFilter ? ' (' : ' (Exclusions: ') +
|
8251
8263
|
lodash.map(fieldFilter.excludes, item => highchartsRenderer.returnRawDataValue(fieldFilter.type, item, fieldFilter.format)).join(', ') +
|
8252
8264
|
')'
|
8253
8265
|
};
|
@@ -8257,10 +8269,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8257
8269
|
if (fieldFilter && fieldFilter.type && fieldFilter.type === 'Date' && fieldFilter.datetypevalues) {
|
8258
8270
|
if (fieldFilter.datetypevalues.datetype === "frame") {
|
8259
8271
|
const timeframeLabel = highchartsRenderer.DATE_FILTER_TIMEFRAME_LABELS[fieldFilter.datetypevalues.val.timeframe] || highchartsRenderer.getDateFilterCustomTimeframeLabel(fieldFilter.datetypevalues.val);
|
8260
|
-
if (
|
8272
|
+
if (isPermissionOrGlobalFilter) {
|
8261
8273
|
return {
|
8262
|
-
label: displayname +
|
8263
|
-
tooltip: displayname +
|
8274
|
+
label: displayname + separator + highchartsRenderer.getGlobalFilterValueHighlighter(timeframeLabel),
|
8275
|
+
tooltip: displayname + separator + timeframeLabel,
|
8264
8276
|
}
|
8265
8277
|
}
|
8266
8278
|
displayname += ` (${ timeframeLabel })`;
|
@@ -8282,8 +8294,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8282
8294
|
.toLocaleDateString();
|
8283
8295
|
}
|
8284
8296
|
});
|
8285
|
-
if (
|
8286
|
-
displayname +=
|
8297
|
+
if (isPermissionOrGlobalFilter) {
|
8298
|
+
displayname += `${separator}${ highchartsRenderer.getGlobalFilterValueHighlighter(dates.from.displayedValue + '-' + dates.to.displayedValue) }`;
|
8287
8299
|
return {
|
8288
8300
|
label: displayname,
|
8289
8301
|
tooltip: dates.from.displayedValue + '-' + dates.to.displayedValue,
|
@@ -8291,18 +8303,18 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8291
8303
|
}
|
8292
8304
|
displayname += ` (${ dates.from.displayedValue }-${ dates.to.displayedValue })`;
|
8293
8305
|
} else {
|
8294
|
-
displayname +=
|
8306
|
+
displayname += isPermissionOrGlobalFilter ? separator + 'All' : ' (All)';
|
8295
8307
|
}
|
8296
8308
|
} else if (fieldFilter &&
|
8297
8309
|
((fieldFilter.values && fieldFilter.values.type === 'advanced') || (fieldFilter.datetypevalues && fieldFilter.datetypevalues.type === 'advanced'))) {
|
8298
|
-
displayname += (
|
8310
|
+
displayname += (isPermissionOrGlobalFilter ? separator + highchartsRenderer.getGlobalFilterValueHighlighter('Advanced') : ' (Advanced)');
|
8299
8311
|
return {
|
8300
8312
|
label: displayname,
|
8301
|
-
tooltip:
|
8313
|
+
tooltip: isPermissionOrGlobalFilter ? 'Advanced' : displayname,
|
8302
8314
|
};
|
8303
8315
|
|
8304
8316
|
} else {
|
8305
|
-
displayname +=
|
8317
|
+
displayname += isPermissionOrGlobalFilter ? separator + 'All' : ' (All)';
|
8306
8318
|
}
|
8307
8319
|
|
8308
8320
|
return {
|
@@ -8316,6 +8328,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8316
8328
|
return `<span class="filters-values-label">${ value }</span>`;
|
8317
8329
|
}
|
8318
8330
|
|
8331
|
+
highchartsRenderer.getPermissionFilterSeparatorHighlighter = function (value) {
|
8332
|
+
return `<span class="filters-values-separator">${ value }</span>`;
|
8333
|
+
}
|
8334
|
+
|
8319
8335
|
highchartsRenderer.getDateFilterCustomTimeframeLabel = function (value) {
|
8320
8336
|
if (!value || !value.timeframe || !value.timeframe.startsWith('x')) return 'Custom';
|
8321
8337
|
|
@@ -6882,7 +6882,174 @@ describe('highcharts_renderer', () => {
|
|
6882
6882
|
color: '#b3060e'
|
6883
6883
|
}
|
6884
6884
|
]);
|
6885
|
-
})
|
6885
|
+
});
|
6886
|
+
|
6887
|
+
describe("DR-31214 - Fix drilldown by total", () => {
|
6888
|
+
const originResponse = [{
|
6889
|
+
color: '#ff0202',
|
6890
|
+
data: [
|
6891
|
+
{
|
6892
|
+
drilldown: true,
|
6893
|
+
initialName: 'col 1',
|
6894
|
+
name: 'col 1',
|
6895
|
+
y: 12345
|
6896
|
+
},
|
6897
|
+
{
|
6898
|
+
drilldown: true,
|
6899
|
+
initialName: 'col 2',
|
6900
|
+
name: 'col 2',
|
6901
|
+
y: 54321
|
6902
|
+
},
|
6903
|
+
{
|
6904
|
+
drilldown: true,
|
6905
|
+
initialName: 'Others',
|
6906
|
+
name: 'Others',
|
6907
|
+
y: 99999
|
6908
|
+
}
|
6909
|
+
],
|
6910
|
+
dataLabels: {
|
6911
|
+
allowOverlap: false,
|
6912
|
+
color: '#151a41',
|
6913
|
+
enabled: true,
|
6914
|
+
formatter: expect.any(Function),
|
6915
|
+
style: {
|
6916
|
+
fontFamily: 'Poppins',
|
6917
|
+
fontSize: '11',
|
6918
|
+
fontWeight: 'normal'
|
6919
|
+
}
|
6920
|
+
},
|
6921
|
+
initialName: 'row 1',
|
6922
|
+
name: 'row 1'
|
6923
|
+
},
|
6924
|
+
{
|
6925
|
+
color: '#b3060e',
|
6926
|
+
data: [
|
6927
|
+
{
|
6928
|
+
drilldown: true,
|
6929
|
+
initialName: 'col 1',
|
6930
|
+
name: 'col 1',
|
6931
|
+
y: 123450
|
6932
|
+
},
|
6933
|
+
{
|
6934
|
+
drilldown: true,
|
6935
|
+
initialName: 'col 2',
|
6936
|
+
name: 'col 2',
|
6937
|
+
y: 11111
|
6938
|
+
},
|
6939
|
+
{
|
6940
|
+
drilldown: true,
|
6941
|
+
initialName: 'Others',
|
6942
|
+
name: 'Others',
|
6943
|
+
y: 99991
|
6944
|
+
}
|
6945
|
+
],
|
6946
|
+
dataLabels: {
|
6947
|
+
allowOverlap: false,
|
6948
|
+
color: '#151a41',
|
6949
|
+
enabled: true,
|
6950
|
+
formatter: expect.any(Function),
|
6951
|
+
style: {
|
6952
|
+
fontFamily: 'Poppins',
|
6953
|
+
fontSize: '11',
|
6954
|
+
fontWeight: 'normal'
|
6955
|
+
}
|
6956
|
+
},
|
6957
|
+
initialName: 'row 2',
|
6958
|
+
name: 'row 2'
|
6959
|
+
},
|
6960
|
+
{
|
6961
|
+
className: 'totalSeries',
|
6962
|
+
color: '#70000a',
|
6963
|
+
data: [
|
6964
|
+
{
|
6965
|
+
initialName: 'col 1',
|
6966
|
+
name: 'col 1',
|
6967
|
+
y: 123450
|
6968
|
+
},
|
6969
|
+
{
|
6970
|
+
initialName: 'col 2',
|
6971
|
+
name: 'col 2',
|
6972
|
+
y: 123451
|
6973
|
+
},
|
6974
|
+
{
|
6975
|
+
initialName: 'DR_Others',
|
6976
|
+
name: 'DR_Others',
|
6977
|
+
y: 123452
|
6978
|
+
}
|
6979
|
+
],
|
6980
|
+
dataLabels: {
|
6981
|
+
allowOverlap: false,
|
6982
|
+
color: '#151a41',
|
6983
|
+
enabled: true,
|
6984
|
+
formatter: expect.any(Function),
|
6985
|
+
style: {
|
6986
|
+
fontFamily: 'Poppins',
|
6987
|
+
fontSize: '11',
|
6988
|
+
fontWeight: 'normal'
|
6989
|
+
}
|
6990
|
+
},
|
6991
|
+
initialName: 'row 2',
|
6992
|
+
name: 'Total'
|
6993
|
+
}];
|
6994
|
+
|
6995
|
+
it("should mark the series as total if the feature flag is on", () => {
|
6996
|
+
additionalOptionsMock = {};
|
6997
|
+
opts = {
|
6998
|
+
total: true,
|
6999
|
+
devFixDrollDownByTotal: true,
|
7000
|
+
};
|
7001
|
+
pivotDataMock.colTotals = {
|
7002
|
+
"col 1": { value: () => 123450 },
|
7003
|
+
"col 2": { value: () => 123451 },
|
7004
|
+
DR_Others: { value: () => 123452 },
|
7005
|
+
};
|
7006
|
+
const value = highchartsRenderer.ptCreateColumnSeries(
|
7007
|
+
pivotDataMock,
|
7008
|
+
colors,
|
7009
|
+
onlyNumbers,
|
7010
|
+
isUniqueVals,
|
7011
|
+
isNotDrillDown,
|
7012
|
+
additionalOptionsMock,
|
7013
|
+
opts,
|
7014
|
+
chartOptions,
|
7015
|
+
chartType
|
7016
|
+
);
|
7017
|
+
const fixedResponse = [...originResponse];
|
7018
|
+
fixedResponse[fixedResponse.length - 1] = {
|
7019
|
+
...fixedResponse[fixedResponse.length - 1],
|
7020
|
+
...{
|
7021
|
+
initialName: "Total",
|
7022
|
+
isTotal: true,
|
7023
|
+
},
|
7024
|
+
};
|
7025
|
+
expect(value).toEqual(fixedResponse);
|
7026
|
+
});
|
7027
|
+
|
7028
|
+
it("should not change the original series if the feature flag is off", () => {
|
7029
|
+
additionalOptionsMock = {};
|
7030
|
+
opts = {
|
7031
|
+
total: true,
|
7032
|
+
devFixDrollDownByTotal: false,
|
7033
|
+
};
|
7034
|
+
pivotDataMock.colTotals = {
|
7035
|
+
"col 1": { value: () => 123450 },
|
7036
|
+
"col 2": { value: () => 123451 },
|
7037
|
+
DR_Others: { value: () => 123452 },
|
7038
|
+
};
|
7039
|
+
const value = highchartsRenderer.ptCreateColumnSeries(
|
7040
|
+
pivotDataMock,
|
7041
|
+
colors,
|
7042
|
+
onlyNumbers,
|
7043
|
+
isUniqueVals,
|
7044
|
+
isNotDrillDown,
|
7045
|
+
additionalOptionsMock,
|
7046
|
+
opts,
|
7047
|
+
chartOptions,
|
7048
|
+
chartType
|
7049
|
+
);
|
7050
|
+
expect(value).toEqual(originResponse);
|
7051
|
+
});
|
7052
|
+
});
|
6886
7053
|
});
|
6887
7054
|
describe('Function ptCreateBasicLineSeries', () => {
|
6888
7055
|
const format = null;
|