@datarailsshared/dr_renderer 1.2.398 → 1.2.399
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
@@ -7038,4 +7038,363 @@ describe('highcharts_renderer', () => {
|
|
7038
7038
|
]);
|
7039
7039
|
})
|
7040
7040
|
});
|
7041
|
+
describe('Function ptCreateBasicLineSeries', () => {
|
7042
|
+
const format = null;
|
7043
|
+
let pivotDataMock, additionalOptionsMock, colors, onlyNumbers, isUniqueVals, opts, chartOptions;
|
7044
|
+
beforeEach(() => {
|
7045
|
+
colors = [
|
7046
|
+
"#ff0202",
|
7047
|
+
"#b3060e",
|
7048
|
+
"#70000a"
|
7049
|
+
];
|
7050
|
+
opts = {};
|
7051
|
+
chartOptions = {};
|
7052
|
+
pivotDataMock = {
|
7053
|
+
getAggregator: (rows, cols) => {
|
7054
|
+
let aggregator = highchartsRenderer.rhPivotAggregatorSum([''], format, true, {}, {});
|
7055
|
+
const agg = aggregator({}, '', '');
|
7056
|
+
|
7057
|
+
if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, ['row 1'])) {
|
7058
|
+
agg.sum = 12345;
|
7059
|
+
} else if (lodash.isEqual(cols, ['col 1']) && lodash.isEqual(rows, ['row 2'])) {
|
7060
|
+
agg.sum = 123450;
|
7061
|
+
} else if (lodash.isEqual(cols, ['col 2']) && lodash.isEqual(rows, ['row 1'])) {
|
7062
|
+
agg.sum = 54321;
|
7063
|
+
} else if (lodash.isEqual(cols, ['col 2']) && lodash.isEqual(rows, ['row 2'])) {
|
7064
|
+
agg.sum = 11111;
|
7065
|
+
} else if (lodash.isEqual(cols, [highchartsRenderer.DR_OTHERS_KEY]) && lodash.isEqual(rows, ['row 1'])) {
|
7066
|
+
agg.sum = 99999;
|
7067
|
+
} else if (lodash.isEqual(cols, [highchartsRenderer.DR_OTHERS_KEY]) && lodash.isEqual(rows, ['row 2'])) {
|
7068
|
+
agg.sum = 99991;
|
7069
|
+
}
|
7070
|
+
|
7071
|
+
return agg;
|
7072
|
+
},
|
7073
|
+
getColKeys: () => [['col 1'], ['col 2'], [highchartsRenderer.DR_OTHERS_KEY]],
|
7074
|
+
getRowKeys: () => [['row 1'], ['row 2']],
|
7075
|
+
rowFormats: [],
|
7076
|
+
colFormats: [],
|
7077
|
+
rowAttrs: ['row 1'],
|
7078
|
+
};
|
7079
|
+
});
|
7080
|
+
|
7081
|
+
it('should prepare appropriate chart series, when additional options have delta column \'field\'', ()=> {
|
7082
|
+
additionalOptionsMock = {
|
7083
|
+
delta_column: {
|
7084
|
+
field: 'series',
|
7085
|
+
name: 'row 1',
|
7086
|
+
chart: 'line'
|
7087
|
+
}
|
7088
|
+
};
|
7089
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7090
|
+
expect(value).toEqual([
|
7091
|
+
{
|
7092
|
+
data: [
|
7093
|
+
{
|
7094
|
+
y: 12345,
|
7095
|
+
initialName: 'col 1',
|
7096
|
+
name: 'col 1'
|
7097
|
+
},
|
7098
|
+
{
|
7099
|
+
y: 54321,
|
7100
|
+
initialName: 'col 2',
|
7101
|
+
name: 'col 2'
|
7102
|
+
},
|
7103
|
+
{
|
7104
|
+
y: 99999,
|
7105
|
+
initialName: 'Others',
|
7106
|
+
name: 'Others'
|
7107
|
+
}
|
7108
|
+
],
|
7109
|
+
initialName: 'row 1',
|
7110
|
+
name: 'row 1',
|
7111
|
+
color: '#5ecfb9',
|
7112
|
+
type: 'line',
|
7113
|
+
lineColor: '#5ecfb9',
|
7114
|
+
marker: {
|
7115
|
+
lineColor: '#5ecfb9'
|
7116
|
+
}
|
7117
|
+
},
|
7118
|
+
{
|
7119
|
+
data: [
|
7120
|
+
{
|
7121
|
+
y: 123450,
|
7122
|
+
initialName: 'col 1',
|
7123
|
+
name: 'col 1'
|
7124
|
+
},
|
7125
|
+
{
|
7126
|
+
y: 11111,
|
7127
|
+
initialName: 'col 2',
|
7128
|
+
name: 'col 2'
|
7129
|
+
},
|
7130
|
+
{
|
7131
|
+
y: 99991,
|
7132
|
+
initialName: 'Others',
|
7133
|
+
name: 'Others'
|
7134
|
+
}
|
7135
|
+
],
|
7136
|
+
initialName: 'row 2',
|
7137
|
+
name: 'row 2',
|
7138
|
+
color: '#b3060e'
|
7139
|
+
}
|
7140
|
+
]);
|
7141
|
+
});
|
7142
|
+
|
7143
|
+
it('should prepare appropriate chart series, when additional options have delta column \'only variant\'', ()=> {
|
7144
|
+
additionalOptionsMock = {
|
7145
|
+
delta_column: {
|
7146
|
+
field: 'series',
|
7147
|
+
only_variant: true,
|
7148
|
+
name: 'row 1',
|
7149
|
+
chart: 'line'
|
7150
|
+
}
|
7151
|
+
};
|
7152
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7153
|
+
expect(value).toEqual([{
|
7154
|
+
data: [
|
7155
|
+
{
|
7156
|
+
y: 12345,
|
7157
|
+
initialName: 'col 1',
|
7158
|
+
name: 'col 1'
|
7159
|
+
},
|
7160
|
+
{
|
7161
|
+
y: 54321,
|
7162
|
+
initialName: 'col 2',
|
7163
|
+
name: 'col 2'
|
7164
|
+
},
|
7165
|
+
{
|
7166
|
+
y: 99999,
|
7167
|
+
initialName: 'Others',
|
7168
|
+
name: 'Others'
|
7169
|
+
}
|
7170
|
+
],
|
7171
|
+
initialName: 'row 1',
|
7172
|
+
name: 'row 1',
|
7173
|
+
color: '#5ecfb9',
|
7174
|
+
type: 'line',
|
7175
|
+
lineColor: '#5ecfb9',
|
7176
|
+
marker: {
|
7177
|
+
lineColor: '#5ecfb9'
|
7178
|
+
}
|
7179
|
+
}]);
|
7180
|
+
});
|
7181
|
+
it('should change additional options, when additional options \'chart\' configuration and its option \'showAllLegends\' set to false', ()=> {
|
7182
|
+
additionalOptionsMock = {
|
7183
|
+
chart: {
|
7184
|
+
showAllLegends: false
|
7185
|
+
}
|
7186
|
+
};
|
7187
|
+
highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7188
|
+
expect(additionalOptionsMock.chart.isLimited).toEqual(false);
|
7189
|
+
});
|
7190
|
+
|
7191
|
+
|
7192
|
+
it('should change additional options, when additional options \'chart\' configuration and its option \'showAllLegends\' set to true', ()=> {
|
7193
|
+
additionalOptionsMock = {
|
7194
|
+
chart: {
|
7195
|
+
showAllLegends: true
|
7196
|
+
}
|
7197
|
+
};
|
7198
|
+
highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7199
|
+
expect(additionalOptionsMock.chart.isLimited).toEqual(false);
|
7200
|
+
});
|
7201
|
+
|
7202
|
+
it('should prepare appropriate chart series, when opts \'total\' configuration is set to true', ()=> {
|
7203
|
+
opts = {
|
7204
|
+
total: true
|
7205
|
+
};
|
7206
|
+
pivotDataMock.colTotals = {
|
7207
|
+
'col 1': {value: () => 123450},
|
7208
|
+
'col 2': {value: () => 123451},
|
7209
|
+
'DR_Others': {value: () => 123452},
|
7210
|
+
};
|
7211
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7212
|
+
expect(value).toEqual([
|
7213
|
+
{
|
7214
|
+
data: [
|
7215
|
+
{
|
7216
|
+
y: 12345,
|
7217
|
+
initialName: 'col 1',
|
7218
|
+
name: 'col 1'
|
7219
|
+
},
|
7220
|
+
{
|
7221
|
+
y: 54321,
|
7222
|
+
initialName: 'col 2',
|
7223
|
+
name: 'col 2'
|
7224
|
+
},
|
7225
|
+
{
|
7226
|
+
y: 99999,
|
7227
|
+
initialName: 'Others',
|
7228
|
+
name: 'Others'
|
7229
|
+
}
|
7230
|
+
],
|
7231
|
+
initialName: 'row 1',
|
7232
|
+
name: 'row 1',
|
7233
|
+
color: '#ff0202'
|
7234
|
+
},
|
7235
|
+
{
|
7236
|
+
data: [
|
7237
|
+
{
|
7238
|
+
y: 123450,
|
7239
|
+
initialName: 'col 1',
|
7240
|
+
name: 'col 1'
|
7241
|
+
},
|
7242
|
+
{
|
7243
|
+
y: 11111,
|
7244
|
+
initialName: 'col 2',
|
7245
|
+
name: 'col 2'
|
7246
|
+
},
|
7247
|
+
{
|
7248
|
+
y: 99991,
|
7249
|
+
initialName: 'Others',
|
7250
|
+
name: 'Others'
|
7251
|
+
}
|
7252
|
+
],
|
7253
|
+
initialName: 'row 2',
|
7254
|
+
name: 'row 2',
|
7255
|
+
color: '#b3060e'
|
7256
|
+
},
|
7257
|
+
{
|
7258
|
+
data: [
|
7259
|
+
123450,
|
7260
|
+
123451,
|
7261
|
+
123452
|
7262
|
+
],
|
7263
|
+
initialName: 'row 2',
|
7264
|
+
name: 'Total',
|
7265
|
+
color: '#70000a',
|
7266
|
+
className: 'totalSeries'
|
7267
|
+
}
|
7268
|
+
]);
|
7269
|
+
});
|
7270
|
+
|
7271
|
+
it('should prepare appropriate chart series, when opts \'trendLine\' configuration is set to true', ()=> {
|
7272
|
+
opts = {
|
7273
|
+
trendLine: true
|
7274
|
+
};
|
7275
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7276
|
+
expect(value).toEqual([
|
7277
|
+
{
|
7278
|
+
data: [
|
7279
|
+
{
|
7280
|
+
y: 12345,
|
7281
|
+
initialName: 'col 1',
|
7282
|
+
name: 'col 1'
|
7283
|
+
},
|
7284
|
+
{
|
7285
|
+
y: 54321,
|
7286
|
+
initialName: 'col 2',
|
7287
|
+
name: 'col 2'
|
7288
|
+
},
|
7289
|
+
{
|
7290
|
+
y: 99999,
|
7291
|
+
initialName: 'Others',
|
7292
|
+
name: 'Others'
|
7293
|
+
}
|
7294
|
+
],
|
7295
|
+
initialName: 'row 1',
|
7296
|
+
name: 'row 1',
|
7297
|
+
color: '#ff0202'
|
7298
|
+
},
|
7299
|
+
{
|
7300
|
+
data: [
|
7301
|
+
{
|
7302
|
+
y: 123450,
|
7303
|
+
initialName: 'col 1',
|
7304
|
+
name: 'col 1'
|
7305
|
+
},
|
7306
|
+
{
|
7307
|
+
y: 11111,
|
7308
|
+
initialName: 'col 2',
|
7309
|
+
name: 'col 2'
|
7310
|
+
},
|
7311
|
+
{
|
7312
|
+
y: 99991,
|
7313
|
+
initialName: 'Others',
|
7314
|
+
name: 'Others'
|
7315
|
+
}
|
7316
|
+
],
|
7317
|
+
initialName: 'row 2',
|
7318
|
+
name: 'row 2',
|
7319
|
+
color: '#b3060e'
|
7320
|
+
},
|
7321
|
+
{
|
7322
|
+
data: [
|
7323
|
+
11728,
|
7324
|
+
55555,
|
7325
|
+
99382
|
7326
|
+
],
|
7327
|
+
initialName: 'row 1',
|
7328
|
+
name: 'Trend Line (row 1)',
|
7329
|
+
color: '#ff0202',
|
7330
|
+
className: 'trendSeries',
|
7331
|
+
dashStyle: 'shortdot',
|
7332
|
+
type: 'line'
|
7333
|
+
},
|
7334
|
+
{
|
7335
|
+
data: [
|
7336
|
+
89913.5,
|
7337
|
+
78184,
|
7338
|
+
66454.5
|
7339
|
+
],
|
7340
|
+
initialName: 'row 2',
|
7341
|
+
name: 'Trend Line (row 2)',
|
7342
|
+
color: '#b3060e',
|
7343
|
+
className: 'trendSeries',
|
7344
|
+
dashStyle: 'shortdot',
|
7345
|
+
type: 'line'
|
7346
|
+
}
|
7347
|
+
]);
|
7348
|
+
});
|
7349
|
+
|
7350
|
+
it('should prepare appropriate chart series for standard input', () => {
|
7351
|
+
const value = highchartsRenderer.ptCreateBasicLineSeries(pivotDataMock, colors, onlyNumbers, isUniqueVals, additionalOptionsMock, opts, chartOptions);
|
7352
|
+
expect(value).toEqual([
|
7353
|
+
{
|
7354
|
+
data: [
|
7355
|
+
{
|
7356
|
+
y: 12345,
|
7357
|
+
initialName: 'col 1',
|
7358
|
+
name: 'col 1'
|
7359
|
+
},
|
7360
|
+
{
|
7361
|
+
y: 54321,
|
7362
|
+
initialName: 'col 2',
|
7363
|
+
name: 'col 2'
|
7364
|
+
},
|
7365
|
+
{
|
7366
|
+
y: 99999,
|
7367
|
+
initialName: 'Others',
|
7368
|
+
name: 'Others'
|
7369
|
+
}
|
7370
|
+
],
|
7371
|
+
initialName: 'row 1',
|
7372
|
+
name: 'row 1',
|
7373
|
+
color: '#ff0202'
|
7374
|
+
},
|
7375
|
+
{
|
7376
|
+
data: [
|
7377
|
+
{
|
7378
|
+
y: 123450,
|
7379
|
+
initialName: 'col 1',
|
7380
|
+
name: 'col 1'
|
7381
|
+
},
|
7382
|
+
{
|
7383
|
+
y: 11111,
|
7384
|
+
initialName: 'col 2',
|
7385
|
+
name: 'col 2'
|
7386
|
+
},
|
7387
|
+
{
|
7388
|
+
y: 99991,
|
7389
|
+
initialName: 'Others',
|
7390
|
+
name: 'Others'
|
7391
|
+
}
|
7392
|
+
],
|
7393
|
+
initialName: 'row 2',
|
7394
|
+
name: 'row 2',
|
7395
|
+
color: '#b3060e'
|
7396
|
+
}
|
7397
|
+
]);
|
7398
|
+
})
|
7399
|
+
});
|
7041
7400
|
});
|