@datarailsshared/dr_renderer 1.5.159 → 1.5.168

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.
Files changed (32) hide show
  1. package/.idea/jsLibraryMappings.xml +6 -0
  2. package/.idea/misc.xml +9 -0
  3. package/.nvmrc +1 -0
  4. package/jest.config.js +1 -1
  5. package/package.json +9 -11
  6. package/scripts/check-versions.js +16 -0
  7. package/src/highcharts_renderer.d.ts +2 -2
  8. package/tsconfig.json +1 -1
  9. package/.circleci/config.yml +0 -85
  10. package/.github/workflows/ai-coder-jira.yml +0 -915
  11. package/.github/workflows/ai-coder-n8n-caller.yml +0 -82
  12. package/.github/workflows/release.yml +0 -49
  13. package/tests/__snapshots__/suboptions.test.js.snap +0 -5028
  14. package/tests/dr-renderer-helpers.test.js +0 -228
  15. package/tests/dr_chart_tooltip.test.js +0 -789
  16. package/tests/dr_gauge_chart.test.js +0 -2041
  17. package/tests/errors.test.js +0 -157
  18. package/tests/highcharts_renderer.test.js +0 -9407
  19. package/tests/mock/add-in-dynamic-ranges.json +0 -127
  20. package/tests/mock/add-in-functions.json +0 -410
  21. package/tests/mock/add-in-tables.json +0 -347
  22. package/tests/mock/tables.json +0 -2258
  23. package/tests/mock/widgets.json +0 -401
  24. package/tests/options-builder.test.js +0 -1698
  25. package/tests/pivot-table/freeze-panes/constants.test.js +0 -92
  26. package/tests/pivot-table/freeze-panes/index.test.js +0 -193
  27. package/tests/pivot-table/freeze-panes/sticky-strategy.test.js +0 -542
  28. package/tests/pivot-table/freeze-panes/transform-strategy.test.js +0 -304
  29. package/tests/ptCreateDrillDownSeriesToDrilldownChart.test.js +0 -509
  30. package/tests/seriesPointStyles-helper.test.js +0 -114
  31. package/tests/suboptions.test.js +0 -322
  32. package/tests/value.formatter.test.js +0 -143
