@datarailsshared/dr_renderer 1.2.334 → 1.2.335
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
@@ -549,7 +549,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
549
549
|
var func = function () {
|
550
550
|
var value = parseFloat(this.y);
|
551
551
|
if (pivotData) {
|
552
|
-
let series_name = (this
|
552
|
+
let series_name = highchartsRenderer.getSeriesNameInFormatterContext(this);
|
553
553
|
var rows = series_name.split(highchartsRenderer.delimer);
|
554
554
|
|
555
555
|
if (is_drill_down_pie && highchartsRenderer.selfStartsWith(series_name, "Series ")) {
|
@@ -562,7 +562,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
562
562
|
rows = [];
|
563
563
|
}
|
564
564
|
|
565
|
-
var cols =
|
565
|
+
var cols = highchartsRenderer.getColsInFormatterContext(this);
|
566
566
|
if (typeof (cols) == 'object' && cols.name) {
|
567
567
|
cols = cols.name;
|
568
568
|
}
|
@@ -730,7 +730,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
730
730
|
|
731
731
|
var y = parseFloat(this.y);
|
732
732
|
if (pivotData) {
|
733
|
-
let series_name = (this
|
733
|
+
let series_name = highchartsRenderer.getSeriesNameInFormatterContext(this);
|
734
734
|
var rows = series_name.split(highchartsRenderer.delimer);
|
735
735
|
if (is_drill_down_pie && highchartsRenderer.selfStartsWith(series_name,"Series ")) {
|
736
736
|
rows = [];
|
@@ -741,7 +741,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
741
741
|
rows = [];
|
742
742
|
}
|
743
743
|
|
744
|
-
var cols =
|
744
|
+
var cols = highchartsRenderer.getColsInFormatterContext(this);
|
745
745
|
if (!cols && is_drill_down_pie) {
|
746
746
|
cols = this.name;
|
747
747
|
}
|
@@ -768,7 +768,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
768
768
|
? isWaterfallWalkthrough
|
769
769
|
? this.key
|
770
770
|
: cols[0]
|
771
|
-
: cols
|
771
|
+
: highchartsRenderer.isFormattingAxis() && lodash.get(this, 'point.name') || cols
|
772
772
|
);
|
773
773
|
|
774
774
|
highchartsRenderer.replaceDrOthersKeys(cols, rows, drOthersInAxis, othersName);
|
@@ -9379,6 +9379,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9379
9379
|
lodash.set(e, 'point.category.userOptions', e.point.initialName.toString().split(highchartsRenderer.delimer));
|
9380
9380
|
}
|
9381
9381
|
|
9382
|
+
highchartsRenderer.getSeriesNameInFormatterContext = function(context) {
|
9383
|
+
return ((highchartsRenderer.isFormattingAxis() && lodash.get(context, 'series.userOptions.initialName')) || context.series.name || '') + "";
|
9384
|
+
}
|
9385
|
+
|
9386
|
+
highchartsRenderer.getColsInFormatterContext = function(context) {
|
9387
|
+
return lodash.get(context, 'point.options.colsForTotal')
|
9388
|
+
|| highchartsRenderer.isFormattingAxis() && (lodash.get(context, 'point.initialName') || lodash.get(context, 'options.initialName'))
|
9389
|
+
|| context.key;
|
9390
|
+
}
|
9391
|
+
|
9382
9392
|
return highchartsRenderer;
|
9383
9393
|
};
|
9384
9394
|
|
@@ -5183,4 +5183,117 @@ describe('highcharts_renderer', () => {
|
|
5183
5183
|
expect(e.point.category.userOptions).toEqual([event.point.initialName]);
|
5184
5184
|
});
|
5185
5185
|
});
|
5186
|
+
|
5187
|
+
describe('Function getSeriesNameInFormatterContext', () => {
|
5188
|
+
|
5189
|
+
const name1 = 'test series name';
|
5190
|
+
const name2 = 'test series name 2';
|
5191
|
+
|
5192
|
+
it('should return series.userOptions.initialName if it is present and axis formatting is on', () => {
|
5193
|
+
lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
|
5194
|
+
const context = {
|
5195
|
+
series: {
|
5196
|
+
userOptions: {
|
5197
|
+
initialName: name1,
|
5198
|
+
},
|
5199
|
+
name: name2,
|
5200
|
+
}
|
5201
|
+
}
|
5202
|
+
expect(highchartsRenderer.getSeriesNameInFormatterContext(context)).toEqual(name1);
|
5203
|
+
});
|
5204
|
+
|
5205
|
+
it('should return series.name if axis formatting is on but series.userOptions.initialName is not present', () => {
|
5206
|
+
lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
|
5207
|
+
const context = {
|
5208
|
+
series: {
|
5209
|
+
name: name2,
|
5210
|
+
}
|
5211
|
+
}
|
5212
|
+
expect(highchartsRenderer.getSeriesNameInFormatterContext(context)).toEqual(name2);
|
5213
|
+
});
|
5214
|
+
|
5215
|
+
it('should return series.name if series.userOptions.initialName is present but axis formatting is off', () => {
|
5216
|
+
lodash.set(document, 'ReportHippo.user.features', []);
|
5217
|
+
const context = {
|
5218
|
+
series: {
|
5219
|
+
userOptions: {
|
5220
|
+
initialName: name1,
|
5221
|
+
},
|
5222
|
+
name: name2,
|
5223
|
+
}
|
5224
|
+
}
|
5225
|
+
expect(highchartsRenderer.getSeriesNameInFormatterContext(context)).toEqual(name2);
|
5226
|
+
});
|
5227
|
+
});
|
5228
|
+
|
5229
|
+
describe('Function getColsInFormatterContext', () => {
|
5230
|
+
|
5231
|
+
const name1 = 'test series name 1';
|
5232
|
+
const name2 = 'test series name 2';
|
5233
|
+
const name3 = 'test series name 3';
|
5234
|
+
|
5235
|
+
it('should return point.options.colsForTotal if it is present', () => {
|
5236
|
+
const context = {
|
5237
|
+
point: {
|
5238
|
+
initialName: name1,
|
5239
|
+
options: {
|
5240
|
+
colsForTotal: name3
|
5241
|
+
}
|
5242
|
+
},
|
5243
|
+
key: name2,
|
5244
|
+
}
|
5245
|
+
|
5246
|
+
lodash.forEach(['use_default_table_format_for_axis'], [], features => {
|
5247
|
+
lodash.set(document, 'ReportHippo.user.features', features);
|
5248
|
+
expect(highchartsRenderer.getColsInFormatterContext(context)).toEqual(name3);
|
5249
|
+
});
|
5250
|
+
});
|
5251
|
+
|
5252
|
+
it('should return point.initialName if it is present and FF is on and colsForTotal is not present', () => {
|
5253
|
+
lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
|
5254
|
+
const context = {
|
5255
|
+
point: {
|
5256
|
+
initialName: name1,
|
5257
|
+
},
|
5258
|
+
options: {
|
5259
|
+
initialName: name3,
|
5260
|
+
},
|
5261
|
+
key: name2,
|
5262
|
+
}
|
5263
|
+
expect(highchartsRenderer.getColsInFormatterContext(context)).toEqual(name1);
|
5264
|
+
});
|
5265
|
+
|
5266
|
+
it('should return context.key if FF is off and colsForTotal is not present', () => {
|
5267
|
+
lodash.set(document, 'ReportHippo.user.features', []);
|
5268
|
+
const context = {
|
5269
|
+
point: {
|
5270
|
+
initialName: name1,
|
5271
|
+
},
|
5272
|
+
options: {
|
5273
|
+
initialName: name3,
|
5274
|
+
},
|
5275
|
+
key: name2,
|
5276
|
+
}
|
5277
|
+
expect(highchartsRenderer.getColsInFormatterContext(context)).toEqual(name2);
|
5278
|
+
});
|
5279
|
+
|
5280
|
+
it('should return options.initialName if FF is on, colsForTotal is not present and point.initialName is not present', () => {
|
5281
|
+
lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
|
5282
|
+
const context = {
|
5283
|
+
options: {
|
5284
|
+
initialName: name3,
|
5285
|
+
},
|
5286
|
+
key: name2,
|
5287
|
+
}
|
5288
|
+
expect(highchartsRenderer.getColsInFormatterContext(context)).toEqual(name3);
|
5289
|
+
});
|
5290
|
+
|
5291
|
+
it('should return context.key if FF is on, no colsForTotal a, no point.initialName no options.initialName', () => {
|
5292
|
+
lodash.set(document, 'ReportHippo.user.features', ['use_default_table_format_for_axis']);
|
5293
|
+
const context = {
|
5294
|
+
key: name2,
|
5295
|
+
}
|
5296
|
+
expect(highchartsRenderer.getColsInFormatterContext(context)).toEqual(name2);
|
5297
|
+
});
|
5298
|
+
});
|
5186
5299
|
});
|