forked from Zorn192/AutoTrimps
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGraphs.js
1644 lines (1546 loc) · 71 KB
/
Graphs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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
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
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
584
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
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
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
const Graphs = {
Backend: {
_lastSave: new Date(),
_safeLocalStorage: function (name, data) {
try {
if (name === "portalDataCurrent") {
// save at most every 450ms. Stringify is too expensive to run at max speed in timewarp, but still save every zone in liq otherwise
if ((new Date() - this._lastSave) / 450 < 1) return;
else this._lastSave = new Date();
}
if (typeof data != "string") data = JSON.stringify(data);
localStorage.setItem(name, data);
} catch (e) {
if (e.code == 22 || e.code == 1014) { //
// Storage full, delete oldest 10 portals from history, and try again
console.debug(`Deleting oldest 10 portals ${Object.keys(Graphs.portalSaveData)[0]} - ${Object.keys(Graphs.portalSaveData)[10]}`);
var delCount = 10;
for (var i = 0; i < delCount; i++) {
delete Graphs.portalSaveData[Object.keys(Graphs.portalSaveData)[i]];
}
this.savePortalData(true, true); // force a blocking save
console.warn(`Ran out of Local Storage, consider lowering your saved portals to something under ${Object.keys(Graphs.portalSaveData).length}`);
}
}
},
// create a fake url for our compression webworker to live at. This is so cursed. (getting around cross-source issues with -monkey)
_compressionUrl: URL.createObjectURL(new Blob([`
var LZString = function () { var r = String.fromCharCode, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$", e = {}; function t(r, o) { if (!e[r]) { e[r] = {}; for (var n = 0; n < r.length; n++)e[r][r.charAt(n)] = n } return e[r][o] } var i = { compressToBase64: function (r) { if (null == r) return ""; var n = i._compress(r, 6, function (r) { return o.charAt(r) }); switch (n.length % 4) { default: case 0: return n; case 1: return n + "==="; case 2: return n + "=="; case 3: return n + "=" } }, decompressFromBase64: function (r) { return null == r ? "" : "" == r ? null : i._decompress(r.length, 32, function (n) { return t(o, r.charAt(n)) }) }, compressToUTF16: function (o) { return null == o ? "" : i._compress(o, 15, function (o) { return r(o + 32) }) + " " }, decompressFromUTF16: function (r) { return null == r ? "" : "" == r ? null : i._decompress(r.length, 16384, function (o) { return r.charCodeAt(o) - 32 }) }, compressToUint8Array: function (r) { for (var o = i.compress(r), n = new Uint8Array(2 * o.length), e = 0, t = o.length; e < t; e++) { var s = o.charCodeAt(e); n[2 * e] = s >>> 8, n[2 * e + 1] = s % 256 } return n }, decompressFromUint8Array: function (o) { if (null == o) return i.decompress(o); for (var n = new Array(o.length / 2), e = 0, t = n.length; e < t; e++)n[e] = 256 * o[2 * e] + o[2 * e + 1]; var s = []; return n.forEach(function (o) { s.push(r(o)) }), i.decompress(s.join("")) }, compressToEncodedURIComponent: function (r) { return null == r ? "" : i._compress(r, 6, function (r) { return n.charAt(r) }) }, decompressFromEncodedURIComponent: function (r) { return null == r ? "" : "" == r ? null : (r = r.replace(/ /g, "+"), i._decompress(r.length, 32, function (o) { return t(n, r.charAt(o)) })) }, compress: function (o) { return i._compress(o, 16, function (o) { return r(o) }) }, _compress: function (r, o, n) { if (null == r) return ""; var e, t, i, s = {}, u = {}, a = "", p = "", c = "", l = 2, f = 3, h = 2, d = [], m = 0, v = 0; for (i = 0; i < r.length; i += 1)if (a = r.charAt(i), Object.prototype.hasOwnProperty.call(s, a) || (s[a] = f++, u[a] = !0), p = c + a, Object.prototype.hasOwnProperty.call(s, p)) c = p; else { if (Object.prototype.hasOwnProperty.call(u, c)) { if (c.charCodeAt(0) < 256) { for (e = 0; e < h; e++)m <<= 1, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++; for (t = c.charCodeAt(0), e = 0; e < 8; e++)m = m << 1 | 1 & t, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1 } else { for (t = 1, e = 0; e < h; e++)m = m << 1 | t, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t = 0; for (t = c.charCodeAt(0), e = 0; e < 16; e++)m = m << 1 | 1 & t, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1 } 0 == --l && (l = Math.pow(2, h), h++), delete u[c] } else for (t = s[c], e = 0; e < h; e++)m = m << 1 | 1 & t, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1; 0 == --l && (l = Math.pow(2, h), h++), s[p] = f++, c = String(a) } if ("" !== c) { if (Object.prototype.hasOwnProperty.call(u, c)) { if (c.charCodeAt(0) < 256) { for (e = 0; e < h; e++)m <<= 1, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++; for (t = c.charCodeAt(0), e = 0; e < 8; e++)m = m << 1 | 1 & t, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1 } else { for (t = 1, e = 0; e < h; e++)m = m << 1 | t, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t = 0; for (t = c.charCodeAt(0), e = 0; e < 16; e++)m = m << 1 | 1 & t, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1 } 0 == --l && (l = Math.pow(2, h), h++), delete u[c] } else for (t = s[c], e = 0; e < h; e++)m = m << 1 | 1 & t, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1; 0 == --l && (l = Math.pow(2, h), h++) } for (t = 2, e = 0; e < h; e++)m = m << 1 | 1 & t, v == o - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1; for (; ;) { if (m <<= 1, v == o - 1) { d.push(n(m)); break } v++ } return d.join("") }, decompress: function (r) { return null == r ? "" : "" == r ? null : i._decompress(r.length, 32768, function (o) { return r.charCodeAt(o) }) }, _decompress: function (o, n, e) { var t, i, s, u, a, p, c, l = [], f = 4, h = 4, d = 3, m = "", v = [], g = { val: e(0), position: n, index: 1 }; for (t = 0; t < 3; t += 1)l[t] = t; for (s = 0, a = Math.pow(2, 2), p = 1; p != a;)u = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = n, g.val = e(g.index++)), s |= (u > 0 ? 1 : 0) * p, p <<= 1; switch (s) { case 0: for (s = 0, a = Math.pow(2, 8), p = 1; p != a;)u = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = n, g.val = e(g.index++)), s |= (u > 0 ? 1 : 0) * p, p <<= 1; c = r(s); break; case 1: for (s = 0, a = Math.pow(2, 16), p = 1; p != a;)u = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = n, g.val = e(g.index++)), s |= (u > 0 ? 1 : 0) * p, p <<= 1; c = r(s); break; case 2: return "" }for (l[3] = c, i = c, v.push(c); ;) { if (g.index > o) return ""; for (s = 0, a = Math.pow(2, d), p = 1; p != a;)u = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = n, g.val = e(g.index++)), s |= (u > 0 ? 1 : 0) * p, p <<= 1; switch (c = s) { case 0: for (s = 0, a = Math.pow(2, 8), p = 1; p != a;)u = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = n, g.val = e(g.index++)), s |= (u > 0 ? 1 : 0) * p, p <<= 1; l[h++] = r(s), c = h - 1, f--; break; case 1: for (s = 0, a = Math.pow(2, 16), p = 1; p != a;)u = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = n, g.val = e(g.index++)), s |= (u > 0 ? 1 : 0) * p, p <<= 1; l[h++] = r(s), c = h - 1, f--; break; case 2: return v.join("") }if (0 == f && (f = Math.pow(2, d), d++), l[c]) m = l[c]; else { if (c !== h) return null; m = i + i.charAt(0) } v.push(m), l[h++] = i + m.charAt(0), i = m, 0 == --f && (f = Math.pow(2, d), d++) } } }; return i }(); "function" == typeof define && define.amd ? define(function () { return LZString }) : "undefined" != typeof module && null != module ? module.exports = LZString : "undefined" != typeof angular && null != angular && angular.module("LZString", []).factory("LZString", function () { return LZString });
onmessage = function (event) { postMessage(LZString.compressToBase64(event.data)); self.close(); }
`], { type: 'text/javascript' })),
savePortalData: function (saveAll = true, forceImmediate) {
// Save Portal Data to history, or current only
var currentPortal = Graphs.getportalID();
if (saveAll) {
try {
if (typeof window.Worker === 'function' && !forceImmediate) {
worker = new Worker(this._compressionUrl);
worker.onmessage = this._recievedCompressedSave;
worker.postMessage(JSON.stringify(Graphs.portalSaveData));
}
else {
console.debug("Fallback to non-webworker");
this._safeLocalStorage("portalDataHistory", LZString.compressToBase64(JSON.stringify(Graphs.portalSaveData)));
}
}
catch (e) {
console.debug("Error saving graph history", e.code, e);
}
}
else {
var portalObj = {};
portalObj[currentPortal] = Graphs.portalSaveData[currentPortal];
this._safeLocalStorage("portalDataCurrent", portalObj);
}
},
_recievedCompressedSave: function (event) {
var saveString = event.data;
Graphs.Backend._safeLocalStorage("portalDataHistory", saveString);
console.debug("Successfully used a webworker to save graph data");
},
saveSetting: function (key, value) {
// Save settings, with or without updating a key
if (key !== null && value !== null) Graphs.Settings[key] = value;
this._safeLocalStorage("GRAPHSETTINGS", Graphs.Settings);
},
_safeLoad: function (storagekey, compressed) {
var input = localStorage.getItem(storagekey);
if (input) {
if (compressed) input = LZString.decompressFromBase64(input);
try {
var out = JSON.parse(input);
if (out && Object.entries(out).length > 0) return out;
}
catch (e) {
console.error("Failed to load Graph history", e);
}
}
return null;
},
loadGraphData: function () {
var loadedData = this._safeLoad("portalDataHistory", true)
var currentPortal = this._safeLoad("portalDataCurrent")
if (loadedData) {
if (currentPortal) { loadedData[Object.keys(currentPortal)[0]] = Object.values(currentPortal)[0] }
// remake object structure
for (const [portalID, portalData] of Object.entries(loadedData)) {
Graphs.portalSaveData[portalID] = new Graphs.Portal();
try {
for (const [k, v] of Object.entries(portalData)) {
Graphs.portalSaveData[portalID][k] = v;
}
}
catch (e) {
console.log(`Error on loading ${portalID}`, portalData)
}
}
}
var loadedSettings = this._safeLoad("GRAPHSETTINGS")
if (loadedSettings !== null) {
for (const [k, v] of Object.entries(loadedSettings)) {
Graphs.Settings[k] = v;
}
}
// initialize save space for the toggles
if (Graphs.Settings.toggles == null) Graphs.Settings.toggles = {};
for (const graph of GraphsConfig.graphList) {
if (graph.toggles) {
if (Graphs.Settings.toggles[graph.id] === undefined) { Graphs.Settings.toggles[graph.id] = {} }
graph.toggles.forEach((toggle) => {
if (Graphs.Settings.toggles[graph.id][toggle] === undefined) { Graphs.Settings.toggles[graph.id][toggle] = false }
})
}
}
Graphs.Settings.open = false;
},
importGraphs: function () {
var currentdata = localStorage.portalDataHistory; // make a backup
// get user input and put it in localstorage
var exportArea = document.getElementById("exportArea")
var data = exportArea.value;
localStorage.portalDataHistory = data;
Graphs.portalSaveData = {} // wipe old data
try {
this.loadGraphData();
}
catch (e) {
exportArea.innerHTML = "Error loading graph data, are you sure that was what you wanted to paste?"
console.log(e)
localStorage.portalDataHistory = currentdata
this.loadGraphData()
}
},
clearData: function (keepN, clrall = false) {
// TODO it is awkward as fuck that this works on portal number, when IDs are universe + portal number.
// Fixing that would remove a lot of ugliness here and in deleteSpecific.
var universe = Graphs.Settings.universeSelection
var changed = false;
var currentPortalNumber = getTotalPortals();
if (clrall) { // delete all but current
Graphs.debugMsg(`Deleting ${Object.keys(Graphs.portalSaveData).length - 1} Portals, clearall ${clrall}`)
for (const [portalID, portalData] of Object.entries(Graphs.portalSaveData)) {
if (portalData.totalPortals != currentPortalNumber && portalData.universe == universe) { // only delete currently selected universe data
delete Graphs.portalSaveData[portalID];
changed = true;
}
}
}
else { // keep keepN portals in selected universe , delete the rest
var portals = Object.entries(Graphs.portalSaveData).filter((data) => data[1].universe == universe).map((data) => { return data[0] });
// TODO 100% sure there's a better way than filter().map() but I'm not looking it up right now
if (keepN < portals.length) Graphs.debugMsg(`Existing Portals (${Object.keys(Graphs.portalSaveData).length}): ${Object.keys(Graphs.portalSaveData)}`)
while (keepN < portals.length) {
var current = portals.shift()
Graphs.debugMsg(`Deleting ${current}, keepn ${keepN}`)
delete Graphs.portalSaveData[current];
changed = true;
}
}
if (changed) {
Graphs.debugMsg("Saving Portal Data after deletions")
this.savePortalData(true)
Graphs.UI.showHideUnused();
}
},
deleteSpecific: function () {
var portalNum = document.getElementById("deleteSpecificTextBox").value
if (isNaN(parseInt(portalNum))) { // challenge name deletion
var portalType = portalNum.toLocaleLowerCase()
if (portalType === "") return; // Don't delete everything with blank input, that would be bad.
for (const [portalID, portalData] of Object.entries(Graphs.portalSaveData)) {
if (portalData.challenge.toLocaleLowerCase().includes(portalType) && portalData.universe == Graphs.Settings.universeSelection) { // only delete if in selected universe
delete Graphs.portalSaveData[portalID];
Graphs.debugMsg(`Deleting ${portalID}, deleteSpecific`)
}
}
} else {
portalNum = parseInt(portalNum)
if (portalNum < 0) { this.clearData(Math.abs(portalNum)); } // keep X portals, delete the rest
else if (portalNum > 0) { // single portal deletion
for (const [portalID, portalData] of Object.entries(Graphs.portalSaveData)) {
if (portalData.totalPortals === portalNum && portalData.universe == Graphs.Settings.universeSelection) { // only delete if in selected universe
delete Graphs.portalSaveData[portalID];
Graphs.debugMsg(`Deleting ${portalID}, deleteSpecific`)
}
}
}
}
this.savePortalData(true)
Graphs.UI.showHideUnused();
}
},
UI: {
_lastTheme: -1,
importExportGraphsDialog: function () {
this.escapeATWindows(true) // close graphs... rendering graphs while also having up to 5MB of text on display is a bad time.
// Code shamelessly lifted from the main game. How much of this is needed? I'm not going to find out.
if (game.global.lockTooltip && event != 'update') return;
if (game.global.lockTooltip && isItIn && event == 'update') return;
var elem = document.getElementById("tooltipDiv");
swapClass("tooltipExtra", "tooltipExtraNone", elem);
document.getElementById('tipText').className = "";
var ondisplay = null; // if non-null, called after the tooltip is displayed
openTooltip = null;
Graphs.Backend.savePortalData(true, true); // force save
var saveText = localStorage.portalDataHistory
var buttonHTML;
var downloadBlob;
if (Blob !== null) {
var blob = new Blob([saveText], { type: 'text/plain' });
var uri = URL.createObjectURL(blob);
downloadBlob = uri;
} else {
downloadBlob = 'data:text/plain,' + encodeURIComponent(saveText);
}
var saveName = `Trimps Graphs ${Object.keys(Graphs.portalSaveData)[0]} - ${Graphs.last(Object.keys(Graphs.portalSaveData))}`;
tooltipText = "This is your graph data. To Import, paste your data here and then click import. If you did that and then realized you actually wanted to export, re-open this dialog and then don't do it in that order again. <br/><br/><textarea spellcheck='false' id='exportArea' style='width: 100%' rows='5'>" + saveText + "</textarea>";
buttonHTML = "<div class='maxCenter'><div id='confirmTooltipBtn' class='btn btn-info' onclick='cancelTooltip()'>Got it</div> ";
if (document.queryCommandSupported('copy')) {
buttonHTML += "<div id='clipBoardBtn' class='btn btn-success'>Export</div>";
}
buttonHTML += `
<div id='importBtn' class='btn btn-success' onclick='Graphs.Backend.importGraphs()'>Import</div>
<a id='downloadLink' target='_blank' download="${saveName}"'.txt', href=${downloadBlob}>
<div class='btn btn-danger' id='downloadBtn'>Download as File</div></a>
</div>`;
ondisplay = tooltips.handleCopyButton();
game.global.lockTooltip = true;
elem.style.left = "33.75%";
elem.style.top = "25%";
var titleText;
titleText = "Import/Export Graph Data"
lastTooltipTitle = titleText;
tip2 = ""
var tipNum = (tip2) ? "2" : "";
document.getElementById("tipTitle" + tipNum).innerHTML = titleText;
document.getElementById("tipText" + tipNum).innerHTML = tooltipText;
document.getElementById("tipCost" + tipNum).innerHTML = buttonHTML;
elem.style.display = "block";
if (ondisplay !== null)
ondisplay();
},
_createStyles: function () {
let styleElem = document.createElement("style");
styleElem.textContent = `
#graphParent {
height: 600px;
overflow: auto;
position: relative;
display: grid;
grid-template-columns: repeat(3, minmax(1fr, max-content));
grid-template-rows: 2.5em 1fr 2.5em 2.5em;
font-size: 1em;
border-top: gray;
border-top-width: .2em;
border-top-style: solid;
}
#toggleDiv {
grid-area: 1 / 1;
margin: 1em;
z-index: 1;
}
#graph {
grid-column: 1/-1;
grid-row: 1/3;
}
#graphFooter {
grid-column: 1/-1;
grid-row: 3/-1;
display: grid;
grid-template-columns: subgrid;
grid-template-rows: subgrid;
margin-top: .2em
}
#graphFooter .footerR1 {
grid-row: 1;
}
#graphFooter .footerR2 {
grid-row: 2;
}
#graphFooter .footerLeft {
grid-column: 1;
}
#graphFooter .footerCenter {
grid-column: 2;
justify-self: center;
}
#graphFooter .footerRight {
grid-column: 3;
justify-self: end;
}
#graphParent input:not([type=checkbox]) {
width: 3em;
text-align: center;
}
.btnContainer {
margin: 0 .5em 0 .5em;
}
#graphParent button, #graphParent input, #graphParent select {
background: black;
color: white;
padding: .2em;
border-radius: 0px;
border: 1px solid white;
}
`;
document.head.appendChild(styleElem);
},
createUI: function () {
// Create all of the UI elements and load in scripts needed
for (const source of ["https://code.highcharts.com/11.1.0/highcharts.js", "https://code.highcharts.com/11.1.0/modules/boost.js"]) {
var chartscript = document.createElement("script");
chartscript.type = "text/javascript";
chartscript.src = source
chartscript.async = false
document.head.appendChild(chartscript);
}
this._createStyles();
var graphsButton = document.createElement("TD");
graphsButton.innerText = "Graphs";
graphsButton.classList.add("btn", "btn-default");
graphsButton.id = "graphsBtn";
graphsButton.addEventListener("click", function () { Graphs.UI.escapeATWindows(false); Graphs.ChartArea.draw(); Graphs.UI.swapGraphUniverse(); });
// insert after Achievements
document.querySelector("#settingsTable>*>*>:nth-child(5)").insertAdjacentElement("afterend", graphsButton);
/*
Layout is a 3 column, 4 row grid
Header r1, overlapping the Graph
Graph r1-2
Footer r3-4
*/
document.getElementById("settingsRow").insertAdjacentHTML("afterbegin",
`
<div id="graphParent" style="display: none;">
<div id="toggleDiv"></div>
<div id="graph"></div>
<div id="graphFooter">
<div class="footerLeft footerR1">
<span id="graphsSelectorContainer" class="btnContainer"></span>
</div>
<div class="footerCenter footerR1">
<span class="btnContainer">
<input id="clrChkbox" type="checkbox">
<button id="clrAllDataBtn" class="btn" disabled="">Clear All U1 Data</button>
</span>
<span class="btnContainer" id="deleteSpecificCont">
<input id="deleteSpecificTextBox">
<button id="deleteSpecificBtn">Delete Specific U1 Portals</button>
</span>
</div>
<div class="footerRight footerR1">
<span id="GraphsLegendCtrl" class="btnContainer">
<button id="GraphsInvertSelection">Invert Selection</button>
<button id="GraphsToggleAll">All Off/On</button>
</span>
<button id="GraphsExport" class="btnContainer">Import/Export</button>
</div>
<div class="footerLeft footerR2">
<button id="GraphsRefresh" class="btnContainer">Refresh</button>
<span class="btnContainer"><input type="checkbox" id="liveCheckbox">Live Updates</span>
</div>
<div class="footerCenter footerR2">
<span class="btnContainer"><input id="portalCountTextBox">Displayed Portals</span>
<span class="btnContainer"><input id="portalsSavedTextBox">Saved Portals</span>
</div>
<div class="footerRight footerR2">
<span class="btnContainer"><input id="blackCB" type="checkbox">Black Graphs</span>
</div>
</div>
</div>
`);
function createSelector(id, sourceList, textMod = "", onchangeMod) {
var selector = document.createElement("select");
selector.id = id;
//selector.setAttribute("style", "");
selector.addEventListener("change", function () { Graphs.Backend.saveSetting(this.id, this.value); Graphs.ChartArea.draw(); });
if (onchangeMod) { selector.addEventListener("change", onchangeMod); }
for (var item of sourceList) {
var opt = document.createElement("option");
opt.value = item;
opt.text = textMod + item;
selector.appendChild(opt);
}
selector.value = Graphs.Settings[selector.id];
return selector;
};
// Create Universe and Graph selectors
var selectorContainer = document.querySelector("#graphsSelectorContainer");
[
["universeSelection", [1, 2], "Universe ", function () { Graphs.UI.swapGraphUniverse(); }],
["u1graphSelection", GraphsConfig.graphList.filter((g) => g.universe == 1 || !g.universe).map((g) => g.selectorText)],
["u2graphSelection", GraphsConfig.graphList.filter((g) => g.universe == 2 || !g.universe).map((g) => g.selectorText)],
].forEach((opts) => selectorContainer.appendChild(createSelector(...opts)))
var GraphsTipsDelete = "To delete a portal, type its portal number in the box and press Delete Specific. Using negative numbers in the Delete Specific box will keep that many portals (starting counting backwards from the current one), ie: if you have Portals 1000-1015, typing -10 will keep 1005-1015. <br> You can also delete portals by challenge name, matches are non case sensitive and allow partial matches, ie coord matches Coordinated."
var GraphsTips = "You can zoom by dragging a box around an area. You can toggle portals by clicking them on the legend, or double click to toggle all of the same challenge. <br> Quickly view the last portal by clicking it off, then Invert Selection. Or by clicking All Off, then clicking the portal on."
const GraphUIEvents = [
["click", "GraphsRefresh", function () { Graphs.ChartArea.draw() }],
["click", "clrChkbox", function () { Graphs.UI.toggleClearButton() }],
["click", "clrAllDataBtn", function () { Graphs.Backend.clearData("null", true); Graphs.ChartArea.draw(); }],
["click", "deleteSpecificBtn", function () { Graphs.Backend.deleteSpecific(); Graphs.ChartArea.draw() }],
["click", "GraphsInvertSelection", function () { Graphs.ChartArea.toggleSpecific() }],
["click", "GraphsToggleAll", function () { Graphs.ChartArea.toggleAll() }],
["click", "GraphsExport", function () { Graphs.UI.importExportGraphsDialog() }],
["click", "liveCheckbox", function () { Graphs.Backend.saveSetting('live', this.checked) }],
["click", "blackCB", function () { Graphs.UI.toggleDarkGraphs() }],
["mouseover", "deleteSpecificCont", function () { tooltip("Tips", "customText", event, `${GraphsTipsDelete}`) }],
["mouseover", "GraphsLegendCtrl", function () { tooltip("Tips", "customText", event, `${GraphsTips}`) }],
["change", "portalCountTextBox", function () { Graphs.Backend.saveSetting('portalsDisplayed', this.value); Graphs.ChartArea.update(); }],
["change", "portalsSavedTextBox", function () { Graphs.Backend.saveSetting('maxGraphs', this.value); Graphs.Backend.clearData(this.value); Graphs.ChartArea.update(); }],
]
for (const [eventType, elemID, eventFunc] of GraphUIEvents) {
let targetElem = document.getElementById(elemID)
targetElem.addEventListener(eventType, eventFunc)
if (eventType === "mouseover") {
targetElem.addEventListener("mouseout", function () { tooltip("hide"); })
}
}
// Set toggles to saved values
document.querySelector("#blackCB").checked = Graphs.Settings.darkTheme;
document.querySelector("#portalCountTextBox").value = Graphs.Settings.portalsDisplayed;
document.querySelector("#portalsSavedTextBox").value = Graphs.Settings.maxGraphs;
document.querySelector("#liveCheckbox").checked = Graphs.Settings.live;
this.toggleDarkGraphs();
this.showHideUnused()
},
swapGraphUniverse: function () {
// Show/hide the universe-specific graph selectors
var universe = Graphs.Settings.universeSelection;
var active = `u${universe}`
var inactive = `u${universe == 1 ? 2 : 1}`
document.getElementById(`${active}graphSelection`).style.display = '';
document.getElementById(`${inactive}graphSelection`).style.display = 'none';
document.getElementById("clrAllDataBtn").innerText = `Clear All U${universe} Data`;
document.getElementById("deleteSpecificBtn").innerText = `Delete Specific U${universe} Portals`;
},
toggleClearButton: function () {
document.getElementById("clrAllDataBtn").disabled = !document.getElementById("clrChkbox").checked;
},
toggleDarkGraphs: function () {
if (game) {
var darkcss = document.getElementById("dark-graph.css")
var dark = document.getElementById("blackCB").checked;
Graphs.Backend.saveSetting("darkTheme", dark)
if (!darkcss && dark) {
var b = document.createElement("link");
b.rel = "stylesheet";
b.type = "text/css";
b.id = "dark-graph.css";
b.href = graphsBasePath + "dark-graph.css";
document.head.appendChild(b);
Graphs.debugMsg("Adding dark-graph.css file", "graphs");
}
else if (darkcss && !dark) {
document.head.removeChild(darkcss)
Graphs.debugMsg("Removing dark-graph.css file", "graphs")
}
}
},
escapeATWindows: function (escPressed = true) {
// Toggle AT windows with UI, or force close with Esc
var a = document.getElementById("tooltipDiv");
if (a.style.display != "none") return void cancelTooltip(); // old code, uncertain what it's for or why it's here.
for (elemId of ["autoSettings", "autoTrimpsTabBarMenu", "settingsHere", "graphParent"]) {
var elem = document.getElementById(elemId);
if (!elem) continue;
if (elemId === "graphParent") { // toggle Graphs window
var open = elem.style.display === "grid";
if (escPressed) open = true; // override to always close
elem.style.display = open ? "none" : "grid";
Graphs.Settings.open = !open;
trimpStatsDisplayed = !open; // HACKS disable hotkeys without touching Trimps settings
}
else { elem.style.display = "none"; } // close other windows
}
},
showHideUnused: function () {
// Hide graphs that have no collected data
var activeUniverses = [];
for (const graph of GraphsConfig.graphList) {
if (graph.graphType != "line") continue; // ignore column graphs (pure laziness, the only two always exist anyways)
const universes = graph.universe ? [graph.universe] : [1, 2]
for (const universe of universes) {
var style = "none"
for (portal of Object.values(Graphs.portalSaveData)) {
if (portal.perZoneData[graph.dataVar] && portal.universe === universe // has collected data, in the right universe
&& new Set(portal.perZoneData[graph.dataVar].filter(x => x === 0 || x)).size > 1) { // and there is nonzero, variable data
style = ""
if (!activeUniverses.includes(universe)) activeUniverses.push(universe);
break;
}
}
// hide unused graphs
document.querySelector(`#u${universe}graphSelection [value="${graph.selectorText}"]`).style.display = style;
}
}
// hide universe selector if graphs are only in one universe
var universeSel = document.querySelector(`#universeSelection`);
if (activeUniverses.length === 1) {
universeSel.style.display = "none";
Graphs.Settings.universeSelection = activeUniverses[0];
this.swapGraphUniverse()
}
else {
universeSel.style.display = "";
}
},
},
ChartArea: {
chart: undefined,
_lookupGraph: function (selectorText) {
for (const graph of GraphsConfig.graphList) {
if (graph.selectorText === selectorText) return graph;
}
},
draw: function () {
// Draws the graph currently selected by the user
function makeCheckbox(graph, toggle) {
// TOGGLES
// create checkbox element labeled with the toggle
var container = document.createElement("span")
var checkbox = document.createElement("input");
var label = document.createElement("span");
container.style.padding = "0rem .5rem";
checkbox.type = "checkbox";
checkbox.id = toggle;
// initialize the checkbox to saved value
checkbox.checked = Graphs.Settings.toggles[graph][toggle];
// create a godawful inline function to set saved value on change, apply exclusions, and update the graph
function manageCheckbox() {
if (GraphsConfig.toggledGraphs[toggle] && GraphsConfig.toggledGraphs[toggle].exclude) {
GraphsConfig.toggledGraphs[toggle].exclude.forEach(exTog => Graphs.Settings.toggles[graph][exTog] = false)
}
Graphs.Settings.toggles[graph][toggle] = this.checked;
Graphs.ChartArea.draw();
}
checkbox.addEventListener("click", manageCheckbox)
label.innerText = toggle;
label.style.color = "#757575";
container.appendChild(checkbox)
container.appendChild(label)
return container;
}
Graphs.Push.zoneData(); // update current zone data on request
this.update();
var universe = Graphs.Settings.universeSelection;
var selectedGraph = document.getElementById(`u${universe}graphSelection`);
if (selectedGraph.value) {
// draw the graph
var graph = this._lookupGraph(selectedGraph.value);
// create toggle elements
toggleDiv = document.querySelector("#toggleDiv")
toggleDiv.innerHTML = "";
if (graph.toggles) {
for (const toggle of graph.toggles) {
toggleDiv.appendChild(makeCheckbox(graph.id, toggle))
}
}
}
Graphs.UI.showHideUnused();
},
update: function () {
var universe = Graphs.Settings.universeSelection;
var selectedGraph = document.getElementById(`u${universe}graphSelection`);
if (selectedGraph.value) {
// draw the graph
var graph = this._lookupGraph(selectedGraph.value);
graph.updateGraph();
}
},
// Graph Selection
saveSelected: function () {
if (!this.chart) return;
for (var i = 0; i < this.chart.series.length; i++) {
Graphs.Settings.rememberSelected[i] = this.chart.series[i].visible;
}
Graphs.Backend.saveSetting();
},
applyRemembered: function () {
if (this.chart.series.length !== Graphs.Settings.rememberSelected.length) {
Graphs.Settings.rememberSelected = [] // if the graphlist changes, order is no longer guaranteed
}
for (var i = 0; i < this.chart.series.length; i++) {
if (Graphs.Settings.rememberSelected[i] === false) { this.chart.series[i].setVisible(false, false); }
}
this.chart.redraw()
},
toggleSpecific: function () {
for (const chart of this.chart.series) {
chart.visible ? chart.setVisible(false, false) : chart.setVisible(true, false);
}
this.chart.redraw();
},
toggleAll: function () {
// toggle all graphs to the opposite of the average visible/hidden state
var visCount = 0;
this.chart.series.forEach(chart => visCount += chart.visible)
for (const chart of this.chart.series) {
visCount > this.chart.series.length / 2 ? chart.setVisible(false, false) : chart.setVisible(true, false);
}
this.chart.redraw()
},
toggleNamed: function (name) {
// toggle all graphs that share the same name as the clicked graph to on
for (const chart of this.chart.series) {
// If the last word of the name matches, toggle it
if (chart.name.split(" ").pop() === name.split(" ").pop()) {
chart.setVisible(true, false);
} else {
chart.setVisible(false, false);
}
}
this.chart.redraw()
},
},
Push: {
zoneData: function () {
//debug("Starting Zone " + getGameData.world(), "graphs");
const portalID = Graphs.getportalID();
if (!Graphs.portalSaveData[portalID] || GraphsConfig.getGameData.world() === 1) { // reset portal data if restarting a portal
Graphs.Backend.savePortalData(true) // save old portal to history
Graphs.portalSaveData[portalID] = new Graphs.Portal();
Graphs.Backend.clearData(Graphs.Settings.maxGraphs); // clear out old portals
}
Graphs.portalSaveData[portalID].update();
Graphs.Backend.savePortalData(false) // save current portal
if (Graphs.Settings.live && Graphs.Settings.open) {
Graphs.ChartArea.update();
}
},
triggerData: function (updates = [[]],) {
const portalID = Graphs.getportalID();
try {
if (!Graphs.portalSaveData[portalID]) {
this.zoneData(); // create portal data if we somehow trigger a non-zone event without a portal created
console.debug("Current portal did not start logging correctly, restarting", portalID)
}
var perZoneData = Graphs.portalSaveData[portalID].perZoneData;
var world = GraphsConfig.getGameData.world();
for (var [name, value, cuum, accumulator, customx] of updates) {
if (customx) world = customx;
if (!perZoneData[name][world] && accumulator) perZoneData[name][world] += perZoneData[name][world - 1] || 0
if (cuum) perZoneData[name][world] = value + perZoneData[name][world] || 0;
else perZoneData[name][world] = value;
}
}
catch (e) {
console.debug("Failed to update: ", portalID, updates, e)
}
Graphs.Backend.savePortalData(false) // save current portal
if (Graphs.Settings.live && Graphs.Settings.open) {
Graphs.ChartArea.update();
}
},
mapData: function () {
this.triggerData([
["timeOnMap", GraphsConfig.getGameData.timeOnMap(), true, true],
["mapCount", 1, true, true]])
},
},
formatters: {
datetime: function () {
var ser = this.series;
return '<span style="color:' + ser.color + '" >●</span> ' + ser.name + ": <b>" + Graphs.formatters._formatDuration(this.y / 1000) + "</b><br>";
},
defaultPoint: function () {
var ser = this.series; // 'this' being the highcharts object that uses formatter()
return '<span style="color:' + ser.color + '" >●</span> ' + ser.name + ": <b>" + prettify(this.y) + "</b><br>";
},
defaultAxis: function () {
// These are Trimps format functions for durations(modified) and numbers, respectively
if (this.dateTimeLabelFormat) return Graphs.formatters._formatDuration(this.value / 1000)
else return prettify(this.value);
},
// returns _d _h _m _s or _._s
_formatDuration: function (timeSince) {
var timeObj = {
d: Math.floor(timeSince / 86400),
h: Math.floor(timeSince / 3600) % 24,
m: Math.floor(timeSince / 60) % 60,
s: Math.floor(timeSince % 60),
}
var milliseconds = Math.floor(timeSince % 1 * 10)
var timeString = "";
var unitsUsed = 0
for (const [unit, value] of Object.entries(timeObj)) {
if (value === 0 && timeString === "") continue;
unitsUsed++;
if (value) timeString += value.toString() + unit + " ";
}
if (unitsUsed <= 1) {
timeString = [timeObj.s.toString().padStart(1, "0"), milliseconds.toString(), "s"].join(".");
}
return timeString
},
},
Graph: function (dataVar, universe, selectorText, additionalParams = {}) {
// graphTitle, customFunction, useAccumulator, xTitle, yTitle, formatter, xminFloor, yminFloor, yType
this.dataVar = dataVar
this.universe = universe; // false, 1, 2
this.selectorText = selectorText ? selectorText : dataVar;
this.id = selectorText.replace(/ /g, "_")
this.graphTitle = this.selectorText;
this.graphType = "line"
this.customFunction;
this.useAccumulator;
this.xTitle = "Zone";
this.yTitle = this.selectorText;
this.formatter = Graphs.formatters.defaultPoint;
this.xminFloor = 1;
this.yminFloor;
this.yType = "Linear";
this.graphData = [];
this.typeCheck = "number"
this.conditional = () => { return true };
for (const [key, value] of Object.entries(additionalParams)) {
this[key] = value;
}
this.baseGraphTitle = this.graphTitle;
// create an object to pass to Highcharts.Chart
this.createHighChartsObj = function () {
return {
chart: {
renderTo: "graph",
zoomType: "xy",
animation: false,
shadow: false,
resetZoomButton: {
position: {
align: "right",
verticalAlign: "top",
x: -20,
y: 15,
},
relativeTo: "chart",
},
},
colors: ["#e60049", "#0bb4ff", "#50e991", "#e6d800", "#9b19f5", "#ffa300", "#dc0ab4", "#b3d4ff", "#00bfa0"],
title: {
text: this.graphTitle,
x: -20,
style: {
fontSize: '2rem'
}
},
boost: {
useGPUTranslations: true,
// Chart-level boost when there are more than 5 series in the chart
seriesThreshold: 101
},
plotOptions: {
series: {
lineWidth: 1,
animation: false,
marker: {
enabled: false,
},
},
},
xAxis: {
floor: this.xminFloor,
title: {
text: this.xTitle,
style: {
fontSize: "1.5rem"
},
},
labels: {
style: {
fontSize: "1.2rem"
},
},
},
yAxis: {
floor: this.yminFloor,
title: {
text: this.yTitle,
style: {
fontSize: "1.5rem"
},
},
plotLines: [
{
value: 0,
width: 1,
color: "#808080",
},
],
type: this.yType,
labels: {
formatter: Graphs.formatters.defaultAxis,
style: {
fontSize: "1.2rem"
},
},
endOnTick: false,
maxPadding: .05,
},
tooltip: {
animation: false,
shadow: false,
pointFormatter: this.formatter,
style: {
fontSize: "1.2rem"
},
},
legend: {
layout: "vertical",
align: "right",
verticalAlign: "middle",
borderWidth: 0,
padding: 0,
itemMarginBottom: 0,
itemMarginTop: 0,
itemStyle: {
fontSize: "1rem",
},
},
series: this.graphData,
additionalParams: {},
}
}
// Main Graphing function
this.updateGraph = function () {
var HighchartsObj;
if (this.graphType == "line") HighchartsObj = this.lineGraph();
if (this.graphType == "column") HighchartsObj = this.columnGraph();
Graphs.ChartArea.saveSelected();
Graphs.ChartArea.chart = new Highcharts.Chart(HighchartsObj);
Graphs.ChartArea.applyRemembered();
}
// prepares data series for Highcharts, and optionally transforms it with toggled options, customFunction and useAccumulator
this.lineGraph = function () {
var highChartsObj = this.createHighChartsObj() // make default object, to be customized as needed
var item = this.dataVar;
this.graphData = [];
this.useAccumulator = false; // HACKS ( only one set of graphs uses an accumulator and it's on a toggle )
var maxS3 = Math.max(...Object.values(Graphs.portalSaveData).map((portal) => portal.s3).filter((s3) => s3));
var activeToggles = [];
if (this.toggles) {
// Modify the chart area based on the toggles active
activeToggles = Object.keys(GraphsConfig.toggledGraphs).filter(toggle => Graphs.Settings.toggles[this.id][toggle])
activeToggles.forEach(toggle => GraphsConfig.toggledGraphs[toggle].graphMods(this, highChartsObj)); //
}
// get all possible active data vars
var activeDataVars = [item]
activeToggles.forEach(toggle => { if (GraphsConfig.toggledGraphs[toggle].dataVars) activeDataVars.push(GraphsConfig.toggledGraphs[toggle].dataVars) });
var portalCount = 0;
// parse data per portal
for (const portal of Object.values(Graphs.portalSaveData).reverse()) {
if (!activeDataVars.some(dvar => dvar in portal.perZoneData)) continue; // ignore completely blank
if (portal.universe != Graphs.Settings.universeSelection) continue; // ignore inactive universe
var cleanData = [];
var xprev = 0;
// parse the requested datavar
for (const zone in portal.perZoneData[item]) {
var x = portal.perZoneData[item][zone];
var time = portal.perZoneData.currentTime[zone];
if (typeof this.customFunction === "function") {
x = this.customFunction(portal, zone);
if (x < 0) x = null;
}
// TOGGLES
// handle toggles that replace whole data vars first
for (var toggle of activeToggles) {
if (["perZone", "perHr"].includes(toggle)) continue;
try { x = GraphsConfig.toggledGraphs[toggle].customFunction(portal, item, zone, x, time, maxS3, xprev); }
catch (e) {
x = 0;
Graphs.debugMsg(`Error graphing data on: ${item} ${toggle}, ${e.message}`)
}
}
// handle special time and X modifying toggles
originalx = x // save before modifiers for perZone use
if (activeToggles.includes("perZone")) { // must always be first
[x, time] = GraphsConfig.toggledGraphs.perZone.customFunction(portal, item, zone, x, false, false, xprev);
}
if (activeToggles.includes("perHr")) { // must always be first
x = GraphsConfig.toggledGraphs.perHr.customFunction(portal, item, zone, x, time, maxS3, xprev);
}
xprev = originalx;
//if (this.useAccumulator) { x += last(cleanData) !== undefined ? last(cleanData)[1] : 0; }
if (this.typeCheck && typeof x != this.typeCheck) x = null;
cleanData.push([Number(zone), x]) // highcharts expects number, number, not str, number
}
if (activeToggles.includes("perZone") && ["fluffy", "scruffy"].includes(item)) {
cleanData.splice(cleanData.length - 1); // current zone is too erratic to include due to weird order of granting fluffy exp
}
//check for empty data and discard portal
const uniqueData = new Set(cleanData.map(([zone, data]) => { return data }))
uniqueData.delete(null); uniqueData.delete(0);
if (uniqueData.size === 0) {
Graphs.debugMsg("u" + portal.universe, portal.totalPortals, item, "is blank, not displaying")
continue;
}
this.graphData.push({
name: `Portal ${portal.totalPortals}: ${portal.challenge}`,
data: cleanData,
zIndex: -portalCount,
events: {
legendItemClick: (e) => {
// Namespaced with trimps because we have no ownership of the object
// But it is persistent so it works
if (!e.target.trimpsLastClick || (Date.now() - e.target.trimpsLastClick) > 500) {
e.target.trimpsLastClick = Date.now();
} else {
e.preventDefault();
Graphs.ChartArea.toggleNamed(e.target.name)
}
}
}
})
portalCount++;
if (portalCount >= Graphs.Settings.portalsDisplayed) break;
}
highChartsObj.series = this.graphData;
return highChartsObj;
}
// prepares multi-column data series from per-portal data.
this.columnGraph = function () {
var highChartsObj = this.createHighChartsObj() // make default object, to be customized as needed
highChartsObj.xAxis.title.text = "Portal"
highChartsObj.xAxis.floor = 0;
highChartsObj.plotOptions.series = { groupPadding: .2, pointPadding: 0, animation: false, borderColor: "black" }
// set up axes for each column so they scale independently
var activeColumns = this.columns.filter(column => !(column.universe && column.universe != Graphs.Settings.universeSelection));
// disable columns that make no sense to show over time.
if (Graphs.Settings.toggles[this.id].perHr) {
let disabledCols = ["Run Time", "Initial Helium", "Initial Radon"] // time, and start-of-portal stats
GraphsConfig.toggledGraphs.perHr.graphMods(false, highChartsObj)
activeColumns = activeColumns.filter(column => !disabledCols.includes(column.title))
}
this.graphData = [];
var yAxis = 0;
var displayedColumns = [];
for (const column of activeColumns) {
var hasData = false;
var cleanData = []
var currUniPortals = Object.values(Graphs.portalSaveData).filter(portal => portal.universe == Graphs.Settings.universeSelection);
for (const portal of Object.values(currUniPortals).slice(Math.max(Object.values(currUniPortals).length - Graphs.Settings.portalsDisplayed, 0))) {