@@ -1,509 +0,0 @@
1
- import * as JQuery from "jquery";
2
- import * as lodash from 'lodash';
3
- import moment from 'moment/min/moment.min';
4
- import initDRPivotTable from "../src/dr_pivottable";
5
-
6
- const getHighchartsRenderer = require('../src/highcharts_renderer');
7
- const DataFormatter = require('../src/dataformatter');
8
-
9
- global.$ = JQuery;
10
- global.lodash = lodash;
11
-
12
- const Highcharts = {
13
- Color: jest.fn(),
14
- chart: jest.fn(),
15
- setOptions: jest.fn(),
16
- wrap: jest.fn(),
17
- Tooltip: {
18
- prototype: {
19
- hide: jest.fn()
20
- }
21
- },
22
- Point: {
23
- prototype: {
24
- setState: jest.fn()
25
- }
26
- },
27
- Series: {
28
- prototype: {
29
- setState: jest.fn()
30
- }
31
- },
32
- defaultOptions: {
33
- global: {
34
- useUTC: false
35
- }
36
- },
37
- merge: jest.fn((target, source) => Object.assign({}, target, source))
38
- };
39
-
40
- const _document = {
41
- createElement: jest.fn(() => ({
42
- style: {},
43
- setAttribute: jest.fn(),
44
- appendChild: jest.fn()
45
- })),
46
- body: {
47
- appendChild: jest.fn()
48
- }
49
- };
50
-
51
- function createMockAggregator(value) {
52
- return {
53
- value: () => value
54
- };
55
- }
56
-
57
-
58
- let highchartsRenderer = {};
59
-
60
- describe('ptCreateDrillDownSeriesToDrilldownChart', () => {
61
- let mockPivotData;
62
- let mockChartOptions;
63
- let mockAdditionOptions;
64
- let mockOpts;
65
-
66
- beforeAll(() => {
67
- const _window = {
68
- DataFormatter: DataFormatter
69
- };
70
-
71
- initDRPivotTable(JQuery, _window, _document);
72
-
73
- const DEFAULT_USER_COLORS = ['#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1'];
74
- highchartsRenderer = getHighchartsRenderer(JQuery, _document, Highcharts, lodash.cloneDeep(DEFAULT_USER_COLORS), highchartsRenderer, DataFormatter, lodash, moment, false);
75
- });
76
-
77
- beforeEach(() => {
78
- const createMockAggregator = (value) => ({
79
- value: () => value
80
- });
81
-
82
- mockPivotData = {
83
- getRowKeys: jest.fn(() => [
84
- ['CITY SERVICE DEPTS'],
85
- ['MID-SOUTH'],
86
- ['NORTH TX'],
87
- ['SOUTH TX'],
88
- ['VIRGINIA'],
89
- ['CAROLINA']
90
- ]),
91
- getColKeys: jest.fn(() => [
92
- ['003-NATIONAL ACCOUNTS'],
93
- ['015-MEMPHIS'],
94
- ['016-WICHITA FALLS'],
95
- ['017-AMARILLO'],
96
- ['019-AUSTIN'],
97
- ['020-NORFOLK'],
98
- ['023-NEWPORT NEWS'],
99
- ['035-CHARLOTTE CITY SERVICE']
100
- ]),
101
- getAggregator: jest.fn((rowKey, colKey) => {
102
- const rowStr = Array.isArray(rowKey) ? rowKey[0] : rowKey;
103
- const colStr = Array.isArray(colKey) ? colKey[0] : colKey;
104
-
105
- const dataMap = {
106
- 'CITY SERVICE DEPTS,003-NATIONAL ACCOUNTS': 305550.96,
107
- 'MID-SOUTH,015-MEMPHIS': 78827.94,
108
- 'NORTH TX,016-WICHITA FALLS': 28926.52,
109
- 'NORTH TX,017-AMARILLO': 92653.77,
110
- 'SOUTH TX,019-AUSTIN': 103645.51,
111
- 'VIRGINIA,020-NORFOLK': 0,
112
- 'VIRGINIA,023-NEWPORT NEWS': 19997.5,
113
- 'CAROLINA,035-CHARLOTTE CITY SERVICE': 124248.97
114
- };
115
-
116
- const key = `${rowStr},${colStr}`;
117
- const value = dataMap[key] || null;
118
-
119
- return createMockAggregator(value);
120
- }),
121
- colFormats: [
122
- {
123
- type: "Text",
124
- name: "Br number & Name",
125
- format: null,
126
- val_not_convert: []
127
- }
128
- ],
129
- rowFormats: [
130
- {
131
- type: "Text",
132
- name: "Area",
133
- format: null,
134
- val_not_convert: []
135
- }
136
- ]
137
- };
138
-
139
- mockChartOptions = {
140
- chart: {
141
- type: 'pie'
142
- }
143
- };
144
-
145
- mockAdditionOptions = {
146
- dataLabels: {
147
- color: '#151a41'
148
- }
149
- };
150
-
151
- mockOpts = {
152
- total_value_options: {
153
- filter_options: {
154
- filteredOutFieldName: 'Others'
155
- }
156
- }
157
- };
158
-
159
- jest.spyOn(highchartsRenderer, 'getFormattedColKey').mockImplementation((name) => name);
160
- jest.spyOn(highchartsRenderer, 'getFormattedRowKey').mockImplementation((name) => Array.isArray(name) ? name : [name]);
161
- jest.spyOn(highchartsRenderer, 'moveSeriesToSecondYAxisIfNeeded').mockImplementation(() => {});
162
- jest.spyOn(highchartsRenderer, 'getDataLabelsStylesForDrillDown').mockReturnValue({
163
- activeDataLabelStyle: {
164
- color: '#151a41'
165
- }
166
- });
167
- });
168
-
169
- afterEach(() => {
170
- jest.restoreAllMocks();
171
- });
172
-
173
- describe('with valid pivot data', () => {
174
- it('should create drill-down series correctly', () => {
175
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
176
- mockPivotData,
177
- mockChartOptions,
178
- mockAdditionOptions,
179
- mockOpts
180
- );
181
-
182
- // Verify the structure of the result
183
- expect(result).toHaveProperty('activeDataLabelStyle');
184
- expect(result).toHaveProperty('series');
185
- expect(result.activeDataLabelStyle).toEqual({
186
- color: '#151a41'
187
- });
188
-
189
- // Verify series structure
190
- expect(Array.isArray(result.series)).toBe(true);
191
- expect(result.series.length).toBe(7);
192
-
193
- // Check first series (003-NATIONAL ACCOUNTS)
194
- const firstSeries = result.series[0];
195
- expect(firstSeries).toMatchObject({
196
- id: '003-NATIONAL ACCOUNTS',
197
- initialName: '003-NATIONAL ACCOUNTS',
198
- name: '003-NATIONAL ACCOUNTS',
199
- data: expect.any(Array)
200
- });
201
-
202
- // Verify data points in first series
203
- expect(firstSeries.data).toHaveLength(1);
204
- expect(firstSeries.data[0]).toMatchObject({
205
- name: ['CITY SERVICE DEPTS'],
206
- initialName: ['CITY SERVICE DEPTS'],
207
- y: 305550.96
208
- });
209
- });
210
-
211
- it('should handle numeric column IDs correctly', () => {
212
- // Test with numeric column keys
213
- mockPivotData.getColKeys.mockReturnValue([
214
- [123],
215
- [456]
216
- ]);
217
-
218
- mockPivotData.getAggregator.mockImplementation(() => createMockAggregator(100));
219
-
220
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
221
- mockPivotData,
222
- mockChartOptions,
223
- mockAdditionOptions,
224
- mockOpts
225
- );
226
-
227
- expect(result.series[0].id).toBe(123);
228
- expect(result.series[1].id).toBe(456);
229
- });
230
-
231
- it('should handle boolean column IDs correctly', () => {
232
- // Test with boolean column keys
233
- mockPivotData.getColKeys.mockReturnValue([
234
- [true],
235
- [false]
236
- ]);
237
-
238
- mockPivotData.getAggregator.mockImplementation(() => createMockAggregator(100));
239
-
240
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
241
- mockPivotData,
242
- mockChartOptions,
243
- mockAdditionOptions,
244
- mockOpts
245
- );
246
-
247
- expect(result.series[0].id).toBe('true');
248
- expect(result.series[1].id).toBe('false');
249
- });
250
-
251
- it('should filter out null values', () => {
252
- mockPivotData.getAggregator.mockImplementation((rowKey, colKey) => {
253
- const rowStr = Array.isArray(rowKey) ? rowKey[0] : rowKey;
254
- const colStr = Array.isArray(colKey) ? colKey[0] : colKey;
255
-
256
- // Return null for specific combinations
257
- if (rowStr === 'CITY SERVICE DEPTS' && colStr === '015-MEMPHIS') {
258
- return { value: () => null };
259
- }
260
-
261
- return { value: () => 100 };
262
- });
263
-
264
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
265
- mockPivotData,
266
- mockChartOptions,
267
- mockAdditionOptions,
268
- mockOpts
269
- );
270
-
271
- // Find the series for '015-MEMPHIS'
272
- const memphisSeries = result.series.find(s => s.id === '015-MEMPHIS');
273
-
274
- // Should not include data point with null value
275
- expect(memphisSeries.data).not.toContainEqual(
276
- expect.objectContaining({
277
- name: ['CITY SERVICE DEPTS']
278
- })
279
- );
280
- });
281
-
282
- it('should handle undefined column keys', () => {
283
- mockPivotData.getColKeys.mockReturnValue([
284
- [undefined],
285
- ['valid-key']
286
- ]);
287
-
288
- mockPivotData.getAggregator.mockImplementation((rowKey, colKey) => {
289
- return { value: () => 100 }; // Return valid value for all combinations
290
- });
291
-
292
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
293
- mockPivotData,
294
- mockChartOptions,
295
- mockAdditionOptions,
296
- mockOpts
297
- );
298
-
299
- // Should only process series with defined column keys (undefined keys are filtered out)
300
- expect(result.series).toHaveLength(1);
301
- expect(result.series[0].id).toBe('valid-key');
302
- });
303
-
304
- it('should handle empty row keys', () => {
305
- mockPivotData.getRowKeys.mockReturnValue([
306
- [null],
307
- [''],
308
- ['valid-row']
309
- ]);
310
-
311
- mockPivotData.getAggregator.mockImplementation((rowKey) => {
312
- const rowStr = Array.isArray(rowKey) ? rowKey[0] : rowKey;
313
- if (!rowStr) {
314
- return { value: () => 100 };
315
- }
316
- return { value: () => 200 };
317
- });
318
-
319
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
320
- mockPivotData,
321
- mockChartOptions,
322
- mockAdditionOptions,
323
- mockOpts
324
- );
325
-
326
- // Should filter out data points with null/empty row keys
327
- result.series.forEach(series => {
328
- series.data.forEach(dataPoint => {
329
- expect(dataPoint.name[0]).toBeTruthy();
330
- });
331
- });
332
- });
333
-
334
- it('should convert string numbers to float', () => {
335
- mockPivotData.getAggregator.mockImplementation(() => ({
336
- value: () => '123.45' // Return string number
337
- }));
338
-
339
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
340
- mockPivotData,
341
- mockChartOptions,
342
- mockAdditionOptions,
343
- mockOpts
344
- );
345
-
346
- result.series.forEach(series => {
347
- series.data.forEach(dataPoint => {
348
- expect(typeof dataPoint.y).toBe('number');
349
- expect(dataPoint.y).toBe(123.45);
350
- });
351
- });
352
- });
353
-
354
- it('should remove duplicate data points', () => {
355
- // Mock duplicate row keys
356
- mockPivotData.getRowKeys.mockReturnValue([
357
- ['DUPLICATE'],
358
- ['DUPLICATE'],
359
- ['UNIQUE']
360
- ]);
361
-
362
- mockPivotData.getAggregator.mockImplementation(() => ({
363
- value: () => 100
364
- }));
365
-
366
- // Mock getFormattedRowKey to return same name for duplicates
367
- jest.spyOn(highchartsRenderer, 'getFormattedRowKey').mockImplementation((name) => {
368
- if (Array.isArray(name) && name[0] === 'DUPLICATE') {
369
- return ['DUPLICATE'];
370
- }
371
- return Array.isArray(name) ? name : [name];
372
- });
373
-
374
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
375
- mockPivotData,
376
- mockChartOptions,
377
- mockAdditionOptions,
378
- mockOpts
379
- );
380
-
381
- // Each series should have unique data points
382
- result.series.forEach(series => {
383
- const names = series.data.map(d => d.name.join(','));
384
- const uniqueNames = [...new Set(names)];
385
- expect(names.length).toBe(uniqueNames.length);
386
- });
387
- });
388
-
389
- it('should call helper functions with correct parameters', () => {
390
- highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
391
- mockPivotData,
392
- mockChartOptions,
393
- mockAdditionOptions,
394
- mockOpts
395
- );
396
-
397
- expect(highchartsRenderer.moveSeriesToSecondYAxisIfNeeded).toHaveBeenCalledWith(
398
- expect.any(Array),
399
- mockPivotData,
400
- mockChartOptions,
401
- mockAdditionOptions,
402
- mockOpts
403
- );
404
- expect(highchartsRenderer.getDataLabelsStylesForDrillDown).toHaveBeenCalledWith(mockAdditionOptions);
405
- });
406
-
407
- it('should merge values when row name is a plain string (not array)', () => {
408
- jest.spyOn(highchartsRenderer, 'getFormattedRowKey').mockImplementation(name => name);
409
-
410
- mockPivotData.getRowKeys.mockReturnValue([ 'PLAIN_STRING_NAME' ]);
411
- mockPivotData.getColKeys.mockReturnValue([ ['valid-key'] ]);
412
- mockPivotData.getAggregator.mockImplementation(() => ({ value: () => 100 }));
413
-
414
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
415
- mockPivotData,
416
- mockChartOptions,
417
- mockAdditionOptions,
418
- mockOpts
419
- );
420
-
421
- expect(result.series).toHaveLength(1);
422
- const dataPoint = result.series[0].data[0];
423
- expect(dataPoint.name).toEqual(['PLAIN_STRING_NAME']);
424
- expect(dataPoint.y).toBe(100);
425
- });
426
- });
427
-
428
- describe('edge cases', () => {
429
- it('should handle empty column keys', () => {
430
- mockPivotData.getColKeys.mockReturnValue([]);
431
-
432
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
433
- mockPivotData,
434
- mockChartOptions,
435
- mockAdditionOptions,
436
- mockOpts
437
- );
438
-
439
- expect(result.series).toHaveLength(0);
440
- });
441
-
442
- it('should handle empty row keys', () => {
443
- mockPivotData.getRowKeys.mockReturnValue([]);
444
-
445
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
446
- mockPivotData,
447
- mockChartOptions,
448
- mockAdditionOptions,
449
- mockOpts
450
- );
451
-
452
- // Series should exist but have no data
453
- result.series.forEach(series => {
454
- expect(series.data).toHaveLength(0);
455
- });
456
- });
457
-
458
- it('should filter out series with no data', () => {
459
- // Mock aggregator to return null for all combinations
460
- mockPivotData.getAggregator.mockImplementation(() => ({
461
- value: () => null
462
- }));
463
-
464
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
465
- mockPivotData,
466
- mockChartOptions,
467
- mockAdditionOptions,
468
- mockOpts
469
- );
470
-
471
- expect(result.series).toHaveLength(0);
472
- });
473
- });
474
-
475
- describe('with Others key handling', () => {
476
- it('should replace DR_OTHERS_KEY with othersName', () => {
477
- // Mock DR_OTHERS_KEY constant
478
- highchartsRenderer.DR_OTHERS_KEY = 'DR_OTHERS_KEY';
479
-
480
- mockPivotData.getColKeys.mockReturnValue([
481
- ['DR_OTHERS_KEY'],
482
- ['normal-key']
483
- ]);
484
-
485
- mockPivotData.getRowKeys.mockReturnValue([
486
- ['DR_OTHERS_KEY'],
487
- ['normal-row']
488
- ]);
489
-
490
- // Mock aggregator to return valid data
491
- mockPivotData.getAggregator.mockImplementation((rowKey, colKey) => {
492
- return { value: () => 100 }; // Return valid value for all combinations
493
- });
494
-
495
- const result = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
496
- mockPivotData,
497
- mockChartOptions,
498
- mockAdditionOptions,
499
- mockOpts
500
- );
501
-
502
- // Check that DR_OTHERS_KEY is replaced with Others name
503
- const othersColSeries = result.series.find(s => s.initialName === 'Others');
504
- expect(othersColSeries).toBeDefined();
505
- expect(othersColSeries.name).toBe('Others');
506
- });
507
- });
508
- });
509
-
@@ -1,114 +0,0 @@
1
- import seriesPointStylesHelper from '../src/seriesPointStyles-helper';
2
-
3
- describe('setSeriesPointStylesOnClick', () => {
4
- it('should update point styles on click and update other points to non-selected styles on click', () => {
5
- const selectedPoint = {
6
- update: jest.fn(),
7
- series: {
8
- chart: {
9
- series: [{ points: [] }],
10
- redraw: jest.fn()
11
- }
12
- }
13
- };
14
-
15
- const otherPoint = {
16
- update: jest.fn(),
17
- series: selectedPoint.series
18
- };
19
-
20
- selectedPoint.series.chart.series[0].points.push(selectedPoint, otherPoint);
21
-
22
- const mockEvent = { point: selectedPoint };
23
-
24
- seriesPointStylesHelper.setSeriesPointStylesOnClick(mockEvent);
25
-
26
- expect(selectedPoint.update).toHaveBeenCalledWith(
27
- {
28
- opacity: 1,
29
- marker: {
30
- enabled: true,
31
- radius: 8
32
- },
33
- dataLabels: {
34
- style: {
35
- fontWeight: 'bold'
36
- }
37
- }
38
- },
39
- false
40
- );
41
- expect(otherPoint.update).toHaveBeenCalledWith(
42
- {
43
- opacity: 0.1,
44
- marker: {
45
- enabled: true,
46
- radius: 3
47
- },
48
- dataLabels: {
49
- style: {
50
- fontWeight: 'normal'
51
- }
52
- }
53
- },
54
- false
55
- );
56
- expect(selectedPoint.series.chart.redraw).toHaveBeenCalled();
57
- });
58
- });
59
-
60
- describe('setInitialPointStyles', () => {
61
- it('should set initial point styles based on selection', () => {
62
- const opts = { selectedPoint: { initialName: 'point1', y: 10 } };
63
- const mockPoint = { initialName: 'point1', y: 10 };
64
- const mockSeries = { data: [mockPoint] };
65
- const series = [mockSeries];
66
-
67
- seriesPointStylesHelper.setInitialPointStyles(opts, series);
68
-
69
- expect(mockPoint).toEqual(
70
- Object.assign(
71
- mockPoint,
72
- {
73
- opacity: 1,
74
- marker: {
75
- enabled: true,
76
- radius: 8
77
- },
78
- dataLabels: {
79
- style: {
80
- fontWeight: 'bold'
81
- }
82
- }
83
- }
84
- )
85
- );
86
- });
87
-
88
- it('should not set styles if point is not selected', () => {
89
- const opts = { selectedPoint: { initialName: 'point1', y: 10 } };
90
- const mockPoint = { initialName: 'point2', y: 20 };
91
- const mockSeries = { data: [mockPoint] };
92
- const series = [mockSeries];
93
-
94
- seriesPointStylesHelper.setInitialPointStyles(opts, series);
95
-
96
- expect(mockPoint).toEqual(
97
- Object.assign(
98
- mockPoint,
99
- {
100
- opacity: 0.1,
101
- marker: {
102
- enabled: true,
103
- radius: 3
104
- },
105
- dataLabels: {
106
- style: {
107
- fontWeight: 'normal'
108
- }
109
- }
110
- }
111
- )
112
- );
113
- });
114
- });