@datarailsshared/dr_renderer 1.2.48 → 1.2.49-beta
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/.circleci/config.yml +41 -41
- package/README.md +18 -18
- package/package.json +28 -28
- package/src/dataformatter.js +1026 -1026
- package/src/dr_pivottable.js +2360 -2293
- package/src/highcharts_renderer.js +7498 -7021
- package/src/index.js +27 -27
- package/src/novix_renderer.js +901 -901
- package/src/pivot.css +404 -404
- package/src/pivottable.js +1870 -1824
- package/src/published_items_renderer.js +306 -308
- package/start_run.sh +3 -3
package/src/dr_pivottable.js
CHANGED
|
@@ -1,2293 +1,2360 @@
|
|
|
1
|
-
let initDRPivotTable = function($, window, document) {
|
|
2
|
-
var hasProp = {}.hasOwnProperty;
|
|
3
|
-
var slice = [].slice;
|
|
4
|
-
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
|
5
|
-
|
|
6
|
-
var DRPivotData, sortDateStrings, getSort, processKey, SubtotalRenderer, getFormattedNumber, largeToSmallSort, NovixRenderer;
|
|
7
|
-
|
|
8
|
-
var delim = " , ";
|
|
9
|
-
const newTableColors = ['rgb(127, 196, 255)', 'rgb(200, 243,243)', 'rgb(247, 161, 173)', 'rgb(255, 237, 178)', 'rgb(221, 239, 255)',
|
|
10
|
-
'rgb(171, 216, 255)', 'rgb(174, 231, 220)', 'rgb(227, 255, 236)', 'rgb(162, 215, 227)', 'rgb(223, 239, 236)'];
|
|
11
|
-
const useNewUx = document.ReportHippo && document.ReportHippo && document.ReportHippo.user &&
|
|
12
|
-
document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.use_new_ux;
|
|
13
|
-
// const numberOfRows = 500; // change to activate the handsontable when num of rows bigger then this.
|
|
14
|
-
|
|
15
|
-
DRPivotData = (function(superClass) {
|
|
16
|
-
extend(DRPivotData, superClass);
|
|
17
|
-
|
|
18
|
-
function DRPivotData(input, opts) {
|
|
19
|
-
DRPivotData.__super__.constructor.call(this, input, opts);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getSort = function(sorters, attr) {
|
|
23
|
-
var sort;
|
|
24
|
-
sort = sorters(attr);
|
|
25
|
-
if ($.isFunction(sort)) {
|
|
26
|
-
return sort;
|
|
27
|
-
} else {
|
|
28
|
-
return $.pivotUtilities.naturalSort;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
DRPivotData.prototype.forEachRecord = function(input, derivedAttributes, f) {
|
|
33
|
-
var addRecord, compactRecord, i, j, k, l, len1, record, ref, results, results1, tblCols;
|
|
34
|
-
if ($.isEmptyObject(derivedAttributes)) {
|
|
35
|
-
addRecord = f;
|
|
36
|
-
} else {
|
|
37
|
-
addRecord = function(record) {
|
|
38
|
-
var k, ref, v;
|
|
39
|
-
for (k in derivedAttributes) {
|
|
40
|
-
v = derivedAttributes[k];
|
|
41
|
-
record[k] = (ref = v(record)) != null ? ref : record[k];
|
|
42
|
-
}
|
|
43
|
-
return f(record);
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if ($.isFunction(input)) {
|
|
47
|
-
return input(addRecord);
|
|
48
|
-
} else if ($.isArray(input)) {
|
|
49
|
-
if ($.isArray(input[0])) {
|
|
50
|
-
results = [];
|
|
51
|
-
for (i in input) {
|
|
52
|
-
if (!hasProp.call(input, i)) continue;
|
|
53
|
-
compactRecord = input[i];
|
|
54
|
-
if (!(i > 0)) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
record = {};
|
|
58
|
-
ref = input[0];
|
|
59
|
-
for (j in ref) {
|
|
60
|
-
if (!hasProp.call(ref, j)) continue;
|
|
61
|
-
k = ref[j];
|
|
62
|
-
record[k] = compactRecord[j];
|
|
63
|
-
}
|
|
64
|
-
results.push(addRecord(record));
|
|
65
|
-
}
|
|
66
|
-
return results;
|
|
67
|
-
} else {
|
|
68
|
-
results1 = [];
|
|
69
|
-
for (l = 0, len1 = input.length; l < len1; l++) {
|
|
70
|
-
record = input[l];
|
|
71
|
-
results1.push(addRecord(record));
|
|
72
|
-
}
|
|
73
|
-
return results1;
|
|
74
|
-
}
|
|
75
|
-
} else if (input instanceof jQuery) {
|
|
76
|
-
tblCols = [];
|
|
77
|
-
$("thead > tr > th", input).each(function(i) {
|
|
78
|
-
return tblCols.push($(this).text());
|
|
79
|
-
});
|
|
80
|
-
return $("tbody > tr", input).each(function(i) {
|
|
81
|
-
record = {};
|
|
82
|
-
$("td", this).each(function(j) {
|
|
83
|
-
return record[tblCols[j]] = $(this).html();
|
|
84
|
-
});
|
|
85
|
-
return addRecord(record);
|
|
86
|
-
});
|
|
87
|
-
} else {
|
|
88
|
-
throw new Error("unknown input format");
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
DRPivotData.prototype.arrSort = function(attrs) {
|
|
93
|
-
var a, sortersArr;
|
|
94
|
-
sortersArr = (function() {
|
|
95
|
-
var l, len1, results;
|
|
96
|
-
results = [];
|
|
97
|
-
for (l = 0, len1 = attrs.length; l < len1; l++) {
|
|
98
|
-
a = attrs[l];
|
|
99
|
-
results.push(getSort(this.sorters, a));
|
|
100
|
-
}
|
|
101
|
-
return results;
|
|
102
|
-
}).call(this);
|
|
103
|
-
return function(a, b) {
|
|
104
|
-
var comparison, i, sorter;
|
|
105
|
-
for (i in sortersArr) {
|
|
106
|
-
sorter = sortersArr[i];
|
|
107
|
-
comparison = sorter(a[i], b[i]);
|
|
108
|
-
if (comparison !== 0) {
|
|
109
|
-
return comparison;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return 0;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
processKey = function(record, totals, keys, attrs, getAggregator) {
|
|
117
|
-
var addKey, attr, flatKey, k, key, len, ref;
|
|
118
|
-
key = [];
|
|
119
|
-
addKey = false;
|
|
120
|
-
for (k = 0, len = attrs.length; k < len; k++) {
|
|
121
|
-
attr = attrs[k];
|
|
122
|
-
key.push((ref = record[attr]) != null ? ref : "null");
|
|
123
|
-
flatKey = key.join(delim);
|
|
124
|
-
if (!totals[flatKey]) {
|
|
125
|
-
totals[flatKey] = getAggregator(key.slice());
|
|
126
|
-
addKey = true;
|
|
127
|
-
}
|
|
128
|
-
totals[flatKey].push(record);
|
|
129
|
-
}
|
|
130
|
-
if (addKey) {
|
|
131
|
-
keys.push(key);
|
|
132
|
-
}
|
|
133
|
-
return key;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
var
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
if(opts
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
if(opts.chartOptions.table_options.colorize_headers == true
|
|
584
|
-
element.
|
|
585
|
-
}
|
|
586
|
-
};
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
if (
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
"
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
if (
|
|
976
|
-
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
if (
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
tr.appendChild(th);
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
"
|
|
1340
|
-
"
|
|
1341
|
-
"
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
tr
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
};
|
|
1437
|
-
|
|
1438
|
-
$(
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
h.th.
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
h.
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
}
|
|
1709
|
-
h.th.
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
}
|
|
1725
|
-
h.
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
if (
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
}
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
}
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
replaceClass(
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
}
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
}
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
}
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
}
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
// Add row
|
|
2274
|
-
matrix.push(
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
1
|
+
let initDRPivotTable = function($, window, document) {
|
|
2
|
+
var hasProp = {}.hasOwnProperty;
|
|
3
|
+
var slice = [].slice;
|
|
4
|
+
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
|
5
|
+
|
|
6
|
+
var DRPivotData, sortDateStrings, getSort, processKey, SubtotalRenderer, getFormattedNumber, largeToSmallSort, largeToSmallSortByAbsolute, NovixRenderer;
|
|
7
|
+
|
|
8
|
+
var delim = " , ";
|
|
9
|
+
const newTableColors = ['rgb(127, 196, 255)', 'rgb(200, 243,243)', 'rgb(247, 161, 173)', 'rgb(255, 237, 178)', 'rgb(221, 239, 255)',
|
|
10
|
+
'rgb(171, 216, 255)', 'rgb(174, 231, 220)', 'rgb(227, 255, 236)', 'rgb(162, 215, 227)', 'rgb(223, 239, 236)'];
|
|
11
|
+
const useNewUx = document.ReportHippo && document.ReportHippo && document.ReportHippo.user &&
|
|
12
|
+
document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.use_new_ux;
|
|
13
|
+
// const numberOfRows = 500; // change to activate the handsontable when num of rows bigger then this.
|
|
14
|
+
|
|
15
|
+
DRPivotData = (function(superClass) {
|
|
16
|
+
extend(DRPivotData, superClass);
|
|
17
|
+
|
|
18
|
+
function DRPivotData(input, opts) {
|
|
19
|
+
DRPivotData.__super__.constructor.call(this, input, opts);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getSort = function(sorters, attr) {
|
|
23
|
+
var sort;
|
|
24
|
+
sort = sorters(attr);
|
|
25
|
+
if ($.isFunction(sort)) {
|
|
26
|
+
return sort;
|
|
27
|
+
} else {
|
|
28
|
+
return $.pivotUtilities.naturalSort;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
DRPivotData.prototype.forEachRecord = function(input, derivedAttributes, f) {
|
|
33
|
+
var addRecord, compactRecord, i, j, k, l, len1, record, ref, results, results1, tblCols;
|
|
34
|
+
if ($.isEmptyObject(derivedAttributes)) {
|
|
35
|
+
addRecord = f;
|
|
36
|
+
} else {
|
|
37
|
+
addRecord = function(record) {
|
|
38
|
+
var k, ref, v;
|
|
39
|
+
for (k in derivedAttributes) {
|
|
40
|
+
v = derivedAttributes[k];
|
|
41
|
+
record[k] = (ref = v(record)) != null ? ref : record[k];
|
|
42
|
+
}
|
|
43
|
+
return f(record);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if ($.isFunction(input)) {
|
|
47
|
+
return input(addRecord);
|
|
48
|
+
} else if ($.isArray(input)) {
|
|
49
|
+
if ($.isArray(input[0])) {
|
|
50
|
+
results = [];
|
|
51
|
+
for (i in input) {
|
|
52
|
+
if (!hasProp.call(input, i)) continue;
|
|
53
|
+
compactRecord = input[i];
|
|
54
|
+
if (!(i > 0)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
record = {};
|
|
58
|
+
ref = input[0];
|
|
59
|
+
for (j in ref) {
|
|
60
|
+
if (!hasProp.call(ref, j)) continue;
|
|
61
|
+
k = ref[j];
|
|
62
|
+
record[k] = compactRecord[j];
|
|
63
|
+
}
|
|
64
|
+
results.push(addRecord(record));
|
|
65
|
+
}
|
|
66
|
+
return results;
|
|
67
|
+
} else {
|
|
68
|
+
results1 = [];
|
|
69
|
+
for (l = 0, len1 = input.length; l < len1; l++) {
|
|
70
|
+
record = input[l];
|
|
71
|
+
results1.push(addRecord(record));
|
|
72
|
+
}
|
|
73
|
+
return results1;
|
|
74
|
+
}
|
|
75
|
+
} else if (input instanceof jQuery) {
|
|
76
|
+
tblCols = [];
|
|
77
|
+
$("thead > tr > th", input).each(function(i) {
|
|
78
|
+
return tblCols.push($(this).text());
|
|
79
|
+
});
|
|
80
|
+
return $("tbody > tr", input).each(function(i) {
|
|
81
|
+
record = {};
|
|
82
|
+
$("td", this).each(function(j) {
|
|
83
|
+
return record[tblCols[j]] = $(this).html();
|
|
84
|
+
});
|
|
85
|
+
return addRecord(record);
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
throw new Error("unknown input format");
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
DRPivotData.prototype.arrSort = function(attrs) {
|
|
93
|
+
var a, sortersArr;
|
|
94
|
+
sortersArr = (function() {
|
|
95
|
+
var l, len1, results;
|
|
96
|
+
results = [];
|
|
97
|
+
for (l = 0, len1 = attrs.length; l < len1; l++) {
|
|
98
|
+
a = attrs[l];
|
|
99
|
+
results.push(getSort(this.sorters, a));
|
|
100
|
+
}
|
|
101
|
+
return results;
|
|
102
|
+
}).call(this);
|
|
103
|
+
return function(a, b) {
|
|
104
|
+
var comparison, i, sorter;
|
|
105
|
+
for (i in sortersArr) {
|
|
106
|
+
sorter = sortersArr[i];
|
|
107
|
+
comparison = sorter(a[i], b[i]);
|
|
108
|
+
if (comparison !== 0) {
|
|
109
|
+
return comparison;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return 0;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
processKey = function(record, totals, keys, attrs, getAggregator) {
|
|
117
|
+
var addKey, attr, flatKey, k, key, len, ref;
|
|
118
|
+
key = [];
|
|
119
|
+
addKey = false;
|
|
120
|
+
for (k = 0, len = attrs.length; k < len; k++) {
|
|
121
|
+
attr = attrs[k];
|
|
122
|
+
key.push((ref = record[attr]) != null ? ref : "null");
|
|
123
|
+
flatKey = key.join(delim);
|
|
124
|
+
if (!totals[flatKey]) {
|
|
125
|
+
totals[flatKey] = getAggregator(key.slice());
|
|
126
|
+
addKey = true;
|
|
127
|
+
}
|
|
128
|
+
totals[flatKey].push(record);
|
|
129
|
+
}
|
|
130
|
+
if (addKey) {
|
|
131
|
+
keys.push(key);
|
|
132
|
+
}
|
|
133
|
+
return key;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
let newProcessKey = function (record, totals, keys, attrs, getAggregator) {
|
|
137
|
+
var addKey, attr, flatKey, k, key, len, ref;
|
|
138
|
+
key = [];
|
|
139
|
+
addKey = false;
|
|
140
|
+
for (k = 0, len = attrs.length; k < len; k++) {
|
|
141
|
+
attr = attrs[k];
|
|
142
|
+
if (record.hasOwnProperty(attr)) {
|
|
143
|
+
key.push((ref = record[attr]));
|
|
144
|
+
flatKey = key.join(delim);
|
|
145
|
+
}
|
|
146
|
+
if (totals[flatKey] && totals[flatKey].isChangeable) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (!flatKey) return [];
|
|
150
|
+
if (!totals[flatKey]) {
|
|
151
|
+
totals[flatKey] = getAggregator(key.slice());
|
|
152
|
+
addKey = true;
|
|
153
|
+
} else {
|
|
154
|
+
totals[flatKey] = getAggregator(key.slice());
|
|
155
|
+
totals[flatKey].push(record);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (addKey && key.length === attrs.length) {
|
|
159
|
+
keys.push(key);
|
|
160
|
+
}
|
|
161
|
+
return key;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
DRPivotData.prototype.processRecord = function(record, useTotalsCalculation) {
|
|
165
|
+
var colKey, fColKey, fRowKey, flatColKey, flatRowKey, i, j, k, m, n, ref, results, rowKey;
|
|
166
|
+
rowKey = [];
|
|
167
|
+
colKey = [];
|
|
168
|
+
if (useTotalsCalculation) {
|
|
169
|
+
rowKey = newProcessKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, (function(_this) {
|
|
170
|
+
return function(key) {
|
|
171
|
+
return _this.aggregator(_this, key, []);
|
|
172
|
+
};
|
|
173
|
+
})(this));
|
|
174
|
+
colKey = newProcessKey(record, this.colTotals, this.colKeys, this.colAttrs, (function(_this) {
|
|
175
|
+
return function(key) {
|
|
176
|
+
return _this.aggregator(_this, [], key);
|
|
177
|
+
};
|
|
178
|
+
})(this));
|
|
179
|
+
|
|
180
|
+
if (!colKey.length && !rowKey.length) {
|
|
181
|
+
this.allTotal.push(record);
|
|
182
|
+
}
|
|
183
|
+
if (!colKey.length && rowKey.length) {
|
|
184
|
+
this.rowTotals[rowKey.join(delim)].push(record);
|
|
185
|
+
this.rowTotals[rowKey.join(delim)].isChangeable = true;
|
|
186
|
+
}
|
|
187
|
+
if (!rowKey.length && colKey.length) {
|
|
188
|
+
this.colTotals[colKey.join(delim)].push(record);
|
|
189
|
+
this.colTotals[colKey.join(delim)].isChangeable = true;
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
this.allTotal.push(record);
|
|
193
|
+
rowKey = processKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, (function(_this) {
|
|
194
|
+
return function(key) {
|
|
195
|
+
return _this.aggregator(_this, key, []);
|
|
196
|
+
};
|
|
197
|
+
})(this));
|
|
198
|
+
colKey = processKey(record, this.colTotals, this.colKeys, this.colAttrs, (function(_this) {
|
|
199
|
+
return function(key) {
|
|
200
|
+
return _this.aggregator(_this, [], key);
|
|
201
|
+
};
|
|
202
|
+
})(this));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
m = rowKey.length - 1;
|
|
206
|
+
n = colKey.length - 1;
|
|
207
|
+
if (m < 0 || n < 0) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
results = [];
|
|
211
|
+
for (i = k = 0, ref = m; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) {
|
|
212
|
+
fRowKey = rowKey.slice(0, i + 1);
|
|
213
|
+
flatRowKey = fRowKey.join(delim);
|
|
214
|
+
if (!this.tree[flatRowKey]) {
|
|
215
|
+
this.tree[flatRowKey] = {};
|
|
216
|
+
}
|
|
217
|
+
results.push((function() {
|
|
218
|
+
var l, ref1, results1;
|
|
219
|
+
results1 = [];
|
|
220
|
+
for (j = l = 0, ref1 = n; 0 <= ref1 ? l <= ref1 : l >= ref1; j = 0 <= ref1 ? ++l : --l) {
|
|
221
|
+
fColKey = colKey.slice(0, j + 1);
|
|
222
|
+
flatColKey = fColKey.join(delim);
|
|
223
|
+
if (!this.tree[flatRowKey][flatColKey]) {
|
|
224
|
+
this.tree[flatRowKey][flatColKey] = this.aggregator(this, fRowKey, fColKey);
|
|
225
|
+
}
|
|
226
|
+
results1.push(this.tree[flatRowKey][flatColKey].push(record));
|
|
227
|
+
}
|
|
228
|
+
return results1;
|
|
229
|
+
}).call(this));
|
|
230
|
+
}
|
|
231
|
+
return results;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
DRPivotData.prototype.getAggregator = function(rowKey, colKey) {
|
|
235
|
+
var agg, flatColKey, flatRowKey;
|
|
236
|
+
flatRowKey = rowKey.join(delim);
|
|
237
|
+
flatColKey = colKey.join(delim);
|
|
238
|
+
if (rowKey.length === 0 && colKey.length === 0) {
|
|
239
|
+
agg = this.allTotal;
|
|
240
|
+
} else if (rowKey.length === 0) {
|
|
241
|
+
agg = this.colTotals[flatColKey];
|
|
242
|
+
} else if (colKey.length === 0) {
|
|
243
|
+
agg = this.rowTotals[flatRowKey];
|
|
244
|
+
} else {
|
|
245
|
+
agg = this.tree[flatRowKey][flatColKey];
|
|
246
|
+
}
|
|
247
|
+
return agg != null ? agg : {
|
|
248
|
+
value: (function() {
|
|
249
|
+
return null;
|
|
250
|
+
}),
|
|
251
|
+
format: function() {
|
|
252
|
+
return "";
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
return DRPivotData;
|
|
258
|
+
|
|
259
|
+
})($.pivotUtilities.PivotData);
|
|
260
|
+
|
|
261
|
+
sortDateStrings = function(month_order) {
|
|
262
|
+
var i, mapping, x;
|
|
263
|
+
mapping = {};
|
|
264
|
+
var order = [
|
|
265
|
+
{"month":"jan", "versions": ['january', 'jan', 'ja'], weight:1},
|
|
266
|
+
{"month":"feb", "versions": ['february', 'feb', 'fe'], weight:2},
|
|
267
|
+
{"month":"mar", "versions": ['march', 'mar', 'mr'], weight:3},
|
|
268
|
+
{"month":"apr", "versions": ['april', 'apr', 'ap','al'], weight:4},
|
|
269
|
+
{"month":"may", "versions": ['may', 'ma'], weight:5},
|
|
270
|
+
{"month":"jun", "versions": ['june', 'jun','jn'], weight:6},
|
|
271
|
+
{"month":"jul", "versions": ['july', 'jul','jl'], weight:7},
|
|
272
|
+
{"month":"aug", "versions": ['august', 'aug', 'au'], weight:8},
|
|
273
|
+
{"month":"sep", "versions": ['september', 'sept', 'sep','sp','se'], weight:9},
|
|
274
|
+
{"month":"oct", "versions": ['october','oct', 'oc'], weight:10},
|
|
275
|
+
{"month":"nov", "versions": ['november', 'nov', 'no'], weight:11},
|
|
276
|
+
{"month":"dec", "versions": ['december', 'dec', 'de'], weight:12}
|
|
277
|
+
];
|
|
278
|
+
var pattern = /(\d{1,4})|(Ja(n)?(uary)?|Fe(b)?(ruary)?|Mar(ch)?|mr|Ap(r)?(il)?|al|Ma(y)?|Jun(e)?|jn|Jul(y)?|jl|Aug(ust)?|au|Se(p)?(t)?(ember)?|sp|Oc(t)?(ober)?|No(v)?(ember)?|De(c)?(ember)?)/ig
|
|
279
|
+
if(month_order){
|
|
280
|
+
for(i=0; i<month_order.length; i++){
|
|
281
|
+
var find_row = _.find(order, {month:month_order[i]});
|
|
282
|
+
if(find_row){
|
|
283
|
+
find_row.weight = i+1;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
_.forEach(order, function(month_obj){
|
|
289
|
+
_.forEach(month_obj.versions, function(val){
|
|
290
|
+
mapping[val] = month_obj.weight*31;
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
var getIndexForVal = function(value){
|
|
295
|
+
var to_return = 0, matches, i;
|
|
296
|
+
if (typeof value === 'string' || value instanceof String){
|
|
297
|
+
matches = value.match(pattern);
|
|
298
|
+
var numbers = 0;
|
|
299
|
+
var i = 0;
|
|
300
|
+
_.forEach(matches, function(v)
|
|
301
|
+
{
|
|
302
|
+
i++;
|
|
303
|
+
v = v.trim().toLowerCase();
|
|
304
|
+
var res = 0;
|
|
305
|
+
|
|
306
|
+
if(mapping[v] != undefined){
|
|
307
|
+
res = mapping[v];
|
|
308
|
+
}
|
|
309
|
+
else{
|
|
310
|
+
try {
|
|
311
|
+
res = parseInt(v)
|
|
312
|
+
if(res > 31 || numbers > 1 || i == matches.length)
|
|
313
|
+
res *=1000
|
|
314
|
+
numbers++;
|
|
315
|
+
}
|
|
316
|
+
catch(er){
|
|
317
|
+
res = 0
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if(res == NaN){
|
|
321
|
+
res = 0
|
|
322
|
+
}
|
|
323
|
+
to_return += res
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
else{
|
|
327
|
+
try {
|
|
328
|
+
to_return = parseInt(value)
|
|
329
|
+
}
|
|
330
|
+
catch(er){
|
|
331
|
+
to_return = value
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return to_return;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
return function(a, b) {
|
|
339
|
+
return $.pivotUtilities.naturalSort(getIndexForVal(a), getIndexForVal(b));
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
largeToSmallSortByAbsolute = function (as, bs) {
|
|
344
|
+
return largeToSmallSort(as , bs, true);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
largeToSmallSort = function(as, bs, is_abs = false) {
|
|
348
|
+
var a, a1, b, b1, rd, rx, rz;
|
|
349
|
+
rx = /(\d+)|(\D+)/g;
|
|
350
|
+
rd = /\d/;
|
|
351
|
+
rz = /^0/;
|
|
352
|
+
if (typeof as === "number" || typeof bs === "number") {
|
|
353
|
+
if (isNaN(as)) {
|
|
354
|
+
return -1;
|
|
355
|
+
}
|
|
356
|
+
if (isNaN(bs)) {
|
|
357
|
+
return 1;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (is_abs) {
|
|
361
|
+
return Math.abs(bs) - Math.abs(as);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return bs - as;
|
|
365
|
+
}
|
|
366
|
+
a = String(as).toLowerCase();
|
|
367
|
+
b = String(bs).toLowerCase();
|
|
368
|
+
if (a === b) {
|
|
369
|
+
return 0;
|
|
370
|
+
}
|
|
371
|
+
if (!(rd.test(a) && rd.test(b))) {
|
|
372
|
+
return (b > a ? 1 : -1);
|
|
373
|
+
}
|
|
374
|
+
a = a.match(rx);
|
|
375
|
+
b = b.match(rx);
|
|
376
|
+
while (a.length && b.length) {
|
|
377
|
+
a1 = a.shift();
|
|
378
|
+
b1 = b.shift();
|
|
379
|
+
if (a1 !== b1) {
|
|
380
|
+
if (rd.test(a1) && rd.test(b1)) {
|
|
381
|
+
return b1.replace(rz, ".0") - a1.replace(rz, ".0");
|
|
382
|
+
} else {
|
|
383
|
+
return (b1 > a1 ? 1 : -1);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return b.length - a.length;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
$.pivotUtilities.DRPivotData = DRPivotData;
|
|
391
|
+
|
|
392
|
+
getFormattedNumber = function(val, aggregator, opts, format_argument) {
|
|
393
|
+
if (!aggregator) {
|
|
394
|
+
aggregator = {};
|
|
395
|
+
aggregator.format = function(val) {
|
|
396
|
+
return val.toLocaleString();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (val < 0 && opts && opts.chartOptions && opts.chartOptions.negative_numbers && opts.chartOptions.negative_numbers.value) {
|
|
400
|
+
switch (opts.chartOptions.negative_numbers.value) {
|
|
401
|
+
case 'red_minus':
|
|
402
|
+
return '<span style="color: red; fill: red;">' + aggregator.format(val, format_argument) + '</span>';
|
|
403
|
+
break;
|
|
404
|
+
case 'absolute':
|
|
405
|
+
return '(' + aggregator.format(Math.abs(val), format_argument) + ')';
|
|
406
|
+
break;
|
|
407
|
+
case 'red_absolute':
|
|
408
|
+
return '<span style="color: red; fill: red;">(' + aggregator.format(Math.abs(val), format_argument) + ')</span>';
|
|
409
|
+
break;
|
|
410
|
+
default:
|
|
411
|
+
return aggregator.format(val, format_argument);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return aggregator.format(val, format_argument);
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
NovixRenderer = function(pvtData, opts, charttype) {
|
|
418
|
+
var resultsArr = [];
|
|
419
|
+
var additionOptions = opts.chartOptions ? opts.chartOptions : null;
|
|
420
|
+
if (additionOptions && additionOptions.table_options.use_handsOnTable) {
|
|
421
|
+
if (opts && opts.chart_title && !opts.chartOptions.hideChartHeader) {
|
|
422
|
+
var title = document.createElement("div");
|
|
423
|
+
title.className = "title";
|
|
424
|
+
title.innerText = opts.chart_title;
|
|
425
|
+
resultsArr.push(title);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (additionOptions && additionOptions.subtitle && additionOptions.subtitle.subtitle && !opts.chartOptions.hideChartHeader) {
|
|
429
|
+
console.log("subtitle", additionOptions.subtitle);
|
|
430
|
+
var subTitle = document.createElement("div");
|
|
431
|
+
subTitle.className = "sub-title";
|
|
432
|
+
subTitle.innerText = additionOptions.subtitle.subtitle;
|
|
433
|
+
resultsArr.push(subTitle);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
resultsArr.push($.pivotUtilities.novix_renderers["Pivot Table"](pvtData, opts));
|
|
437
|
+
|
|
438
|
+
// var wrapper = document.createElement("div");
|
|
439
|
+
// wrapper.className = "pivot-wrapper2";
|
|
440
|
+
// $(wrapper).append(resultsArr);
|
|
441
|
+
|
|
442
|
+
return resultsArr;
|
|
443
|
+
} else {
|
|
444
|
+
let tooMuch = false;
|
|
445
|
+
if (pvtData && (pvtData.rowKeys.length > 1000 || pvtData.colKeys.length > 500) &&
|
|
446
|
+
(!opts.show_more_function_cols || !opts.show_more_function_cols)) {
|
|
447
|
+
pvtData.rowKeys = [];
|
|
448
|
+
pvtData.colKeys = [];
|
|
449
|
+
tooMuch = true;
|
|
450
|
+
opts.error_has_occurred = true;
|
|
451
|
+
opts.error_params = $.pivotUtilities.errorHandling.placeholders.tooMuchData;
|
|
452
|
+
}
|
|
453
|
+
return SubtotalRenderer(pvtData, opts, charttype, tooMuch, opts.error_params);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
SubtotalRenderer = function(pivotData, opts, charttype, tooMuch = false, error_params) {
|
|
458
|
+
var addClass, allTotal, arrowCollapsed, arrowExpanded, buildColHeaderHeader, buildColHeaderHeaders, buildColHeaderHeadersClickEvents, buildColHeaders, buildColTotals, buildColTotalsHeader, buildGrandTotal, buildRowHeaderHeaders, buildRowHeaderHeadersClickEvents, buildRowHeaders, buildRowTotalsHeader, buildValues, classColCollapsed, classColExpanded, classColHide, classColShow, classCollapsed, classExpanded, classRowCollapsed, classRowExpanded, classRowHide, classRowShow, clickStatusCollapsed, clickStatusExpanded, colAttrs, colDisableAfter, colKeys, colTotals, collapseCol, collapseColsAt, collapseHideDescendantRow, collapseRow, collapseRowsAt, collapseShowColSubtotal, collapseShowRowSubtotal, createElement, defaults, expandChildCol, expandChildRow, expandCol, expandColsAt, expandHideColSubtotal, expandHideRowSubtotal, expandRow, expandRowsAt, expandShowColSubtotal, expandShowRowSubtotal, getTableEventHandlers, hasClass, hideDescendantCol, isColDisable, isColDisableExpandCollapse, isColHideOnExpand, isRowDisable, isRowDisableExpandCollapse, isRowHideOnExpand, main, getSubtotalInBrackets, processKeys, encodeHtmlEntities, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, removeClass, replaceClass, rowAttrs, rowDisableAfter, rowKeys, rowTotals, setAttributes, showChildCol, showChildRow, toggleCol, toggleColHeaderHeader, toggleRow, toggleRowHeaderHeader, tree, assumptionSubscribe;
|
|
459
|
+
var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes, getColorsWithOffsetForTable, offsetColors, handleFreezePanesScroll, selectFreezableElements, removeRowHeaderNullValue;
|
|
460
|
+
var edit_assumptions;
|
|
461
|
+
|
|
462
|
+
var horizontalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' horizontal-freeze-pane' : '';
|
|
463
|
+
var verticalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' vertical-freeze-pane' : '';
|
|
464
|
+
var axisFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' axis-freeze-pane' : '';
|
|
465
|
+
|
|
466
|
+
var elementToTransform = {
|
|
467
|
+
X: horizontalFreezePaneClass,
|
|
468
|
+
Y: verticalFreezePaneClass,
|
|
469
|
+
XY: axisFreezePaneClass,
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
defaults = {
|
|
473
|
+
table: {
|
|
474
|
+
clickCallback: null
|
|
475
|
+
},
|
|
476
|
+
localeStrings: {
|
|
477
|
+
totals: "Grand Totals",
|
|
478
|
+
subtotals: "Subtotal"
|
|
479
|
+
},
|
|
480
|
+
chartOptions:{
|
|
481
|
+
table_options:{
|
|
482
|
+
show_column_total:true,
|
|
483
|
+
show_row_total:true
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
totalFilterElements: null,
|
|
487
|
+
resetSortingElement: null,
|
|
488
|
+
nextSortingElement: null,
|
|
489
|
+
prevSortingElement: null,
|
|
490
|
+
show_more_function_cols: null,
|
|
491
|
+
show_more_function_rows: null,
|
|
492
|
+
show_more_max_items: 10,
|
|
493
|
+
labelsConvertFunction: function(str){return str;}
|
|
494
|
+
};
|
|
495
|
+
opts = $.extend(true, {}, defaults, opts);
|
|
496
|
+
|
|
497
|
+
if(opts.chartOptions.table_options.start_collapsed_rows) {
|
|
498
|
+
opts.collapseRowsAt = 0;
|
|
499
|
+
}
|
|
500
|
+
if(opts.chartOptions.table_options.start_collapsed_columns) {
|
|
501
|
+
opts.collapseColsAt = 0;
|
|
502
|
+
}
|
|
503
|
+
edit_assumptions = opts.chartOptions.edit_assumptions;
|
|
504
|
+
isRowDisable = (ref = opts.rowSubtotalDisplay) != null ? ref.disableSubtotal : void 0;
|
|
505
|
+
isRowHideOnExpand = (ref1 = opts.rowSubtotalDisplay) != null ? ref1.hideOnExpand : !opts.chartOptions.table_options.show_subtotals_for_rows;
|
|
506
|
+
isRowDisableExpandCollapse = (ref2 = opts.rowSubtotalDisplay) != null ? ref2.disableExpandCollapse : void 0;
|
|
507
|
+
rowDisableAfter = (ref3 = opts.rowSubtotalDisplay) != null ? ref3.disableAfter != null ? ref3.disableAfter : ref3.disableAfter = 9999 : void 0;
|
|
508
|
+
isColDisable = (ref4 = opts.colSubtotalDisplay) != null ? ref4.disableSubtotal : void 0;
|
|
509
|
+
isColHideOnExpand = (ref5 = opts.colSubtotalDisplay) != null ? ref5.hideOnExpand : !opts.chartOptions.table_options.show_subtotals_for_columns;
|
|
510
|
+
isColDisableExpandCollapse = (ref6 = opts.colSubtotalDisplay) != null ? ref6.disableExpandCollapse : void 0;
|
|
511
|
+
colDisableAfter = (ref7 = opts.colSubtotalDisplay) != null ? ref7.disableAfter != null ? ref7.disableAfter : ref7.disableAfter = 9999 : void 0;
|
|
512
|
+
arrowCollapsed = opts.arrowCollapsed != null ? opts.arrowCollapsed : opts.arrowCollapsed = '<i class="fa fa-plus dr-icon-add"></i> ';
|
|
513
|
+
arrowExpanded = opts.arrowExpanded != null ? opts.arrowExpanded : opts.arrowExpanded = '<i class="fa fa-minus dr-icon-minus"></i> ';
|
|
514
|
+
colAttrs = pivotData.colAttrs;
|
|
515
|
+
rowAttrs = pivotData.rowAttrs;
|
|
516
|
+
rowKeys = pivotData.getRowKeys();
|
|
517
|
+
|
|
518
|
+
if (charttype == 'column-chart' || charttype == 'column-chart-stacked') {
|
|
519
|
+
if (_.get(opts, 'chartOptions.table_options.transpose_table', false)) {
|
|
520
|
+
rowAttrs = [rowAttrs[0]];
|
|
521
|
+
if (rowKeys && rowKeys.length) {
|
|
522
|
+
rowKeys = rowKeys.map( function(_, index) {
|
|
523
|
+
return [rowKeys[index][0]];
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
} else {
|
|
527
|
+
colAttrs = [colAttrs[0]];
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
colKeys = pivotData.getColKeys();
|
|
531
|
+
tree = pivotData.tree;
|
|
532
|
+
rowTotals = pivotData.rowTotals;
|
|
533
|
+
colTotals = pivotData.colTotals;
|
|
534
|
+
allTotal = pivotData.allTotal;
|
|
535
|
+
classRowExpanded = "rowexpanded";
|
|
536
|
+
classRowCollapsed = "rowcollapsed";
|
|
537
|
+
classRowHide = "rowhide";
|
|
538
|
+
classRowShow = "rowshow";
|
|
539
|
+
classColExpanded = "colexpanded";
|
|
540
|
+
classColCollapsed = "colcollapsed";
|
|
541
|
+
classColHide = "colhide";
|
|
542
|
+
classColShow = "colshow";
|
|
543
|
+
clickStatusExpanded = "expanded";
|
|
544
|
+
clickStatusCollapsed = "collapsed";
|
|
545
|
+
classExpanded = "expanded";
|
|
546
|
+
classCollapsed = "collapsed";
|
|
547
|
+
hasClass = function(element, className) {
|
|
548
|
+
var regExp;
|
|
549
|
+
regExp = new RegExp("(?:^|\\s)" + className + "(?!\\S)", "g");
|
|
550
|
+
return element.className.match(regExp) !== null;
|
|
551
|
+
};
|
|
552
|
+
removeClass = function(element, className) {
|
|
553
|
+
var k, len, name, ref8, regExp, results;
|
|
554
|
+
ref8 = className.split(" ");
|
|
555
|
+
results = [];
|
|
556
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
557
|
+
name = ref8[k];
|
|
558
|
+
regExp = new RegExp("(?:^|\\s)" + name + "(?!\\S)", "g");
|
|
559
|
+
results.push(element.className = element.className.replace(regExp, ''));
|
|
560
|
+
}
|
|
561
|
+
return results;
|
|
562
|
+
};
|
|
563
|
+
addClass = function(element, className) {
|
|
564
|
+
var k, len, name, ref8, results;
|
|
565
|
+
ref8 = className.split(" ");
|
|
566
|
+
results = [];
|
|
567
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
568
|
+
name = ref8[k];
|
|
569
|
+
if (!hasClass(element, name)) {
|
|
570
|
+
results.push(element.className += " " + name);
|
|
571
|
+
} else {
|
|
572
|
+
results.push(void 0);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return results;
|
|
576
|
+
};
|
|
577
|
+
replaceClass = function(element, replaceClassName, byClassName) {
|
|
578
|
+
removeClass(element, replaceClassName);
|
|
579
|
+
return addClass(element, byClassName);
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
colorizeTableIfNeed = function(element){
|
|
583
|
+
if(opts.chartOptions.table_options.colorize_headers == true){
|
|
584
|
+
element.className += " colorized";
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
valueNoDashes = function(value){
|
|
589
|
+
|
|
590
|
+
if(opts.chartOptions.table_options.remove_underscores == true && typeof(value) == 'string'){
|
|
591
|
+
return value.replace(/_/g, " ");
|
|
592
|
+
}
|
|
593
|
+
return value;
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
offsetColors = function (offset, colorsArray) {
|
|
597
|
+
if (offset > opts.defaults_colors.length) {
|
|
598
|
+
offset = offset % opts.defaults_colors;
|
|
599
|
+
}
|
|
600
|
+
var colors_to_return = JSON.parse(JSON.stringify(colorsArray));
|
|
601
|
+
for (var i = 0; i < offset; i++) {
|
|
602
|
+
colors_to_return.push(colors_to_return.shift());
|
|
603
|
+
}
|
|
604
|
+
return colors_to_return;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
getColorsWithOffsetForTable = function (value) {
|
|
608
|
+
var isNewDesign = useNewUx && opts.chartOptions.table_options.use_new_table_design;
|
|
609
|
+
if (value) {
|
|
610
|
+
var offset = parseInt(value);
|
|
611
|
+
if (offset) {
|
|
612
|
+
if (isNewDesign) {
|
|
613
|
+
return offsetColors(offset, newTableColors);
|
|
614
|
+
} else {
|
|
615
|
+
return offsetColors(offset, opts.defaults_colors);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return isNewDesign ? newTableColors : opts.defaults_colors;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
colorizeRowLabelHeaders = function(element, cols_count){
|
|
623
|
+
if(opts.chartOptions.table_options.colorize_headers == true &&
|
|
624
|
+
opts.defaults_colors && opts.defaults_colors.length > 0){
|
|
625
|
+
var offsetColor = getColorsWithOffsetForTable(opts.chartOptions.table_options.table_colors_offset);
|
|
626
|
+
var color_to_set = offsetColor[cols_count];
|
|
627
|
+
if(color_to_set){
|
|
628
|
+
element.style.setProperty("background-color", color_to_set, "important");
|
|
629
|
+
element.style.setProperty("border-color", color_to_set, "important");
|
|
630
|
+
element.style.color = useNewUx && opts.chartOptions.table_options.use_new_table_design? '#3a3b39' : '#FFFFFF';
|
|
631
|
+
element.style.fontWeight = "bold";
|
|
632
|
+
if (opts.chartOptions.table_options.freeze_panes && element.firstChild) {
|
|
633
|
+
for (const child of element.children) {
|
|
634
|
+
child.style.setProperty("background-color", color_to_set, "important");
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
createTotalValsBolder = function(element){
|
|
642
|
+
if(opts.chartOptions.table_options.colorize_headers == true && (!useNewUx || !opts.chartOptions.table_options.use_new_table_design)){
|
|
643
|
+
element.style.setProperty("border-bottom", "3px double #000000", "important");
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
createGrandTotalBolder = function(element){
|
|
647
|
+
if(opts.chartOptions.table_options.colorize_headers == true && (!useNewUx || !opts.chartOptions.table_options.use_new_table_design)){
|
|
648
|
+
element.style.setProperty("border-top", "3px solid #000000", "important");
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
getHeaderColorProperties = function(element, col_number = 0){
|
|
652
|
+
if(opts.chartOptions.table_options.colorize_headers == true &&
|
|
653
|
+
opts.defaults_colors && opts.defaults_colors.length > 0){
|
|
654
|
+
const offsetColor = getColorsWithOffsetForTable(opts.chartOptions.table_options.table_colors_offset);
|
|
655
|
+
var color_to_set = offsetColor[col_number];
|
|
656
|
+
if(color_to_set){
|
|
657
|
+
element.style.setProperty("background-color", color_to_set, "important");
|
|
658
|
+
element.style.setProperty("border-color", color_to_set, "important");
|
|
659
|
+
element.style.setProperty("vertical-align", "baseline");
|
|
660
|
+
element.style.color = useNewUx && opts.chartOptions.table_options.use_new_table_design? '#3a3b39' : '#FFFFFF';
|
|
661
|
+
element.style.fontWeight = "bold";
|
|
662
|
+
if (opts.chartOptions.table_options.freeze_panes && element.firstChild) {
|
|
663
|
+
for (const child of element.children) {
|
|
664
|
+
child.style.setProperty("background-color", color_to_set, "important");
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
getTableEventHandlers = function(value, rowValues, colValues) {
|
|
671
|
+
var attr, event, eventHandlers, filters, handler, i, ref8;
|
|
672
|
+
if (!opts.table && !opts.table.eventHandlers) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
eventHandlers = {};
|
|
676
|
+
ref8 = opts.table.eventHandlers;
|
|
677
|
+
for (event in ref8) {
|
|
678
|
+
if (!hasProp.call(ref8, event)) continue;
|
|
679
|
+
handler = ref8[event];
|
|
680
|
+
filters = {};
|
|
681
|
+
for (i in colAttrs) {
|
|
682
|
+
if (!hasProp.call(colAttrs, i)) continue;
|
|
683
|
+
attr = colAttrs[i];
|
|
684
|
+
if (colValues[i] != null) {
|
|
685
|
+
filters[attr] = colValues[i];
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
for (i in rowAttrs) {
|
|
689
|
+
if (!hasProp.call(rowAttrs, i)) continue;
|
|
690
|
+
attr = rowAttrs[i];
|
|
691
|
+
if (rowValues[i] != null) {
|
|
692
|
+
filters[attr] = rowValues[i];
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
eventHandlers[event] = function(e) {
|
|
696
|
+
return handler(e, value, filters, pivotData);
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
return eventHandlers;
|
|
700
|
+
};
|
|
701
|
+
createElement = function(elementType, className, textContent, attributes, eventHandlers) {
|
|
702
|
+
var attr, e, event, handler, val;
|
|
703
|
+
e = document.createElement(elementType);
|
|
704
|
+
if (className != null) {
|
|
705
|
+
e.className = className;
|
|
706
|
+
}
|
|
707
|
+
if (textContent != null) {
|
|
708
|
+
// We need html for negative items.
|
|
709
|
+
e.innerHTML = textContent;
|
|
710
|
+
}
|
|
711
|
+
if (attributes != null) {
|
|
712
|
+
for (attr in attributes) {
|
|
713
|
+
if (!hasProp.call(attributes, attr)) continue;
|
|
714
|
+
val = attributes[attr];
|
|
715
|
+
e.setAttribute(attr, val);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
if (eventHandlers != null) {
|
|
719
|
+
for (event in eventHandlers) {
|
|
720
|
+
if (!hasProp.call(eventHandlers, event)) continue;
|
|
721
|
+
handler = eventHandlers[event];
|
|
722
|
+
e.addEventListener(event, handler);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return e;
|
|
726
|
+
};
|
|
727
|
+
setAttributes = function(e, attrs) {
|
|
728
|
+
var a, results, v;
|
|
729
|
+
results = [];
|
|
730
|
+
for (a in attrs) {
|
|
731
|
+
if (!hasProp.call(attrs, a)) continue;
|
|
732
|
+
v = attrs[a];
|
|
733
|
+
results.push(e.setAttribute(a, v));
|
|
734
|
+
}
|
|
735
|
+
return results;
|
|
736
|
+
};
|
|
737
|
+
getSubtotalInBrackets = function(keysArr, className, lastCol, lastRow, from, to) {
|
|
738
|
+
let aggregator, val, to_return;
|
|
739
|
+
if(opts.chartOptions.table_options.show_subtotals_in_brackets){
|
|
740
|
+
if(className == "pvtColLabel" && keysArr[from] && to < keysArr[from].length){
|
|
741
|
+
aggregator = pivotData.getAggregator([], keysArr[from].slice(0, to+1));
|
|
742
|
+
val = aggregator.value();
|
|
743
|
+
to_return = getFormattedNumber(val, aggregator, opts);
|
|
744
|
+
return ' ('+to_return+")";
|
|
745
|
+
}
|
|
746
|
+
else if(className == "pvtRowLabel" && keysArr[from] && to < keysArr[from].length){
|
|
747
|
+
aggregator = pivotData.getAggregator(keysArr[from].slice(0, to+1), []);
|
|
748
|
+
val = aggregator.value();
|
|
749
|
+
to_return = getFormattedNumber(val, aggregator, opts);
|
|
750
|
+
return ' ('+to_return+")";
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
return '';
|
|
754
|
+
};
|
|
755
|
+
encodeHtmlEntities = function(string_val) {
|
|
756
|
+
if(!string_val || typeof(string_val) != 'string' ){
|
|
757
|
+
return string_val;
|
|
758
|
+
}
|
|
759
|
+
var entityMap = {"'":"'","<":"<",">":">"," ":" ","¡":"¡","¢":"¢","£":"£","¤":"¤","¥":"¥","¦":"¦","§":"§","¨":"¨","©":"©","ª":"ª","«":"«","¬":"¬","®":"®","¯":"¯","°":"°","±":"±","²":"²","³":"³","´":"´","µ":"µ","¶":"¶","·":"·","¸":"¸","¹":"¹","º":"º","»":"»","¼":"¼","½":"½","¾":"¾","¿":"¿","À":"À","Á":"Á","Â":"Â","Ã":"Ã","Ä":"Ä","Å":"Å","Æ":"Æ","Ç":"Ç","È":"È","É":"É","Ê":"Ê","Ë":"Ë","Ì":"Ì","Í":"Í","Î":"Î","Ï":"Ï","Ð":"Ð","Ñ":"Ñ","Ò":"Ò","Ó":"Ó","Ô":"Ô","Õ":"Õ","Ö":"Ö","×":"×","Ø":"Ø","Ù":"Ù","Ú":"Ú","Û":"Û","Ü":"Ü","Ý":"Ý","Þ":"Þ","ß":"ß","à":"à","á":"á","â":"â","ã":"ã","ä":"ä","å":"å","æ":"æ","ç":"ç","è":"è","é":"é","ê":"ê","ë":"ë","ì":"ì","í":"í","î":"î","ï":"ï","ð":"ð","ñ":"ñ","ò":"ò","ó":"ó","ô":"ô","õ":"õ","ö":"ö","÷":"÷","ø":"ø","ù":"ù","ú":"ú","û":"û","ü":"ü","ý":"ý","þ":"þ","ÿ":"ÿ","Œ":"Œ","œ":"œ","Š":"Š","š":"š","Ÿ":"Ÿ","ƒ":"ƒ","ˆ":"ˆ","˜":"˜","Α":"Α","Β":"Β","Γ":"Γ","Δ":"Δ","Ε":"Ε","Ζ":"Ζ","Η":"Η","Θ":"Θ","Ι":"Ι","Κ":"Κ","Λ":"Λ","Μ":"Μ","Ν":"Ν","Ξ":"Ξ","Ο":"Ο","Π":"Π","Ρ":"Ρ","Σ":"Σ","Τ":"Τ","Υ":"Υ","Φ":"Φ","Χ":"Χ","Ψ":"Ψ","Ω":"Ω","α":"α","β":"β","γ":"γ","δ":"δ","ε":"ε","ζ":"ζ","η":"η","θ":"θ","ι":"ι","κ":"κ","λ":"λ","μ":"μ","ν":"ν","ξ":"ξ","ο":"ο","π":"π","ρ":"ρ","ς":"ς","σ":"σ","τ":"τ","υ":"υ","φ":"φ","χ":"χ","ψ":"ψ","ω":"ω","ϑ":"ϑ","ϒ":"&Upsih;","ϖ":"ϖ","–":"–","—":"—","‘":"‘","’":"’","‚":"‚","“":"“","”":"”","„":"„","†":"†","‡":"‡","•":"•","…":"…","‰":"‰","′":"′","″":"″","‹":"‹","›":"›","‾":"‾","⁄":"⁄","€":"€","ℑ":"ℑ","℘":"℘","ℜ":"ℜ","™":"™","ℵ":"ℵ","←":"←","↑":"↑","→":"→","↓":"↓","↔":"↔","↵":"↵","⇐":"⇐","⇑":"&UArr;","⇒":"⇒","⇓":"⇓","⇔":"⇔","∀":"∀","∂":"∂","∃":"∃","∅":"∅","∇":"∇","∈":"∈","∉":"∉","∋":"∋","∏":"∏","∑":"∑","−":"−","∗":"∗","√":"√","∝":"∝","∞":"∞","∠":"∠","∧":"∧","∨":"∨","∩":"∩","∪":"∪","∫":"∫","∴":"∴","∼":"∼","≅":"≅","≈":"≈","≠":"≠","≡":"≡","≤":"≤","≥":"≥","⊂":"⊂","⊃":"⊃","⊄":"⊄","⊆":"⊆","⊇":"⊇","⊕":"⊕","⊗":"⊗","⊥":"⊥","⋅":"⋅","⌈":"⌈","⌉":"⌉","⌊":"⌊","⌋":"⌋","⟨":"⟨","⟩":"⟩","◊":"◊","♠":"♠","♣":"♣","♥":"♥","♦":"♦"};
|
|
760
|
+
string_val = string_val.replace(/&/g, '&');
|
|
761
|
+
string_val = string_val.replace(/"/g, '"');
|
|
762
|
+
for (var key in entityMap) {
|
|
763
|
+
var entity = entityMap[key];
|
|
764
|
+
var regex = new RegExp(key, 'g');
|
|
765
|
+
string_val = string_val.replace(regex, entity);
|
|
766
|
+
}
|
|
767
|
+
return string_val;
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
processKeys = function(keysArr, className, dimention, attrs) {
|
|
771
|
+
var c, headers, k, key, lastCol, lastRow, node, nodePos, r, rMark, ref8, repeats, th, x;
|
|
772
|
+
const showAllData = opts && opts.chartOptions && opts.chartOptions.table_options && opts.chartOptions.table_options.show_all;
|
|
773
|
+
|
|
774
|
+
headers = [];
|
|
775
|
+
lastRow = keysArr.length - 1;
|
|
776
|
+
lastCol = keysArr[0].length - 1;
|
|
777
|
+
if(lastCol > 0 && className == "pvtColLabel" && !_.get(opts, 'chartOptions.table_options.transpose_table', false) && (charttype == 'column-chart' || charttype == 'column-chart-stacked')){
|
|
778
|
+
lastCol = 0;
|
|
779
|
+
}
|
|
780
|
+
rMark = [];
|
|
781
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(keysArr[0][0]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, 0, 0)));
|
|
782
|
+
key = [];
|
|
783
|
+
key.push(keysArr[0][0]);
|
|
784
|
+
nodePos = 0;
|
|
785
|
+
node = {
|
|
786
|
+
node: nodePos,
|
|
787
|
+
row: 0,
|
|
788
|
+
col: 0,
|
|
789
|
+
th: th,
|
|
790
|
+
parent: null,
|
|
791
|
+
children: [],
|
|
792
|
+
descendants: lastCol,
|
|
793
|
+
leaves: 1,
|
|
794
|
+
key: key,
|
|
795
|
+
flatKey: key.join(delim)
|
|
796
|
+
};
|
|
797
|
+
headers.push(node);
|
|
798
|
+
rMark[0] = node;
|
|
799
|
+
c = 1;
|
|
800
|
+
while (c <= lastCol) {
|
|
801
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(keysArr[0][c]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, 0, c)));
|
|
802
|
+
key = key.slice();
|
|
803
|
+
key.push(keysArr[0][c]);
|
|
804
|
+
++nodePos;
|
|
805
|
+
node = {
|
|
806
|
+
node: nodePos,
|
|
807
|
+
row: 0,
|
|
808
|
+
col: c,
|
|
809
|
+
th: th,
|
|
810
|
+
parent: rMark[c - 1],
|
|
811
|
+
children: [],
|
|
812
|
+
descendants: lastCol - c,
|
|
813
|
+
leaves: 1,
|
|
814
|
+
key: key,
|
|
815
|
+
flatKey: key.join(delim)
|
|
816
|
+
};
|
|
817
|
+
rMark[c] = node;
|
|
818
|
+
rMark[c - 1].children.push(node);
|
|
819
|
+
++c;
|
|
820
|
+
}
|
|
821
|
+
rMark[lastCol].leaves = 0;
|
|
822
|
+
r = 1;
|
|
823
|
+
while (r <= lastRow) {
|
|
824
|
+
repeats = true;
|
|
825
|
+
key = [];
|
|
826
|
+
c = 0;
|
|
827
|
+
while (c <= lastCol) {
|
|
828
|
+
key = key.slice();
|
|
829
|
+
key.push(keysArr[r][c]);
|
|
830
|
+
if ((keysArr[r][c] === keysArr[rMark[c].row][c]) && (c !== lastCol) && repeats) {
|
|
831
|
+
repeats = true;
|
|
832
|
+
++c;
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if(c === 0 && ((dimention == 'rows' && opts.show_more_function_rows)
|
|
837
|
+
|| (dimention == 'cols' && opts.show_more_function_cols)
|
|
838
|
+
) && headers.length > opts.show_more_max_items && !showAllData)
|
|
839
|
+
{
|
|
840
|
+
key=['...'];
|
|
841
|
+
|
|
842
|
+
let th_attr = {data_show_more:'1'};
|
|
843
|
+
|
|
844
|
+
th = createElement("th", className, '... Show All', th_attr);
|
|
845
|
+
++nodePos;
|
|
846
|
+
node = {
|
|
847
|
+
node: nodePos,
|
|
848
|
+
row: r,
|
|
849
|
+
col: c,
|
|
850
|
+
th: th,
|
|
851
|
+
parent: null,
|
|
852
|
+
children: [],
|
|
853
|
+
descendants: 0,
|
|
854
|
+
leaves: 0,
|
|
855
|
+
key: key,
|
|
856
|
+
flatKey: key.join(delim)
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
headers.push(node);
|
|
860
|
+
rMark[c] = node;
|
|
861
|
+
repeats = false;
|
|
862
|
+
r = lastRow;
|
|
863
|
+
break;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(keysArr[r][c]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, r, c)));
|
|
868
|
+
++nodePos;
|
|
869
|
+
node = {
|
|
870
|
+
node: nodePos,
|
|
871
|
+
row: r,
|
|
872
|
+
col: c,
|
|
873
|
+
th: th,
|
|
874
|
+
parent: null,
|
|
875
|
+
children: [],
|
|
876
|
+
descendants: 0,
|
|
877
|
+
leaves: 0,
|
|
878
|
+
key: key,
|
|
879
|
+
flatKey: key.join(delim)
|
|
880
|
+
};
|
|
881
|
+
if (c === 0) {
|
|
882
|
+
headers.push(node);
|
|
883
|
+
} else {
|
|
884
|
+
node.parent = rMark[c - 1];
|
|
885
|
+
rMark[c - 1].children.push(node);
|
|
886
|
+
x = 0;
|
|
887
|
+
while (x <= c - 1) {
|
|
888
|
+
++rMark[x].descendants;
|
|
889
|
+
++x;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
rMark[c] = node;
|
|
893
|
+
repeats = false;
|
|
894
|
+
++c;
|
|
895
|
+
}
|
|
896
|
+
for (c = k = 0, ref8 = lastCol; 0 <= ref8 ? k <= ref8 : k >= ref8; c = 0 <= ref8 ? ++k : --k) {
|
|
897
|
+
++rMark[c].leaves;
|
|
898
|
+
}
|
|
899
|
+
rMark[lastCol].leaves = 0;
|
|
900
|
+
++r;
|
|
901
|
+
}
|
|
902
|
+
return headers;
|
|
903
|
+
};
|
|
904
|
+
buildColHeaderHeader = function(thead, colHeaderHeaders, rowAttrs, colAttrs, tr, col) {
|
|
905
|
+
var className, colAttr, textContent, th, clickStatus;
|
|
906
|
+
colAttr = colAttrs[col];
|
|
907
|
+
textContent = opts.labelsConvertFunction(colAttr);
|
|
908
|
+
className = "pvtAxisLabel" + axisFreezePaneClass;
|
|
909
|
+
if (col < colAttrs.length - 1) {
|
|
910
|
+
if (!(isColDisableExpandCollapse || isColDisable || col > colDisableAfter)) {
|
|
911
|
+
if(opts.collapseColsAt == 0){
|
|
912
|
+
clickStatus = clickStatusCollapsed;
|
|
913
|
+
className += " "+classCollapsed;
|
|
914
|
+
textContent = " " + arrowCollapsed + " " + textContent;
|
|
915
|
+
}
|
|
916
|
+
else{
|
|
917
|
+
clickStatus = clickStatusExpanded;
|
|
918
|
+
className += " "+classExpanded;
|
|
919
|
+
textContent = " " + arrowExpanded + " " + textContent;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
th = createElement("th", className, textContent);
|
|
924
|
+
th.setAttribute("data-colAttr", colAttr);
|
|
925
|
+
//getHeaderColorProperties(th, col);
|
|
926
|
+
tr.appendChild(th);
|
|
927
|
+
colHeaderHeaders.push({
|
|
928
|
+
tr: tr,
|
|
929
|
+
th: th,
|
|
930
|
+
clickStatus: clickStatus,
|
|
931
|
+
expandedCount: 0,
|
|
932
|
+
nHeaders: 0
|
|
933
|
+
});
|
|
934
|
+
return thead.appendChild(tr);
|
|
935
|
+
};
|
|
936
|
+
buildColHeaderHeaders = function(thead, colHeaderHeaders, rowAttrs, colAttrs) {
|
|
937
|
+
var c, k, ref8, results, tr, rowSpan;
|
|
938
|
+
tr = createElement("tr");
|
|
939
|
+
if (rowAttrs.length !== 0) {
|
|
940
|
+
if(opts.chartOptions.table_options.colorize_headers == true){
|
|
941
|
+
rowSpan = 1;
|
|
942
|
+
}
|
|
943
|
+
else{
|
|
944
|
+
rowSpan = colAttrs.length;
|
|
945
|
+
}
|
|
946
|
+
tr.appendChild(createElement("th", axisFreezePaneClass, null, {
|
|
947
|
+
colspan: rowAttrs.length,
|
|
948
|
+
rowspan: rowSpan
|
|
949
|
+
}));
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
buildColHeaderHeader(thead, colHeaderHeaders, rowAttrs, colAttrs, tr, 0);
|
|
953
|
+
getHeaderColorProperties(tr);
|
|
954
|
+
results = [];
|
|
955
|
+
for (c = k = 1, ref8 = colAttrs.length; 1 <= ref8 ? k <= ref8 : k >= ref8; c = 1 <= ref8 ? ++k : --k) {
|
|
956
|
+
if (!(c < colAttrs.length)) {
|
|
957
|
+
continue;
|
|
958
|
+
}
|
|
959
|
+
tr = createElement("tr");
|
|
960
|
+
if (opts.chartOptions.table_options.colorize_headers == true && rowAttrs.length !== 0) {
|
|
961
|
+
tr.appendChild(createElement("th", axisFreezePaneClass, null, {
|
|
962
|
+
colspan: rowAttrs.length
|
|
963
|
+
}));
|
|
964
|
+
}
|
|
965
|
+
getHeaderColorProperties(tr, c);
|
|
966
|
+
results.push(buildColHeaderHeader(thead, colHeaderHeaders, rowAttrs, colAttrs, tr, c));
|
|
967
|
+
}
|
|
968
|
+
return results;
|
|
969
|
+
};
|
|
970
|
+
buildColHeaderHeadersClickEvents = function(colHeaderHeaders, colHeaderCols, colAttrs) {
|
|
971
|
+
var colAttr, i, k, n, ref8, results, th;
|
|
972
|
+
n = colAttrs.length - 1;
|
|
973
|
+
results = [];
|
|
974
|
+
for (i = k = 0, ref8 = n; 0 <= ref8 ? k <= ref8 : k >= ref8; i = 0 <= ref8 ? ++k : --k) {
|
|
975
|
+
if (!(i < n)) {
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
th = colHeaderHeaders[i].th;
|
|
979
|
+
colAttr = colAttrs[i];
|
|
980
|
+
results.push(th.onclick = function(event) {
|
|
981
|
+
event = event || window.event;
|
|
982
|
+
if(!event.currentTarget)
|
|
983
|
+
event.currentTarget = event.target;
|
|
984
|
+
return toggleColHeaderHeader(colHeaderHeaders, colHeaderCols, colAttrs, event.currentTarget.getAttribute("data-colAttr"));
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
return results;
|
|
988
|
+
};
|
|
989
|
+
buildColHeaders = function(colHeaderHeaders, colHeaderCols, colHeader, rowAttrs, colAttrs) {
|
|
990
|
+
var colspan, h, hh, isColSubtotal, k, len, ref8, rowspan, sTh, style, th, tr;
|
|
991
|
+
ref8 = colHeader.children;
|
|
992
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
993
|
+
h = ref8[k];
|
|
994
|
+
buildColHeaders(colHeaderHeaders, colHeaderCols, h, rowAttrs, colAttrs);
|
|
995
|
+
}
|
|
996
|
+
isColSubtotal = colHeader.children.length !== 0;
|
|
997
|
+
colHeader.node = colHeaderCols.length;
|
|
998
|
+
hh = colHeaderHeaders[colHeader.col];
|
|
999
|
+
++hh.expandedCount;
|
|
1000
|
+
++hh.nHeaders;
|
|
1001
|
+
tr = hh.tr;
|
|
1002
|
+
th = colHeader.th;
|
|
1003
|
+
addClass(th, "col" + colHeader.row + " colcol" + colHeader.col + " " + classColShow + verticalFreezePaneClass);
|
|
1004
|
+
//getHeaderColorProperties(th, colHeader.col);
|
|
1005
|
+
if (isColHideOnExpand || isColDisable || (isColSubtotal && colHeader.col > colDisableAfter)) {
|
|
1006
|
+
colspan = colHeader.leaves;
|
|
1007
|
+
} else if (isColSubtotal && colHeader.col <= colDisableAfter) {
|
|
1008
|
+
colspan = colHeader.leaves + 1;
|
|
1009
|
+
} else {
|
|
1010
|
+
colspan = colHeader.descendants + 1;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
if(th.getAttribute('data_show_more') == '1'){
|
|
1014
|
+
rowspan = colAttrs.length + 1;
|
|
1015
|
+
addClass(th, 'show_more_header');
|
|
1016
|
+
th.onclick = opts.show_more_function_cols;
|
|
1017
|
+
}
|
|
1018
|
+
else{
|
|
1019
|
+
rowspan = colHeader.col === colAttrs.length - 1 && rowAttrs.length !== 0 ? 2 : 1;
|
|
1020
|
+
}
|
|
1021
|
+
setAttributes(th, {
|
|
1022
|
+
"rowspan": rowspan,
|
|
1023
|
+
"colspan": colspan,
|
|
1024
|
+
"data-colnode": colHeader.node,
|
|
1025
|
+
"data-colHeader": th.textContent
|
|
1026
|
+
});
|
|
1027
|
+
if (isColSubtotal) {
|
|
1028
|
+
addClass(th, classColExpanded);
|
|
1029
|
+
if (!(isColDisableExpandCollapse || isColDisable || colHeader.col > colDisableAfter)) {
|
|
1030
|
+
th.innerHTML = " " + arrowExpanded + " " + th.textContent;
|
|
1031
|
+
}
|
|
1032
|
+
th.onclick = function(event) {
|
|
1033
|
+
event = event || window.event;
|
|
1034
|
+
return toggleCol(colHeaderHeaders, colHeaderCols, parseInt(event.currentTarget.getAttribute("data-colnode")));
|
|
1035
|
+
};
|
|
1036
|
+
rowspan = colAttrs.length - (colHeader.col + 1) + (rowAttrs.length !== 0 ? 1 : 0);
|
|
1037
|
+
style = "pvtColLabel pvtColSubtotal " + classColExpanded + verticalFreezePaneClass;
|
|
1038
|
+
style += " col" + colHeader.row + " colcol" + colHeader.col;
|
|
1039
|
+
if (isColHideOnExpand || isColDisable || colHeader.col > colDisableAfter) {
|
|
1040
|
+
style += " " + classColHide;
|
|
1041
|
+
}
|
|
1042
|
+
sTh = createElement("th", style, opts.localeStrings.subtotals, {
|
|
1043
|
+
"rowspan": rowspan,
|
|
1044
|
+
"data-colnode": colHeader.node
|
|
1045
|
+
});
|
|
1046
|
+
addClass(sTh, isColHideOnExpand || isColDisable ? " " + classColHide : " " + classColShow);
|
|
1047
|
+
//getHeaderColorProperties(sTh, colHeader.col);
|
|
1048
|
+
if (isColHideOnExpand || isColDisable || colHeader.col > colDisableAfter) {
|
|
1049
|
+
sTh.style.display = "none";
|
|
1050
|
+
}
|
|
1051
|
+
colHeader.children[0].tr.appendChild(sTh);
|
|
1052
|
+
colHeader.sTh = sTh;
|
|
1053
|
+
}
|
|
1054
|
+
colHeader.clickStatus = clickStatusExpanded;
|
|
1055
|
+
tr.appendChild(th);
|
|
1056
|
+
if (opts.chartOptions.table_options.freeze_panes) {
|
|
1057
|
+
getHeaderColorProperties(tr);
|
|
1058
|
+
}
|
|
1059
|
+
colHeader.tr = tr;
|
|
1060
|
+
return colHeaderCols.push(colHeader);
|
|
1061
|
+
};
|
|
1062
|
+
buildRowHeaderHeaders = function(thead, rowHeaderHeaders, rowAttrs, colAttrs) {
|
|
1063
|
+
var className, i, rowAttr, textContent, th, tr, clickStatus;
|
|
1064
|
+
tr = createElement("tr");
|
|
1065
|
+
rowHeaderHeaders.hh = [];
|
|
1066
|
+
for (i in rowAttrs) {
|
|
1067
|
+
if (!hasProp.call(rowAttrs, i)) continue;
|
|
1068
|
+
rowAttr = rowAttrs[i];
|
|
1069
|
+
textContent = opts.labelsConvertFunction(rowAttr);
|
|
1070
|
+
className = "pvtAxisLabel" + axisFreezePaneClass;
|
|
1071
|
+
if (i < rowAttrs.length - 1) {
|
|
1072
|
+
className += " expanded";
|
|
1073
|
+
if (!(isRowDisableExpandCollapse || isRowDisable || i > rowDisableAfter)) {
|
|
1074
|
+
if(opts.collapseRowsAt == 0){
|
|
1075
|
+
clickStatus = clickStatusCollapsed;
|
|
1076
|
+
className += " "+classCollapsed;
|
|
1077
|
+
textContent = " " + arrowCollapsed + " " + textContent;
|
|
1078
|
+
}
|
|
1079
|
+
else{
|
|
1080
|
+
clickStatus = clickStatusExpanded;
|
|
1081
|
+
className += " "+classExpanded;
|
|
1082
|
+
textContent = " " + arrowExpanded + " " + textContent;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
th = createElement("th", className, textContent);
|
|
1087
|
+
th.setAttribute("data-rowAttr", rowAttr);
|
|
1088
|
+
tr.appendChild(th);
|
|
1089
|
+
rowHeaderHeaders.hh.push({
|
|
1090
|
+
th: th,
|
|
1091
|
+
clickStatus: clickStatus,
|
|
1092
|
+
expandedCount: 0,
|
|
1093
|
+
nHeaders: 0
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
if (colAttrs.length !== 0) {
|
|
1097
|
+
th = createElement("th", axisFreezePaneClass);
|
|
1098
|
+
tr.appendChild(th);
|
|
1099
|
+
}
|
|
1100
|
+
colorizeRowLabelHeaders(tr, colAttrs.length);
|
|
1101
|
+
thead.appendChild(tr);
|
|
1102
|
+
return rowHeaderHeaders.tr = tr;
|
|
1103
|
+
};
|
|
1104
|
+
buildRowHeaderHeadersClickEvents = function(rowHeaderHeaders, rowHeaderRows, rowAttrs) {
|
|
1105
|
+
var i, k, n, ref8, results, rowAttr, th;
|
|
1106
|
+
n = rowAttrs.length - 1;
|
|
1107
|
+
results = [];
|
|
1108
|
+
for (i = k = 0, ref8 = n; 0 <= ref8 ? k <= ref8 : k >= ref8; i = 0 <= ref8 ? ++k : --k) {
|
|
1109
|
+
if (!(i < n)) {
|
|
1110
|
+
continue;
|
|
1111
|
+
}
|
|
1112
|
+
th = rowHeaderHeaders.hh[i];
|
|
1113
|
+
rowAttr = rowAttrs[i];
|
|
1114
|
+
results.push(th.th.onclick = function(event) {
|
|
1115
|
+
event = event || window.event;
|
|
1116
|
+
if(!event.currentTarget)
|
|
1117
|
+
event.currentTarget = event.target;
|
|
1118
|
+
return toggleRowHeaderHeader(rowHeaderHeaders, rowHeaderRows, rowAttrs, event.currentTarget.getAttribute("data-rowAttr"));
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
return results;
|
|
1122
|
+
};
|
|
1123
|
+
buildRowTotalsHeader = function(tr, rowAttrs, colAttrs) {
|
|
1124
|
+
var rowspan, th;
|
|
1125
|
+
rowspan = 1;
|
|
1126
|
+
if (colAttrs.length !== 0) {
|
|
1127
|
+
rowspan = colAttrs.length + (rowAttrs.length === 0 ? 0 : 1);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
if(opts.chartOptions.table_options.colorize_headers == true && colAttrs.length > 1){
|
|
1131
|
+
rowspan = 1;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
th = createElement("th", "pvtTotalLabel rowTotal" + verticalFreezePaneClass , opts.localeStrings.totals, {
|
|
1135
|
+
rowspan: rowspan
|
|
1136
|
+
});
|
|
1137
|
+
|
|
1138
|
+
if (opts.totalFilterElements && opts.totalFilterElements.row_total) {
|
|
1139
|
+
th.innerHTML = '';
|
|
1140
|
+
th.appendChild(opts.totalFilterElements.row_total);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
//getHeaderColorProperties(th);
|
|
1144
|
+
if (opts.chartOptions.table_options.freeze_panes) {
|
|
1145
|
+
tr.appendChild(th);
|
|
1146
|
+
getHeaderColorProperties(tr);
|
|
1147
|
+
} else {
|
|
1148
|
+
return tr.appendChild(th);
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
buildRowHeaders = function(tbody, rowHeaderHeaders, rowHeaderRows, rowHeader, rowAttrs, colAttrs, highlighted, hasColLabels) {
|
|
1152
|
+
var colspan, h, hh, isRowSubtotal, k, len, ref8, results, style, th, tr;
|
|
1153
|
+
hh = rowHeaderHeaders.hh[rowHeader.col];
|
|
1154
|
+
++hh.expandedCount;
|
|
1155
|
+
++hh.nHeaders;
|
|
1156
|
+
tr = createElement("tr", "pvtRowSubtotal row" + rowHeader.row, "", {
|
|
1157
|
+
"data-rownode": rowHeader.node
|
|
1158
|
+
});
|
|
1159
|
+
th = rowHeader.th;
|
|
1160
|
+
|
|
1161
|
+
if(th.getAttribute('data_show_more') == '1'){
|
|
1162
|
+
colspan = rowAttrs.length + 1;
|
|
1163
|
+
addClass(th, 'show_more_header');
|
|
1164
|
+
th.onclick = opts.show_more_function_rows;
|
|
1165
|
+
}
|
|
1166
|
+
else{
|
|
1167
|
+
colspan = rowHeader.col === rowAttrs.length - 1 && colAttrs.length !== 0 ? 2 : 1;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
isRowSubtotal = rowHeader.children.length !== 0;
|
|
1171
|
+
addClass(th, "row" + rowHeader.row + " rowcol" + rowHeader.col + " " + classRowShow + horizontalFreezePaneClass);
|
|
1172
|
+
if (highlighted) {
|
|
1173
|
+
addClass(th, "highlighted");
|
|
1174
|
+
}
|
|
1175
|
+
setAttributes(th, {
|
|
1176
|
+
"data-rowHeader": th.textContent,
|
|
1177
|
+
"data-rownode": rowHeader.node,
|
|
1178
|
+
"rowspan": rowHeader.descendants + 1,
|
|
1179
|
+
"colspan": colspan
|
|
1180
|
+
});
|
|
1181
|
+
if (opts.chartOptions.table_options.hide_nulls_in_headers) {
|
|
1182
|
+
th.textContent = th.textContent.replace('[null]', '');
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
if (th.hasAttribute('data_show_more') && th.colSpan > 0 && !hasColLabels) {
|
|
1186
|
+
th.colSpan = th.colSpan - 1;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
tr.appendChild(th);
|
|
1190
|
+
if (isRowSubtotal) {
|
|
1191
|
+
addClass(tr, classRowExpanded);
|
|
1192
|
+
addClass(th, classRowExpanded);
|
|
1193
|
+
if (!(isRowDisableExpandCollapse || isRowDisable || rowHeader.col > rowDisableAfter)) {
|
|
1194
|
+
th.innerHTML = " " + arrowExpanded + " " + th.textContent;
|
|
1195
|
+
}
|
|
1196
|
+
th.onclick = function(event) {
|
|
1197
|
+
event = event || window.event;
|
|
1198
|
+
return toggleRow(rowHeaderHeaders, rowHeaderRows, parseInt(event.currentTarget.getAttribute("data-rownode")));
|
|
1199
|
+
};
|
|
1200
|
+
colspan = rowAttrs.length - (rowHeader.col + 1) + (colAttrs.length !== 0 ? 1 : 0);
|
|
1201
|
+
style = "pvtRowLabel pvtRowSubtotal " + classRowExpanded;
|
|
1202
|
+
style += " row" + rowHeader.row + " rowcol" + rowHeader.col;
|
|
1203
|
+
style += isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter ? " " + classRowHide : " " + classRowShow;
|
|
1204
|
+
style += horizontalFreezePaneClass;
|
|
1205
|
+
th = createElement("th", style, opts.localeStrings.subtotals, {
|
|
1206
|
+
"colspan": colspan,
|
|
1207
|
+
"data-rownode": rowHeader.node
|
|
1208
|
+
});
|
|
1209
|
+
if (isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter) {
|
|
1210
|
+
th.style.display = "none";
|
|
1211
|
+
}
|
|
1212
|
+
tr.appendChild(th);
|
|
1213
|
+
}
|
|
1214
|
+
rowHeader.clickStatus = clickStatusExpanded;
|
|
1215
|
+
rowHeader.tr = tr;
|
|
1216
|
+
rowHeaderRows.push(rowHeader);
|
|
1217
|
+
tbody.appendChild(tr);
|
|
1218
|
+
ref8 = rowHeader.children;
|
|
1219
|
+
results = [];
|
|
1220
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1221
|
+
h = ref8[k];
|
|
1222
|
+
results.push(buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, highlighted, hasColLabels));
|
|
1223
|
+
}
|
|
1224
|
+
return results;
|
|
1225
|
+
};
|
|
1226
|
+
buildValues = function(rowHeaderRows, colHeaderCols, rowAttrs, colAttrs) {
|
|
1227
|
+
var aggregator, colHeader, eventHandlers, flatColKey, flatRowKey, isColSubtotal, isRowSubtotal, k, l, len, len1, ref8, results, rowHeader, style, td, totalAggregator, tr, val;
|
|
1228
|
+
results = [];
|
|
1229
|
+
for (k = 0, len = rowHeaderRows.length; k < len; k++) {
|
|
1230
|
+
rowHeader = rowHeaderRows[k];
|
|
1231
|
+
tr = rowHeader.tr;
|
|
1232
|
+
flatRowKey = rowHeader.flatKey;
|
|
1233
|
+
isRowSubtotal = rowHeader.children.length !== 0;
|
|
1234
|
+
for (l = 0, len1 = colHeaderCols.length; l < len1; l++) {
|
|
1235
|
+
colHeader = colHeaderCols[l];
|
|
1236
|
+
flatColKey = colHeader.flatKey;
|
|
1237
|
+
if(tree && tree[flatRowKey] && tree[flatRowKey][flatColKey]){
|
|
1238
|
+
ref8 = tree[flatRowKey][flatColKey]
|
|
1239
|
+
}
|
|
1240
|
+
else{
|
|
1241
|
+
ref8 = null;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
aggregator = ref8 != null ? ref8 : {
|
|
1245
|
+
value: (function() {
|
|
1246
|
+
return null;
|
|
1247
|
+
}),
|
|
1248
|
+
format: function() {
|
|
1249
|
+
return "";
|
|
1250
|
+
}
|
|
1251
|
+
};
|
|
1252
|
+
val = aggregator.value();
|
|
1253
|
+
isColSubtotal = colHeader.children.length !== 0;
|
|
1254
|
+
style = "pvtVal";
|
|
1255
|
+
if (isColSubtotal) {
|
|
1256
|
+
style += " pvtColSubtotal " + classColExpanded;
|
|
1257
|
+
}
|
|
1258
|
+
if (isRowSubtotal) {
|
|
1259
|
+
style += " pvtRowSubtotal " + classRowExpanded;
|
|
1260
|
+
}
|
|
1261
|
+
style += isRowSubtotal && (isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter) ? " " + classRowHide : " " + classRowShow;
|
|
1262
|
+
style += isColSubtotal && (isColHideOnExpand || isColDisable || colHeader.col > colDisableAfter) ? " " + classColHide : " " + classColShow;
|
|
1263
|
+
style += (" row" + rowHeader.row) + (" col" + colHeader.row) + (" rowcol" + rowHeader.col) + (" colcol" + colHeader.col);
|
|
1264
|
+
eventHandlers = getTableEventHandlers(val, rowHeader.key, colHeader.key);
|
|
1265
|
+
td = createElement("td", style, getFormattedNumber(val, aggregator, opts), {
|
|
1266
|
+
"data-value": val,
|
|
1267
|
+
"data-rownode": rowHeader.node,
|
|
1268
|
+
"data-colnode": colHeader.node
|
|
1269
|
+
}, eventHandlers);
|
|
1270
|
+
if ((isRowSubtotal && (isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter)) || (isColSubtotal && (isColHideOnExpand || isColDisable || colHeader.col > colDisableAfter))) {
|
|
1271
|
+
td.style.display = "none";
|
|
1272
|
+
}
|
|
1273
|
+
assumptionSubscribe(td, rowHeader, rowAttrs, colHeader, colAttrs, val);
|
|
1274
|
+
|
|
1275
|
+
tr.appendChild(td);
|
|
1276
|
+
}
|
|
1277
|
+
totalAggregator = rowTotals[flatRowKey];
|
|
1278
|
+
if(!totalAggregator){
|
|
1279
|
+
totalAggregator = {
|
|
1280
|
+
value: (function () {
|
|
1281
|
+
return null;
|
|
1282
|
+
}),
|
|
1283
|
+
format: function () {
|
|
1284
|
+
return "";
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
val = totalAggregator.value();
|
|
1290
|
+
style = "pvtTotal rowTotal";
|
|
1291
|
+
if (isRowSubtotal) {
|
|
1292
|
+
style += " pvtRowSubtotal";
|
|
1293
|
+
}
|
|
1294
|
+
style += isRowSubtotal && (isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter) ? " " + classRowHide : " " + classRowShow;
|
|
1295
|
+
style += " row" + rowHeader.row + " rowcol" + rowHeader.col;
|
|
1296
|
+
td = createElement("td", style, getFormattedNumber(val, totalAggregator, opts), {
|
|
1297
|
+
"data-value": val,
|
|
1298
|
+
"data-row": "row" + rowHeader.row,
|
|
1299
|
+
"data-rowcol": "col" + rowHeader.col,
|
|
1300
|
+
"data-rownode": rowHeader.node
|
|
1301
|
+
}, getTableEventHandlers(val, rowHeader.key, []));
|
|
1302
|
+
if (isRowSubtotal && (isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter)) {
|
|
1303
|
+
td.style.display = "none";
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
assumptionSubscribe(td, rowHeader, rowAttrs, {key:[], flatKey:''}, colAttrs, val);
|
|
1307
|
+
|
|
1308
|
+
if(opts.chartOptions.table_options.show_row_total)
|
|
1309
|
+
tr.appendChild(td);
|
|
1310
|
+
|
|
1311
|
+
results.push(tr);
|
|
1312
|
+
}
|
|
1313
|
+
return results;
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
assumptionSubscribe = function(td, rowHeader, rowAttrs, colHeader, colAttrs, val){
|
|
1317
|
+
if(edit_assumptions){
|
|
1318
|
+
var filters = [];
|
|
1319
|
+
var i=0;
|
|
1320
|
+
var temp;
|
|
1321
|
+
for(i=0; i<rowHeader.key.length; i++){
|
|
1322
|
+
temp = {
|
|
1323
|
+
name: rowAttrs[i],
|
|
1324
|
+
values: [rowHeader.key[i]],
|
|
1325
|
+
is_excluded:false
|
|
1326
|
+
}
|
|
1327
|
+
filters.push(temp);
|
|
1328
|
+
}
|
|
1329
|
+
for(i=0; i<colHeader.key.length; i++){
|
|
1330
|
+
temp = {
|
|
1331
|
+
name: colAttrs[i],
|
|
1332
|
+
values: [colHeader.key[i]],
|
|
1333
|
+
is_excluded:false
|
|
1334
|
+
}
|
|
1335
|
+
filters.push(temp);
|
|
1336
|
+
}
|
|
1337
|
+
var obj_to_send = {
|
|
1338
|
+
"flatColKey": colHeader.flatKey,
|
|
1339
|
+
"flatRowKey": rowHeader.flatKey,
|
|
1340
|
+
"val": val,
|
|
1341
|
+
"filters": filters
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
// td.addEventListener('dblclick', function(){
|
|
1345
|
+
// edit_assumptions.fn(obj_to_send, this);
|
|
1346
|
+
// });
|
|
1347
|
+
|
|
1348
|
+
td.addEventListener('click', function(){
|
|
1349
|
+
edit_assumptions.fn(obj_to_send, this);
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
if(opts.value_drill_down_fn){
|
|
1354
|
+
td.classList.add('clickable');
|
|
1355
|
+
td.addEventListener('click', function(rowKey, colKey, rowAttrs, colAttrs){
|
|
1356
|
+
return function($event){
|
|
1357
|
+
$event.preventDefault();
|
|
1358
|
+
opts.value_drill_down_fn($event, rowKey, colKey);
|
|
1359
|
+
};
|
|
1360
|
+
}(rowHeader.key, colHeader.key, rowAttrs, colAttrs));
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
buildColTotalsHeader = function(rowAttrs, colAttrs) {
|
|
1365
|
+
var colspan, th, tr;
|
|
1366
|
+
tr = createElement("tr");
|
|
1367
|
+
colspan = rowAttrs.length + (colAttrs.length === 0 ? 0 : 1);
|
|
1368
|
+
th = createElement("th", "pvtTotalLabel colTotal" + horizontalFreezePaneClass, opts.localeStrings.totals, {
|
|
1369
|
+
colspan: colspan
|
|
1370
|
+
});
|
|
1371
|
+
if (opts.totalFilterElements && opts.totalFilterElements.col_total) {
|
|
1372
|
+
th.innerHTML = '';
|
|
1373
|
+
th.appendChild(opts.totalFilterElements.col_total);
|
|
1374
|
+
}
|
|
1375
|
+
tr.appendChild(th);
|
|
1376
|
+
return tr;
|
|
1377
|
+
};
|
|
1378
|
+
buildColTotals = function(tr, colHeaderCols, rowAttrs, colAttrs) {
|
|
1379
|
+
var h, isColSubtotal, k, len, results, style, td, totalAggregator, val;
|
|
1380
|
+
results = [];
|
|
1381
|
+
for (k = 0, len = colHeaderCols.length; k < len; k++) {
|
|
1382
|
+
h = colHeaderCols[k];
|
|
1383
|
+
isColSubtotal = h.children.length !== 0;
|
|
1384
|
+
totalAggregator = colTotals[h.flatKey];
|
|
1385
|
+
if(!totalAggregator){
|
|
1386
|
+
totalAggregator = {
|
|
1387
|
+
value: (function () {
|
|
1388
|
+
return null;
|
|
1389
|
+
}),
|
|
1390
|
+
format: function () {
|
|
1391
|
+
return "";
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
val = totalAggregator.value();
|
|
1396
|
+
style = "pvtVal pvtTotal colTotal";
|
|
1397
|
+
if (isColSubtotal) {
|
|
1398
|
+
style += " pvtColSubtotal";
|
|
1399
|
+
}
|
|
1400
|
+
style += " " + classColExpanded;
|
|
1401
|
+
style += " col" + h.row + " colcol" + h.col;
|
|
1402
|
+
td = createElement("td", style, getFormattedNumber(val, totalAggregator, opts), {
|
|
1403
|
+
"data-value": val,
|
|
1404
|
+
"data-for": "col" + h.col,
|
|
1405
|
+
"data-colnode": "" + h.node
|
|
1406
|
+
}, getTableEventHandlers(val, [], h.key));
|
|
1407
|
+
createTotalValsBolder(td)
|
|
1408
|
+
if (isColSubtotal && (isColHideOnExpand || isColDisable || h.col > colDisableAfter)) {
|
|
1409
|
+
td.style.display = "none";
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
assumptionSubscribe(td, {key:[], flatKey:''}, rowAttrs, h, colAttrs, val);
|
|
1413
|
+
|
|
1414
|
+
results.push(tr.appendChild(td));
|
|
1415
|
+
}
|
|
1416
|
+
createGrandTotalBolder(tr);
|
|
1417
|
+
return results;
|
|
1418
|
+
};
|
|
1419
|
+
buildGrandTotal = function(result, tr, rowAttrs, colAttrs) {
|
|
1420
|
+
var td, totalAggregator, val;
|
|
1421
|
+
totalAggregator = allTotal;
|
|
1422
|
+
val = totalAggregator.value();
|
|
1423
|
+
td = createElement("td", "pvtGrandTotal", getFormattedNumber(val, totalAggregator, opts), {
|
|
1424
|
+
"data-value": val
|
|
1425
|
+
}, getTableEventHandlers(val, [], []));
|
|
1426
|
+
createTotalValsBolder(td);
|
|
1427
|
+
assumptionSubscribe(td, {key:[], flatKey:''}, rowAttrs, {key:[], flatKey:''}, colAttrs, val);
|
|
1428
|
+
|
|
1429
|
+
tr.appendChild(td);
|
|
1430
|
+
return result.appendChild(tr);
|
|
1431
|
+
};
|
|
1432
|
+
removeRowHeaderNullValue = function(h) {
|
|
1433
|
+
if (opts.chartOptions.table_options.hide_nulls_in_headers) {
|
|
1434
|
+
h.th.innerHTML = h.th.innerHTML.replace('[null]' , '');
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
hideDescendantCol = function(d) {
|
|
1438
|
+
return $(d.th).closest('table.pvtTable').find("tbody tr td[data-colnode=\"" + d.node + "\"], th[data-colnode=\"" + d.node + "\"]").removeClass(classColShow).addClass(classColHide).css('display', "none");
|
|
1439
|
+
};
|
|
1440
|
+
collapseShowColSubtotal = function(h) {
|
|
1441
|
+
$(h.th).closest('table.pvtTable').find("tbody tr td[data-colnode=\"" + h.node + "\"], th[data-colnode=\"" + h.node + "\"]").removeClass(classColExpanded + " " + classColHide).addClass(classColCollapsed + " " + classColShow).not(".pvtRowSubtotal." + classRowHide).css('display', "");
|
|
1442
|
+
h.th.innerHTML = " " + arrowCollapsed + " " + h.th.getAttribute("data-colheader");
|
|
1443
|
+
return h.th.colSpan = 1;
|
|
1444
|
+
};
|
|
1445
|
+
collapseCol = function(colHeaderHeaders, colHeaderCols, c) {
|
|
1446
|
+
var colHeaderHeader, colspan, d, h, i, isColSubtotal, k, l, p, ref10, ref8, ref9, results;
|
|
1447
|
+
if (isColDisable) {
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
if (isColDisableExpandCollapse) {
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
if (!colHeaderCols[c]) {
|
|
1454
|
+
return;
|
|
1455
|
+
}
|
|
1456
|
+
h = colHeaderCols[c];
|
|
1457
|
+
if (h.col > colDisableAfter) {
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
if (h.clickStatus === clickStatusCollapsed) {
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
isColSubtotal = h.descendants !== 0;
|
|
1464
|
+
colspan = h.th.colSpan;
|
|
1465
|
+
for (i = k = 1, ref8 = h.descendants; 1 <= ref8 ? k <= ref8 : k >= ref8; i = 1 <= ref8 ? ++k : --k) {
|
|
1466
|
+
if (!(h.descendants !== 0)) {
|
|
1467
|
+
continue;
|
|
1468
|
+
}
|
|
1469
|
+
d = colHeaderCols[c - i];
|
|
1470
|
+
hideDescendantCol(d);
|
|
1471
|
+
}
|
|
1472
|
+
if (isColSubtotal) {
|
|
1473
|
+
collapseShowColSubtotal(h);
|
|
1474
|
+
--colspan;
|
|
1475
|
+
}
|
|
1476
|
+
p = h.parent;
|
|
1477
|
+
while (p !== null) {
|
|
1478
|
+
p.th.colSpan -= colspan;
|
|
1479
|
+
p = p.parent;
|
|
1480
|
+
}
|
|
1481
|
+
h.clickStatus = clickStatusCollapsed;
|
|
1482
|
+
colHeaderHeader = colHeaderHeaders[h.col];
|
|
1483
|
+
colHeaderHeader.expandedCount--;
|
|
1484
|
+
if (colHeaderHeader.expandedCount === 0) {
|
|
1485
|
+
results = [];
|
|
1486
|
+
for (i = l = ref9 = h.col, ref10 = colHeaderHeaders.length - 2; ref9 <= ref10 ? l <= ref10 : l >= ref10; i = ref9 <= ref10 ? ++l : --l) {
|
|
1487
|
+
if (!(i <= colDisableAfter)) {
|
|
1488
|
+
continue;
|
|
1489
|
+
}
|
|
1490
|
+
colHeaderHeader = colHeaderHeaders[i];
|
|
1491
|
+
replaceClass(colHeaderHeader.th, classExpanded, classCollapsed);
|
|
1492
|
+
colHeaderHeader.th.innerHTML = " " + arrowCollapsed + " " + opts.labelsConvertFunction(colHeaderHeader.th.getAttribute("data-colAttr"));
|
|
1493
|
+
results.push(colHeaderHeader.clickStatus = clickStatusCollapsed);
|
|
1494
|
+
}
|
|
1495
|
+
return results;
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
showChildCol = function(ch) {
|
|
1499
|
+
return $(ch.th).closest('table.pvtTable').find("tbody tr td[data-colnode=\"" + ch.node + "\"], th[data-colnode=\"" + ch.node + "\"]").removeClass(classColHide).addClass(classColShow).not(".pvtRowSubtotal." + classRowHide).css('display', "");
|
|
1500
|
+
};
|
|
1501
|
+
expandHideColSubtotal = function(h) {
|
|
1502
|
+
$(h.th).closest('table.pvtTable').find("tbody tr td[data-colnode=\"" + h.node + "\"], th[data-colnode=\"" + h.node + "\"]").removeClass(classColCollapsed + " " + classColShow).addClass(classColExpanded + " " + classColHide).css('display', "none");
|
|
1503
|
+
return h.th.style.display = "";
|
|
1504
|
+
};
|
|
1505
|
+
expandShowColSubtotal = function(h) {
|
|
1506
|
+
$(h.th).closest('table.pvtTable').find("tbody tr td[data-colnode=\"" + h.node + "\"], th[data-colnode=\"" + h.node + "\"]").removeClass(classColCollapsed + " " + classColHide).addClass(classColExpanded + " " + classColShow).not(".pvtRowSubtotal." + classRowHide).css('display', "");
|
|
1507
|
+
h.th.style.display = "";
|
|
1508
|
+
++h.th.colSpan;
|
|
1509
|
+
if (h.sTh != null) {
|
|
1510
|
+
return h.sTh.style.display = "";
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
expandChildCol = function(ch) {
|
|
1514
|
+
var gch, k, len, ref8, results;
|
|
1515
|
+
if (ch.descendants !== 0 && hasClass(ch.th, classColExpanded) && (isColHideOnExpand || isColDisable || ch.col > colDisableAfter)) {
|
|
1516
|
+
ch.th.style.display = "";
|
|
1517
|
+
} else {
|
|
1518
|
+
showChildCol(ch);
|
|
1519
|
+
}
|
|
1520
|
+
if (ch.clickStatus !== clickStatusCollapsed) {
|
|
1521
|
+
ref8 = ch.children;
|
|
1522
|
+
results = [];
|
|
1523
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1524
|
+
gch = ref8[k];
|
|
1525
|
+
results.push(expandChildCol(gch));
|
|
1526
|
+
}
|
|
1527
|
+
return results;
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1530
|
+
expandCol = function(colHeaderHeaders, colHeaderCols, c) {
|
|
1531
|
+
var ch, colspan, h, hh, isColSubtotal, k, len, p, ref8;
|
|
1532
|
+
if (isColDisable) {
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
if (isColDisableExpandCollapse) {
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
if (!colHeaderCols[c]) {
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
h = colHeaderCols[c];
|
|
1542
|
+
if (h.col > colDisableAfter) {
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
if (h.clickStatus === clickStatusExpanded) {
|
|
1546
|
+
return;
|
|
1547
|
+
}
|
|
1548
|
+
isColSubtotal = h.descendants !== 0;
|
|
1549
|
+
colspan = 0;
|
|
1550
|
+
ref8 = h.children;
|
|
1551
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1552
|
+
ch = ref8[k];
|
|
1553
|
+
expandChildCol(ch);
|
|
1554
|
+
colspan += ch.th.colSpan;
|
|
1555
|
+
}
|
|
1556
|
+
h.th.colSpan = colspan;
|
|
1557
|
+
if (isColSubtotal) {
|
|
1558
|
+
replaceClass(h.th, classColCollapsed, classColExpanded);
|
|
1559
|
+
h.th.innerHTML = " " + arrowExpanded + " " + h.th.getAttribute("data-colHeader");
|
|
1560
|
+
if (isColHideOnExpand) {
|
|
1561
|
+
expandHideColSubtotal(h);
|
|
1562
|
+
--colspan;
|
|
1563
|
+
} else {
|
|
1564
|
+
expandShowColSubtotal(h);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
p = h.parent;
|
|
1568
|
+
while (p) {
|
|
1569
|
+
p.th.colSpan += colspan;
|
|
1570
|
+
p = p.parent;
|
|
1571
|
+
}
|
|
1572
|
+
h.clickStatus = clickStatusExpanded;
|
|
1573
|
+
hh = colHeaderHeaders[h.col];
|
|
1574
|
+
++hh.expandedCount;
|
|
1575
|
+
if (hh.expandedCount === hh.nHeaders) {
|
|
1576
|
+
replaceClass(hh.th, classCollapsed, classExpanded);
|
|
1577
|
+
hh.th.innerHTML = " " + arrowExpanded + " " + opts.labelsConvertFunction(hh.th.getAttribute("data-colAttr"));
|
|
1578
|
+
return hh.clickStatus = clickStatusExpanded;
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
collapseHideDescendantRow = function(h) {
|
|
1582
|
+
var cell, cells, k, len, ref8, results, tagName;
|
|
1583
|
+
h.tr.style.display = "none";
|
|
1584
|
+
ref8 = ["td", "th"];
|
|
1585
|
+
results = [];
|
|
1586
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1587
|
+
tagName = ref8[k];
|
|
1588
|
+
cells = h.tr.getElementsByTagName(tagName);
|
|
1589
|
+
results.push((function() {
|
|
1590
|
+
var l, len1, results1;
|
|
1591
|
+
results1 = [];
|
|
1592
|
+
for (l = 0, len1 = cells.length; l < len1; l++) {
|
|
1593
|
+
cell = cells[l];
|
|
1594
|
+
replaceClass(cell, classRowShow, classRowHide);
|
|
1595
|
+
results1.push(cell.style.display = "none");
|
|
1596
|
+
}
|
|
1597
|
+
return results1;
|
|
1598
|
+
})());
|
|
1599
|
+
}
|
|
1600
|
+
return results;
|
|
1601
|
+
};
|
|
1602
|
+
collapseShowRowSubtotal = function(h) {
|
|
1603
|
+
var cell, cells, k, l, len, len1, ref8, tagName;
|
|
1604
|
+
ref8 = ["td", "th"];
|
|
1605
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1606
|
+
tagName = ref8[k];
|
|
1607
|
+
cells = h.tr.getElementsByTagName(tagName);
|
|
1608
|
+
for (l = 0, len1 = cells.length; l < len1; l++) {
|
|
1609
|
+
cell = cells[l];
|
|
1610
|
+
removeClass(cell, classRowExpanded + " " + classRowHide);
|
|
1611
|
+
addClass(cell, classRowCollapsed + " " + classRowShow);
|
|
1612
|
+
if (!hasClass(cell, classColHide)) {
|
|
1613
|
+
cell.style.display = "";
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
h.th.rowSpan = 1;
|
|
1618
|
+
h.th.innerHTML = " " + arrowCollapsed + " " + h.th.getAttribute("data-rowHeader");
|
|
1619
|
+
return replaceClass(h.tr, classRowExpanded, classRowCollapsed);
|
|
1620
|
+
};
|
|
1621
|
+
collapseRow = function(rowHeaderHeaders, rowHeaderRows, r) {
|
|
1622
|
+
var d, h, i, isRowSubtotal, j, k, l, p, ref10, ref8, ref9, results, rowHeaderHeader, rowspan;
|
|
1623
|
+
if (isRowDisable) {
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
if (isRowDisableExpandCollapse) {
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
if (!rowHeaderRows[r]) {
|
|
1630
|
+
return;
|
|
1631
|
+
}
|
|
1632
|
+
h = rowHeaderRows[r];
|
|
1633
|
+
if (h.col > rowDisableAfter) {
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
if (h.clickStatus === clickStatusCollapsed) {
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1639
|
+
isRowSubtotal = h.descendants !== 0;
|
|
1640
|
+
rowspan = h.th.rowSpan;
|
|
1641
|
+
for (i = k = 1, ref8 = h.descendants; 1 <= ref8 ? k <= ref8 : k >= ref8; i = 1 <= ref8 ? ++k : --k) {
|
|
1642
|
+
if (!(h.descendants !== 0)) {
|
|
1643
|
+
continue;
|
|
1644
|
+
}
|
|
1645
|
+
d = rowHeaderRows[r + i];
|
|
1646
|
+
collapseHideDescendantRow(d);
|
|
1647
|
+
}
|
|
1648
|
+
if (isRowSubtotal) {
|
|
1649
|
+
collapseShowRowSubtotal(h);
|
|
1650
|
+
--rowspan;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
removeRowHeaderNullValue(h);
|
|
1654
|
+
|
|
1655
|
+
p = h.parent;
|
|
1656
|
+
while (p) {
|
|
1657
|
+
p.th.rowSpan -= rowspan;
|
|
1658
|
+
p = p.parent;
|
|
1659
|
+
}
|
|
1660
|
+
h.clickStatus = clickStatusCollapsed;
|
|
1661
|
+
rowHeaderHeader = rowHeaderHeaders.hh[h.col];
|
|
1662
|
+
rowHeaderHeader.expandedCount--;
|
|
1663
|
+
if (rowHeaderHeader.expandedCount !== 0) {
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
results = [];
|
|
1667
|
+
for (j = l = ref9 = h.col, ref10 = rowHeaderHeaders.hh.length - 2; ref9 <= ref10 ? l <= ref10 : l >= ref10; j = ref9 <= ref10 ? ++l : --l) {
|
|
1668
|
+
if (!(j <= rowDisableAfter)) {
|
|
1669
|
+
continue;
|
|
1670
|
+
}
|
|
1671
|
+
rowHeaderHeader = rowHeaderHeaders.hh[j];
|
|
1672
|
+
replaceClass(rowHeaderHeader.th, classExpanded, classCollapsed);
|
|
1673
|
+
rowHeaderHeader.th.innerHTML = " " + arrowCollapsed + " " + opts.labelsConvertFunction(rowHeaderHeader.th.getAttribute("data-rowAttr"));
|
|
1674
|
+
results.push(rowHeaderHeader.clickStatuatus = clickStatusCollapsed);
|
|
1675
|
+
}
|
|
1676
|
+
return results;
|
|
1677
|
+
};
|
|
1678
|
+
showChildRow = function(h) {
|
|
1679
|
+
var cell, cells, k, l, len, len1, ref8, tagName;
|
|
1680
|
+
ref8 = ["td", "th"];
|
|
1681
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1682
|
+
tagName = ref8[k];
|
|
1683
|
+
cells = h.tr.getElementsByTagName(tagName);
|
|
1684
|
+
for (l = 0, len1 = cells.length; l < len1; l++) {
|
|
1685
|
+
cell = cells[l];
|
|
1686
|
+
replaceClass(cell, classRowHide, classRowShow);
|
|
1687
|
+
if (!hasClass(cell, classColHide)) {
|
|
1688
|
+
cell.style.display = "";
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
return h.tr.style.display = "";
|
|
1693
|
+
};
|
|
1694
|
+
expandShowRowSubtotal = function(h) {
|
|
1695
|
+
var cell, cells, k, l, len, len1, ref8, tagName;
|
|
1696
|
+
ref8 = ["td", "th"];
|
|
1697
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1698
|
+
tagName = ref8[k];
|
|
1699
|
+
cells = h.tr.getElementsByTagName(tagName);
|
|
1700
|
+
for (l = 0, len1 = cells.length; l < len1; l++) {
|
|
1701
|
+
cell = cells[l];
|
|
1702
|
+
removeClass(cell, classRowCollapsed + " " + classRowHide);
|
|
1703
|
+
addClass(cell, classRowExpanded + " " + classRowShow);
|
|
1704
|
+
if (!hasClass(cell, classColHide)) {
|
|
1705
|
+
cell.style.display = "";
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
h.th.innerHTML = " " + arrowExpanded + " " + h.th.getAttribute("data-rowHeader");
|
|
1710
|
+
return replaceClass(h.tr, classRowCollapsed, classRowExpanded);
|
|
1711
|
+
};
|
|
1712
|
+
expandHideRowSubtotal = function(h) {
|
|
1713
|
+
var cell, cells, k, l, len, len1, ref8, tagName;
|
|
1714
|
+
ref8 = ["td", "th"];
|
|
1715
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1716
|
+
tagName = ref8[k];
|
|
1717
|
+
cells = h.tr.getElementsByTagName(tagName);
|
|
1718
|
+
for (l = 0, len1 = cells.length; l < len1; l++) {
|
|
1719
|
+
cell = cells[l];
|
|
1720
|
+
removeClass(cell, classRowCollapsed + " " + classRowShow);
|
|
1721
|
+
addClass(cell, classRowExpanded + " " + classRowHide);
|
|
1722
|
+
cell.style.display = "none";
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
h.th.style.display = "";
|
|
1726
|
+
h.th.innerHTML = " " + arrowExpanded + " " + h.th.getAttribute("data-rowHeader");
|
|
1727
|
+
return replaceClass(h.tr, classRowCollapsed, classRowExpanded);
|
|
1728
|
+
};
|
|
1729
|
+
expandChildRow = function(ch) {
|
|
1730
|
+
var gch, k, len, ref8, results;
|
|
1731
|
+
if (ch.descendants !== 0 && hasClass(ch.th, classRowExpanded) && (isRowHideOnExpand || isRowDisable || ch.col > rowDisableAfter)) {
|
|
1732
|
+
ch.tr.style.display = "";
|
|
1733
|
+
ch.th.style.display = "";
|
|
1734
|
+
} else {
|
|
1735
|
+
showChildRow(ch);
|
|
1736
|
+
}
|
|
1737
|
+
if (ch.clickStatus !== clickStatusCollapsed) {
|
|
1738
|
+
ref8 = ch.children;
|
|
1739
|
+
results = [];
|
|
1740
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1741
|
+
gch = ref8[k];
|
|
1742
|
+
results.push(expandChildRow(gch));
|
|
1743
|
+
}
|
|
1744
|
+
return results;
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
expandRow = function(rowHeaderHeaders, rowHeaderRows, r) {
|
|
1748
|
+
var ch, h, hh, isRowSubtotal, k, len, p, ref8, rowspan;
|
|
1749
|
+
if (isRowDisable) {
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
if (isRowDisableExpandCollapse) {
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
if (!rowHeaderRows[r]) {
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1758
|
+
h = rowHeaderRows[r];
|
|
1759
|
+
if (h.col > rowDisableAfter) {
|
|
1760
|
+
return;
|
|
1761
|
+
}
|
|
1762
|
+
if (h.clickStatus === clickStatusExpanded) {
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
isRowSubtotal = h.descendants !== 0;
|
|
1766
|
+
rowspan = 0;
|
|
1767
|
+
ref8 = h.children;
|
|
1768
|
+
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1769
|
+
ch = ref8[k];
|
|
1770
|
+
expandChildRow(ch);
|
|
1771
|
+
rowspan += ch.th.rowSpan;
|
|
1772
|
+
}
|
|
1773
|
+
h.th.rowSpan = rowspan + 1;
|
|
1774
|
+
if (isRowSubtotal) {
|
|
1775
|
+
if (isRowHideOnExpand) {
|
|
1776
|
+
expandHideRowSubtotal(h);
|
|
1777
|
+
} else {
|
|
1778
|
+
expandShowRowSubtotal(h);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
removeRowHeaderNullValue(h);
|
|
1783
|
+
|
|
1784
|
+
p = h.parent;
|
|
1785
|
+
while (p) {
|
|
1786
|
+
p.th.rowSpan += rowspan;
|
|
1787
|
+
p = p.parent;
|
|
1788
|
+
}
|
|
1789
|
+
h.clickStatus = clickStatusExpanded;
|
|
1790
|
+
hh = rowHeaderHeaders.hh[h.col];
|
|
1791
|
+
++hh.expandedCount;
|
|
1792
|
+
if (hh.expandedCount === hh.nHeaders) {
|
|
1793
|
+
replaceClass(hh.th, classCollapsed, classExpanded);
|
|
1794
|
+
hh.th.innerHTML = " " + arrowExpanded + " " + opts.labelsConvertFunction(hh.th.getAttribute("data-rowAttr"));
|
|
1795
|
+
return hh.clickStatus = clickStatusExpanded;
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
toggleCol = function(colHeaderHeaders, colHeaderCols, c) {
|
|
1799
|
+
var h, allClass, mainClass, is_other, main_th;
|
|
1800
|
+
if (colHeaderCols[c] == null) {
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
h = colHeaderCols[c];
|
|
1804
|
+
if (h.clickStatus === clickStatusCollapsed) {
|
|
1805
|
+
allClass = classColCollapsed;
|
|
1806
|
+
mainClass = classCollapsed;
|
|
1807
|
+
expandCol(colHeaderHeaders, colHeaderCols, c);
|
|
1808
|
+
} else {
|
|
1809
|
+
collapseCol(colHeaderHeaders, colHeaderCols, c);
|
|
1810
|
+
mainClass = classExpanded;
|
|
1811
|
+
allClass = classColExpanded;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
is_other = $('.pvtColLabel.'+allClass,h.tr).not('.pvtColSubtotal').length;
|
|
1815
|
+
if(is_other == 0){
|
|
1816
|
+
$('.pvtAxisLabel.'+mainClass,h.tr).trigger( "click" );
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
return h.th.scrollIntoView;
|
|
1820
|
+
};
|
|
1821
|
+
toggleRow = function(rowHeaderHeaders, rowHeaderRows, r) {
|
|
1822
|
+
var h, allClass, mainClass, is_other, main_th, hh;
|
|
1823
|
+
|
|
1824
|
+
if (rowHeaderRows[r] == null) {
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
h = rowHeaderRows[r];
|
|
1829
|
+
|
|
1830
|
+
if (rowHeaderRows[r].clickStatus === clickStatusCollapsed) {
|
|
1831
|
+
expandRow(rowHeaderHeaders, rowHeaderRows, r);
|
|
1832
|
+
allClass = clickStatusCollapsed;
|
|
1833
|
+
mainClass = classCollapsed;
|
|
1834
|
+
} else {
|
|
1835
|
+
collapseRow(rowHeaderHeaders, rowHeaderRows, r);
|
|
1836
|
+
allClass = clickStatusExpanded;
|
|
1837
|
+
mainClass = classExpanded;
|
|
1838
|
+
|
|
1839
|
+
/*is_other = _.find(rowHeaderRows, {col:h.col, clickStatus:allClass});
|
|
1840
|
+
if(!is_other){
|
|
1841
|
+
hh = rowHeaderHeaders.hh[h.col];
|
|
1842
|
+
if(hh && hh.th && $(hh.th).hasClass(mainClass)){
|
|
1843
|
+
$(hh.th).trigger('click');
|
|
1844
|
+
}
|
|
1845
|
+
}*/
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
return h.th.scrollIntoView;
|
|
1849
|
+
};
|
|
1850
|
+
collapseColsAt = function(colHeaderHeaders, colHeaderCols, colAttrs, colAttr) {
|
|
1851
|
+
var h, hh, i, idx, nAttrs, nCols, results;
|
|
1852
|
+
if (isColDisable) {
|
|
1853
|
+
return;
|
|
1854
|
+
}
|
|
1855
|
+
if (typeof colAttr === 'string') {
|
|
1856
|
+
idx = colAttrs.indexOf(colAttr);
|
|
1857
|
+
} else {
|
|
1858
|
+
idx = colAttr;
|
|
1859
|
+
}
|
|
1860
|
+
if (idx < 0 || idx === colAttrs.length - 1) {
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
i = idx;
|
|
1864
|
+
nAttrs = colAttrs.length - 1;
|
|
1865
|
+
while (i < nAttrs && i <= colDisableAfter) {
|
|
1866
|
+
hh = colHeaderHeaders[i];
|
|
1867
|
+
replaceClass(hh.th, classExpanded, classCollapsed);
|
|
1868
|
+
hh.th.innerHTML = " " + arrowCollapsed + " " + opts.labelsConvertFunction(colAttrs[i]);
|
|
1869
|
+
hh.clickStatus = clickStatusCollapsed;
|
|
1870
|
+
++i;
|
|
1871
|
+
}
|
|
1872
|
+
i = 0;
|
|
1873
|
+
nCols = colHeaderCols.length;
|
|
1874
|
+
results = [];
|
|
1875
|
+
while (i < nCols) {
|
|
1876
|
+
h = colHeaderCols[i];
|
|
1877
|
+
if (h.col === idx && h.clickStatus !== clickStatusCollapsed && h.th.style.display !== "none") {
|
|
1878
|
+
collapseCol(colHeaderHeaders, colHeaderCols, parseInt(h.th.getAttribute("data-colnode")));
|
|
1879
|
+
}
|
|
1880
|
+
results.push(++i);
|
|
1881
|
+
}
|
|
1882
|
+
return results;
|
|
1883
|
+
};
|
|
1884
|
+
expandColsAt = function(colHeaderHeaders, colHeaderCols, colAttrs, colAttr) {
|
|
1885
|
+
var colHeaderHeader, h, hh, i, idx, j, k, nCols, ref8, results;
|
|
1886
|
+
if (isColDisable) {
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
if (typeof colAttr === 'string') {
|
|
1890
|
+
idx = colAttrs.indexOf(colAttr);
|
|
1891
|
+
} else {
|
|
1892
|
+
idx = colAttr;
|
|
1893
|
+
}
|
|
1894
|
+
if (idx < 0 || idx === colAttrs.length - 1) {
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
for (i = k = 0, ref8 = idx; 0 <= ref8 ? k <= ref8 : k >= ref8; i = 0 <= ref8 ? ++k : --k) {
|
|
1898
|
+
if (i <= colDisableAfter) {
|
|
1899
|
+
hh = colHeaderHeaders[i];
|
|
1900
|
+
replaceClass(hh.th, classCollapsed, classExpanded);
|
|
1901
|
+
hh.th.innerHTML = " " + arrowExpanded + " " + opts.labelsConvertFunction(colAttrs[i]);
|
|
1902
|
+
hh.clickStatus = clickStatusExpanded;
|
|
1903
|
+
}
|
|
1904
|
+
j = 0;
|
|
1905
|
+
nCols = colHeaderCols.length;
|
|
1906
|
+
while (j < nCols) {
|
|
1907
|
+
h = colHeaderCols[j];
|
|
1908
|
+
if (h.col === i) {
|
|
1909
|
+
expandCol(colHeaderHeaders, colHeaderCols, j);
|
|
1910
|
+
}
|
|
1911
|
+
++j;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
++idx;
|
|
1915
|
+
results = [];
|
|
1916
|
+
while (idx < colAttrs.length - 1 && idx <= colDisableAfter) {
|
|
1917
|
+
colHeaderHeader = colHeaderHeaders[idx];
|
|
1918
|
+
if (colHeaderHeader.expandedCount === 0) {
|
|
1919
|
+
replaceClass(colHeaderHeader.th, classExpanded, classCollapsed);
|
|
1920
|
+
colHeaderHeader.th.innerHTML = " " + arrowCollapsed + " " + opts.labelsConvertFunction(colAttrs[idx]);
|
|
1921
|
+
colHeaderHeader.clickStatus = clickStatusCollapsed;
|
|
1922
|
+
} else if (colHeaderHeader.expandedCount === colHeaderHeader.nHeaders) {
|
|
1923
|
+
replaceClass(colHeaderHeader.th, classCollapsed, classExpanded);
|
|
1924
|
+
colHeaderHeader.th.innerHTML = " " + arrowExpanded + " " + opts.labelsConvertFunction(colAttrs[idx]);
|
|
1925
|
+
colHeaderHeader.clickStatus = clickStatusExpanded;
|
|
1926
|
+
}
|
|
1927
|
+
results.push(++idx);
|
|
1928
|
+
}
|
|
1929
|
+
return results;
|
|
1930
|
+
};
|
|
1931
|
+
collapseRowsAt = function(rowHeaderHeaders, rowHeaderRows, rowAttrs, rowAttr) {
|
|
1932
|
+
var h, i, idx, j, nAttrs, nRows, results;
|
|
1933
|
+
if (isRowDisable) {
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
if (typeof rowAttr === 'string') {
|
|
1937
|
+
idx = rowAttrs.indexOf(rowAttr);
|
|
1938
|
+
} else {
|
|
1939
|
+
idx = rowAttr;
|
|
1940
|
+
}
|
|
1941
|
+
if (idx < 0 || idx === rowAttrs.length - 1) {
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
i = idx;
|
|
1945
|
+
nAttrs = rowAttrs.length - 1;
|
|
1946
|
+
while (i < nAttrs && i <= rowDisableAfter) {
|
|
1947
|
+
h = rowHeaderHeaders.hh[i];
|
|
1948
|
+
replaceClass(h.th, classExpanded, classCollapsed);
|
|
1949
|
+
h.th.innerHTML = " " + arrowCollapsed + " " + opts.labelsConvertFunction(rowAttrs[i]);
|
|
1950
|
+
h.clickStatus = clickStatusCollapsed;
|
|
1951
|
+
++i;
|
|
1952
|
+
}
|
|
1953
|
+
j = 0;
|
|
1954
|
+
nRows = rowHeaderRows.length;
|
|
1955
|
+
results = [];
|
|
1956
|
+
while (j < nRows) {
|
|
1957
|
+
h = rowHeaderRows[j];
|
|
1958
|
+
if (h.col === idx && h.clickStatus !== clickStatusCollapsed && h.tr.style.display !== "none") {
|
|
1959
|
+
collapseRow(rowHeaderHeaders, rowHeaderRows, j);
|
|
1960
|
+
results.push(j = j + h.descendants + 1);
|
|
1961
|
+
} else {
|
|
1962
|
+
results.push(++j);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
return results;
|
|
1966
|
+
};
|
|
1967
|
+
expandRowsAt = function(rowHeaderHeaders, rowHeaderRows, rowAttrs, rowAttr) {
|
|
1968
|
+
var h, hh, i, idx, j, k, nRows, ref8, results, rowHeaderHeader;
|
|
1969
|
+
if (isRowDisable) {
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
if (typeof rowAttr === 'string') {
|
|
1973
|
+
idx = rowAttrs.indexOf(rowAttr);
|
|
1974
|
+
} else {
|
|
1975
|
+
idx = rowAttr;
|
|
1976
|
+
}
|
|
1977
|
+
if (idx < 0 || idx === rowAttrs.length - 1) {
|
|
1978
|
+
return;
|
|
1979
|
+
}
|
|
1980
|
+
for (i = k = 0, ref8 = idx; 0 <= ref8 ? k <= ref8 : k >= ref8; i = 0 <= ref8 ? ++k : --k) {
|
|
1981
|
+
if (i <= rowDisableAfter) {
|
|
1982
|
+
hh = rowHeaderHeaders.hh[i];
|
|
1983
|
+
replaceClass(hh.th, classCollapsed, classExpanded);
|
|
1984
|
+
hh.th.innerHTML = " " + arrowExpanded + " " + opts.labelsConvertFunction(rowAttrs[i]);
|
|
1985
|
+
hh.clickStatus = clickStatusExpanded;
|
|
1986
|
+
}
|
|
1987
|
+
j = 0;
|
|
1988
|
+
nRows = rowHeaderRows.length;
|
|
1989
|
+
while (j < nRows) {
|
|
1990
|
+
h = rowHeaderRows[j];
|
|
1991
|
+
if (h.col === i) {
|
|
1992
|
+
expandRow(rowHeaderHeaders, rowHeaderRows, j);
|
|
1993
|
+
j += h.descendants + 1;
|
|
1994
|
+
} else {
|
|
1995
|
+
++j;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
++idx;
|
|
2000
|
+
results = [];
|
|
2001
|
+
while (idx < rowAttrs.length - 1 && idx <= rowDisableAfter) {
|
|
2002
|
+
rowHeaderHeader = rowHeaderHeaders.hh[idx];
|
|
2003
|
+
if (rowHeaderHeader.expandedCount === 0) {
|
|
2004
|
+
replaceClass(rowHeaderHeader.th, classExpanded, classCollapsed);
|
|
2005
|
+
rowHeaderHeader.th.innerHTML = " " + arrowCollapsed + " " + opts.labelsConvertFunction(rowAttrs[idx]);
|
|
2006
|
+
rowHeaderHeader.clickStatus = clickStatusCollapsed;
|
|
2007
|
+
} else if (rowHeaderHeader.expandedCount === rowHeaderHeader.nHeaders) {
|
|
2008
|
+
replaceClass(rowHeaderHeader.th, classCollapsed, classExpanded);
|
|
2009
|
+
rowHeaderHeader.th.innerHTML = " " + arrowExpanded + " " + opts.labelsConvertFunction(rowAttrs[idx]);
|
|
2010
|
+
rowHeaderHeader.clickStatus = clickStatusExpanded;
|
|
2011
|
+
}
|
|
2012
|
+
results.push(++idx);
|
|
2013
|
+
}
|
|
2014
|
+
return results;
|
|
2015
|
+
};
|
|
2016
|
+
toggleColHeaderHeader = function(colHeaderHeaders, colHeaderCols, colAttrs, colAttr) {
|
|
2017
|
+
var h, idx;
|
|
2018
|
+
if (isColDisable) {
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
if (isColDisableExpandCollapse) {
|
|
2022
|
+
return;
|
|
2023
|
+
}
|
|
2024
|
+
idx = colAttrs.indexOf(colAttr);
|
|
2025
|
+
h = colHeaderHeaders[idx];
|
|
2026
|
+
if (h.col > colDisableAfter) {
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
if (h.clickStatus === clickStatusCollapsed) {
|
|
2030
|
+
h.clickStatus = clickStatusExpanded;
|
|
2031
|
+
h.th.innerHTML = " " + arrowExpanded + " " + opts.labelsConvertFunction(colAttr);
|
|
2032
|
+
replaceClass(h.th, classCollapsed, classExpanded);
|
|
2033
|
+
return expandColsAt(colHeaderHeaders, colHeaderCols, colAttrs, colAttr);
|
|
2034
|
+
} else {
|
|
2035
|
+
h.clickStatus = clickStatusCollapsed;
|
|
2036
|
+
h.th.innerHTML = " " + arrowCollapsed + " " + opts.labelsConvertFunction(colAttr);
|
|
2037
|
+
replaceClass(h.th, classExpanded, classCollapsed);
|
|
2038
|
+
return collapseColsAt(colHeaderHeaders, colHeaderCols, colAttrs, colAttr);
|
|
2039
|
+
}
|
|
2040
|
+
};
|
|
2041
|
+
toggleRowHeaderHeader = function(rowHeaderHeaders, rowHeaderRows, rowAttrs, rowAttr) {
|
|
2042
|
+
var idx, th;
|
|
2043
|
+
if (isRowDisable) {
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
if (isRowDisableExpandCollapse) {
|
|
2047
|
+
return;
|
|
2048
|
+
}
|
|
2049
|
+
idx = rowAttrs.indexOf(rowAttr);
|
|
2050
|
+
th = rowHeaderHeaders.hh[idx];
|
|
2051
|
+
if (th.col > rowDisableAfter) {
|
|
2052
|
+
return;
|
|
2053
|
+
}
|
|
2054
|
+
if (th.clickStatus === clickStatusCollapsed) {
|
|
2055
|
+
th.clickStatus = clickStatusExpanded;
|
|
2056
|
+
th.th.innerHTML = " " + arrowExpanded + " " + opts.labelsConvertFunction(rowAttr);
|
|
2057
|
+
replaceClass(th.th, classCollapsed, classExpanded);
|
|
2058
|
+
return expandRowsAt(rowHeaderHeaders, rowHeaderRows, rowAttrs, rowAttr);
|
|
2059
|
+
} else {
|
|
2060
|
+
th.clickStatus = clickStatusCollapsed;
|
|
2061
|
+
th.th.innerHTML = " " + arrowCollapsed + " " + opts.labelsConvertFunction(rowAttr);
|
|
2062
|
+
replaceClass(th.th, classExpanded, classCollapsed);
|
|
2063
|
+
return collapseRowsAt(rowHeaderHeaders, rowHeaderRows, rowAttrs, rowAttr);
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
|
|
2067
|
+
handleFreezePanesScroll = function(freezableElements) {
|
|
2068
|
+
return function(event) {
|
|
2069
|
+
if (event.target.dataset.canFreezePanes) return;
|
|
2070
|
+
|
|
2071
|
+
const wrapper = event.target;
|
|
2072
|
+
|
|
2073
|
+
const translateY = `translate(0px, ${wrapper.scrollTop}px)`;
|
|
2074
|
+
const translateX = `translate(${wrapper.scrollLeft}px, 0px)`;
|
|
2075
|
+
const translateXY = `translate(${wrapper.scrollLeft}px, ${wrapper.scrollTop}px)`;
|
|
2076
|
+
|
|
2077
|
+
_.forEach(freezableElements, function (element) {
|
|
2078
|
+
let currentTranslate = translateY;
|
|
2079
|
+
currentTranslate = element.className.includes(elementToTransform.X) ? translateX : currentTranslate;
|
|
2080
|
+
currentTranslate = element.className.includes(elementToTransform.XY) ? translateXY : currentTranslate;
|
|
2081
|
+
element.style.transform = currentTranslate;
|
|
2082
|
+
});
|
|
2083
|
+
}
|
|
2084
|
+
};
|
|
2085
|
+
|
|
2086
|
+
selectFreezableElements = function(wrapper) {
|
|
2087
|
+
const selectString =_.map(Object.values(elementToTransform), function (item) {
|
|
2088
|
+
return `.${item.replace(' ', '')}`;
|
|
2089
|
+
}).join(',');
|
|
2090
|
+
return Array.from(wrapper.querySelectorAll(selectString));
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
main = function(rowAttrs, rowKeys, colAttrs, colKeys) {
|
|
2094
|
+
var c,rowspan, colHeaderCols, colHeaderHeaders, colHeaders, h, k, l, len, len1, result, rowHeaderHeaders, rowHeaderRows, rowHeaders, tbody, thead, tr;
|
|
2095
|
+
rowHeaders = [];
|
|
2096
|
+
colHeaders = [];
|
|
2097
|
+
rowHeaderHeaders = {};
|
|
2098
|
+
rowHeaderRows = [];
|
|
2099
|
+
colHeaderHeaders = [];
|
|
2100
|
+
colHeaderCols = [];
|
|
2101
|
+
if (rowAttrs.length > 0 && rowKeys.length > 0) {
|
|
2102
|
+
rowHeaders = processKeys(rowKeys, "pvtRowLabel", 'rows', rowAttrs);
|
|
2103
|
+
}
|
|
2104
|
+
if (colAttrs.length > 0 && colKeys.length > 0) {
|
|
2105
|
+
colHeaders = processKeys(colKeys, "pvtColLabel", 'cols', colAttrs);
|
|
2106
|
+
}
|
|
2107
|
+
var tableClasses = useNewUx && opts.chartOptions.table_options.use_new_table_design ? 'pvtTable newPvtTable' : 'pvtTable';
|
|
2108
|
+
result = createElement("table", tableClasses , null, {
|
|
2109
|
+
style: "display: none;"
|
|
2110
|
+
});
|
|
2111
|
+
|
|
2112
|
+
colorizeTableIfNeed(result);
|
|
2113
|
+
|
|
2114
|
+
thead = createElement("thead");
|
|
2115
|
+
result.appendChild(thead);
|
|
2116
|
+
if (colAttrs.length > 0) {
|
|
2117
|
+
buildColHeaderHeaders(thead, colHeaderHeaders, rowAttrs, colAttrs);
|
|
2118
|
+
for (k = 0, len = colHeaders.length; k < len; k++) {
|
|
2119
|
+
h = colHeaders[k];
|
|
2120
|
+
buildColHeaders(colHeaderHeaders, colHeaderCols, h, rowAttrs, colAttrs);
|
|
2121
|
+
}
|
|
2122
|
+
buildColHeaderHeadersClickEvents(colHeaderHeaders, colHeaderCols, colAttrs);
|
|
2123
|
+
}
|
|
2124
|
+
if (rowAttrs.length > 0) {
|
|
2125
|
+
buildRowHeaderHeaders(thead, rowHeaderHeaders, rowAttrs, colAttrs);
|
|
2126
|
+
if (colAttrs.length === 0 && opts.chartOptions.table_options.show_row_total) {
|
|
2127
|
+
buildRowTotalsHeader(rowHeaderHeaders.tr, rowAttrs, colAttrs);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
if (colAttrs.length > 0 && opts.chartOptions.table_options.show_row_total) {
|
|
2131
|
+
buildRowTotalsHeader(colHeaderHeaders[0].tr, rowAttrs, colAttrs);
|
|
2132
|
+
if(opts.chartOptions.table_options.colorize_headers == true){
|
|
2133
|
+
for (c=1; c<colHeaderHeaders.length; c++){
|
|
2134
|
+
rowspan = 1;
|
|
2135
|
+
if(c == colHeaderHeaders.length-1){
|
|
2136
|
+
rowspan = 2;
|
|
2137
|
+
}
|
|
2138
|
+
colHeaderHeaders[c].tr.appendChild(createElement("th", verticalFreezePaneClass, "",{rowspan: rowspan}));
|
|
2139
|
+
if (opts.chartOptions.table_options.freeze_panes) {
|
|
2140
|
+
getHeaderColorProperties(colHeaderHeaders[c].tr, c);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
tbody = createElement("tbody");
|
|
2146
|
+
result.appendChild(tbody);
|
|
2147
|
+
|
|
2148
|
+
const hasColLabels = !!thead.querySelector('.pvtColLabel');
|
|
2149
|
+
|
|
2150
|
+
if (rowAttrs.length > 0) {
|
|
2151
|
+
for (l = 0, len1 = rowHeaders.length; l < len1; l++) {
|
|
2152
|
+
h = rowHeaders[l];
|
|
2153
|
+
buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, l%2 === 0, hasColLabels);
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
buildRowHeaderHeadersClickEvents(rowHeaderHeaders, rowHeaderRows, rowAttrs);
|
|
2157
|
+
buildValues(rowHeaderRows, colHeaderCols, rowAttrs, colAttrs);
|
|
2158
|
+
if(opts.chartOptions.table_options.show_column_total){
|
|
2159
|
+
tr = buildColTotalsHeader(rowAttrs, colAttrs);
|
|
2160
|
+
if (colAttrs.length > 0) {
|
|
2161
|
+
buildColTotals(tr, colHeaderCols, rowAttrs, colAttrs);
|
|
2162
|
+
}
|
|
2163
|
+
if(opts.chartOptions.table_options.show_row_total)
|
|
2164
|
+
buildGrandTotal(tbody, tr, rowAttrs, colAttrs);
|
|
2165
|
+
else
|
|
2166
|
+
tbody.appendChild(tr);
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
result.setAttribute("data-numrows", rowKeys.length);
|
|
2170
|
+
result.setAttribute("data-numcols", colKeys.length);
|
|
2171
|
+
if ((opts.collapseRowsAt == null) && (opts.collapseColsAt == null)) {
|
|
2172
|
+
result.style.display = "";
|
|
2173
|
+
}
|
|
2174
|
+
if (opts.collapseRowsAt != null) {
|
|
2175
|
+
collapseRowsAt(rowHeaderHeaders, rowHeaderRows, rowAttrs, opts.collapseRowsAt);
|
|
2176
|
+
}
|
|
2177
|
+
if (opts.collapseColsAt != null) {
|
|
2178
|
+
collapseColsAt(colHeaderHeaders, colHeaderCols, colAttrs, opts.collapseColsAt);
|
|
2179
|
+
}
|
|
2180
|
+
result.style.display = "";
|
|
2181
|
+
|
|
2182
|
+
var resultsArr = [];
|
|
2183
|
+
var additionOptions = opts.chartOptions ? opts.chartOptions : null;
|
|
2184
|
+
|
|
2185
|
+
if (opts && opts.chart_title && !opts.chartOptions.hideChartHeader) {
|
|
2186
|
+
var title = document.createElement("div");
|
|
2187
|
+
title.className = "title";
|
|
2188
|
+
title.innerText = opts.chart_title;
|
|
2189
|
+
resultsArr.push(title);
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
if (additionOptions && additionOptions.subtitle && !opts.chartOptions.hideChartHeader) {
|
|
2193
|
+
var subTitle = document.createElement("div");
|
|
2194
|
+
subTitle.className = "sub-title";
|
|
2195
|
+
subTitle.innerText = additionOptions.subtitle.subtitle;
|
|
2196
|
+
resultsArr.push(subTitle);
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
if (tooMuch) {
|
|
2200
|
+
const defaultPlaceholder = $('<div class="noData"><i class="fa fa-info"></i> There are too many rows to display in the table.<br>Please filter or change the table type in options.</div>');
|
|
2201
|
+
|
|
2202
|
+
resultsArr.push($.pivotUtilities.errorHandling.getErrorPlaceholder(error_params, useNewUx) || defaultPlaceholder);
|
|
2203
|
+
} else {
|
|
2204
|
+
var tableContainer = document.createElement("div");
|
|
2205
|
+
tableContainer.className = "pivot-div";
|
|
2206
|
+
tableContainer.appendChild(result);
|
|
2207
|
+
if (opts.chartOptions.table_options.freeze_panes) {
|
|
2208
|
+
tableContainer.onscroll = handleFreezePanesScroll(selectFreezableElements(tableContainer));
|
|
2209
|
+
}
|
|
2210
|
+
resultsArr.push(tableContainer);
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
var wrapper = document.createElement("div");
|
|
2214
|
+
wrapper.className = "pivot-wrapper";
|
|
2215
|
+
|
|
2216
|
+
$(wrapper).append(resultsArr);
|
|
2217
|
+
|
|
2218
|
+
return wrapper;
|
|
2219
|
+
};
|
|
2220
|
+
return main(rowAttrs, rowKeys, colAttrs, colKeys);
|
|
2221
|
+
};
|
|
2222
|
+
// $.pivotUtilities.subtotal_renderers = SubtotalRenderer;
|
|
2223
|
+
$.pivotUtilities.subtotal_renderers = NovixRenderer;
|
|
2224
|
+
$.pivotUtilities.delim = delim;
|
|
2225
|
+
|
|
2226
|
+
$.pivotUtilities.getFormattedNumber = getFormattedNumber;
|
|
2227
|
+
$.pivotUtilities.sortDateStrings = sortDateStrings;
|
|
2228
|
+
$.pivotUtilities.largeToSmallSort = largeToSmallSort;
|
|
2229
|
+
$.pivotUtilities.largeToSmallSortByAbsolute = largeToSmallSortByAbsolute;
|
|
2230
|
+
$.pivotUtilities.getPivotDataModel = function(input, opts){ return new DRPivotData(input, opts); }
|
|
2231
|
+
$.pivotUtilities.getPivotTableFormula = function(rowData, opts, func, colFields, rowFields, aggregationDefaults, utils) {
|
|
2232
|
+
let totalStr = 'Grand Totals';
|
|
2233
|
+
let pivotData = new DRPivotData(rowData, opts);
|
|
2234
|
+
let rowAttrs = pivotData.rowAttrs;
|
|
2235
|
+
let rowKeys = pivotData.getRowKeys();
|
|
2236
|
+
let colAttrs = pivotData.colAttrs;
|
|
2237
|
+
let colKeys = pivotData.getColKeys();
|
|
2238
|
+
|
|
2239
|
+
if ((rowKeys.length || 1) * (colKeys.length || 1) > 10000) {
|
|
2240
|
+
throw new Error(`Can't create table formula. The table has many rows or columns`);
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
let rowValuesIndex = colAttrs.length;
|
|
2244
|
+
let colValuesIndex = rowAttrs.length;
|
|
2245
|
+
let matrix = [];
|
|
2246
|
+
let colFormulas = [];
|
|
2247
|
+
let rowFormulas = [];
|
|
2248
|
+
let aggregation = utils.getAggregationConfigFromFields(func, colFields, rowFields, aggregationDefaults);
|
|
2249
|
+
|
|
2250
|
+
// Create headers
|
|
2251
|
+
if (rowAttrs && rowAttrs.length && colAttrs && colAttrs.length) {
|
|
2252
|
+
colValuesIndex += 1;
|
|
2253
|
+
rowValuesIndex += 1;
|
|
2254
|
+
|
|
2255
|
+
// Free place in formulas arrays
|
|
2256
|
+
colFormulas = new Array(colValuesIndex).fill(null);
|
|
2257
|
+
rowFormulas = new Array(rowValuesIndex).fill(null);
|
|
2258
|
+
|
|
2259
|
+
for (let i = 0; i < colAttrs.length; i++) {
|
|
2260
|
+
// Free place in row start
|
|
2261
|
+
let headerRow = new Array(rowAttrs.length).fill(null);
|
|
2262
|
+
// Add col field name
|
|
2263
|
+
headerRow.push(colAttrs[i]);
|
|
2264
|
+
// Add row keys
|
|
2265
|
+
_.forEach(colKeys, function (keys) {
|
|
2266
|
+
headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type));
|
|
2267
|
+
// Calc formulas in first time
|
|
2268
|
+
if (i === 0) {
|
|
2269
|
+
colFormulas.push(utils.createKeysFormula(colFields, keys, colFormulas.length + 1, true));
|
|
2270
|
+
}
|
|
2271
|
+
});
|
|
2272
|
+
|
|
2273
|
+
// Add row to matrix
|
|
2274
|
+
matrix.push(headerRow);
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
// Add row fields + free space under cols + Grand Totals right
|
|
2278
|
+
matrix.push(rowAttrs.concat(new Array(colKeys.length + 1).fill(null)).concat(totalStr));
|
|
2279
|
+
// Row Headers
|
|
2280
|
+
for (let i = 0; i < rowKeys.length; i++) {
|
|
2281
|
+
// Formatting row keys
|
|
2282
|
+
let keysFormatted = [];
|
|
2283
|
+
for (let k = 0; k < rowKeys[i].length; k++) {
|
|
2284
|
+
keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type))
|
|
2285
|
+
}
|
|
2286
|
+
// Add row keys
|
|
2287
|
+
matrix.push(keysFormatted.concat(null));
|
|
2288
|
+
// Calc formulas
|
|
2289
|
+
rowFormulas.push(utils.createKeysFormula(rowFields, rowKeys[i], rowFormulas.length + 1));
|
|
2290
|
+
}
|
|
2291
|
+
// Add Grand Totals bottom
|
|
2292
|
+
matrix.push(new Array(rowAttrs.length).fill(null).concat(totalStr));
|
|
2293
|
+
|
|
2294
|
+
// Fill values
|
|
2295
|
+
for (let y = rowValuesIndex; y < matrix.length; y++) {
|
|
2296
|
+
for (let x = colValuesIndex; x < matrix[rowValuesIndex - 1].length; x++) {
|
|
2297
|
+
matrix[y][x] = utils.createCellFormula(func, colFormulas[x], rowFormulas[y], aggregation);
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
} else if (colAttrs && colAttrs.length) {
|
|
2301
|
+
colFormulas = new Array(null);
|
|
2302
|
+
|
|
2303
|
+
for (let i = 0; i < colAttrs.length; i++) {
|
|
2304
|
+
// Add col field name
|
|
2305
|
+
let headerRow = [colAttrs[i]];
|
|
2306
|
+
// Add keys
|
|
2307
|
+
_.forEach(colKeys, function (keys) {
|
|
2308
|
+
headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type));
|
|
2309
|
+
// Calc formulas in first time
|
|
2310
|
+
if (i === 0) {
|
|
2311
|
+
colFormulas.push(utils.createKeysFormula(colFields, keys, colFormulas.length + 1, true));
|
|
2312
|
+
}
|
|
2313
|
+
});
|
|
2314
|
+
|
|
2315
|
+
// Add row to matrix
|
|
2316
|
+
matrix.push(headerRow);
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
// Add Grand Totals right
|
|
2320
|
+
matrix[matrix.length - 1].push(totalStr);
|
|
2321
|
+
// Add Grand Totals bottom
|
|
2322
|
+
matrix.push([totalStr]);
|
|
2323
|
+
|
|
2324
|
+
// Fill totals
|
|
2325
|
+
for (let x = 1; x < matrix[matrix.length - 2].length; x++) {
|
|
2326
|
+
matrix[matrix.length - 1][x] = utils.createCellFormula(func, colFormulas[x], '', aggregation);
|
|
2327
|
+
}
|
|
2328
|
+
} else if (rowAttrs && rowAttrs.length) {
|
|
2329
|
+
rowFormulas = new Array(null);
|
|
2330
|
+
|
|
2331
|
+
// Add row fields + Grand Totals right
|
|
2332
|
+
matrix.push(rowAttrs.concat(totalStr));
|
|
2333
|
+
// Row Headers
|
|
2334
|
+
for (let i = 0; i < rowKeys.length; i++) {
|
|
2335
|
+
// Formatting row keys
|
|
2336
|
+
let keysFormatted = [];
|
|
2337
|
+
for (let k = 0; k < rowKeys[i].length; k++) {
|
|
2338
|
+
keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type))
|
|
2339
|
+
}
|
|
2340
|
+
// Add row keys
|
|
2341
|
+
matrix.push(keysFormatted);
|
|
2342
|
+
// Calc formulas
|
|
2343
|
+
rowFormulas.push(utils.createKeysFormula(rowFields, rowKeys[i], rowFormulas.length + 1));
|
|
2344
|
+
}
|
|
2345
|
+
// Add Grand Totals bottom
|
|
2346
|
+
matrix.push(new Array(rowAttrs.length - 1).fill(null).concat(totalStr));
|
|
2347
|
+
|
|
2348
|
+
// Fill totals
|
|
2349
|
+
for (let y = 1; y < matrix.length; y++) {
|
|
2350
|
+
matrix[y][rowAttrs.length] = utils.createCellFormula(func, '', rowFormulas[y], aggregation);
|
|
2351
|
+
}
|
|
2352
|
+
} else {
|
|
2353
|
+
matrix = [[totalStr, utils.createCellFormula(func, '', '', aggregation)]];
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
return matrix;
|
|
2357
|
+
};
|
|
2358
|
+
};
|
|
2359
|
+
|
|
2360
|
+
module.exports = initDRPivotTable;
|