-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
816 lines (687 loc) · 26.5 KB
/
index.html
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
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/highcharts.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/highcharts-more.js"
integrity="sha256-x5API4J/vECCB8CNZv5h5onmdQNrA7I2qvc35XE3QO0=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/modules/boost.js"
integrity="sha256-CymzXFABoVZscOBGsQGzaIRHn/of09Xj2VuxPPeLPg8=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/modules/exporting.js"
integrity="sha256-yr/VcTNtv0Q6nAc7jMKmx/mmwu/51GNIvTGqrLNm9so=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/modules/offline-exporting.js" integrity="sha256-ctkyXnQruzgziWxhpoc/ebkzyZ3uiFAt7l0TRL3lrRk=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="generate.lead.url.js"></script>
<style>
.highcharts-legend-item {
font-family: 'Open Sans,sans-serif';
font-size: '1rem';
}
.highcharts-title {
font-family: 'Open Sans,sans-serif';
}
.highcharts-subtitle {
font-family: 'Open Sans,sans-serif';
}
.highcharts-axis-labels {
font-family: 'Open Sans,sans-serif';
}
.highcharts-tooltip {
font-family: 'Open Sans,sans-serif';
}
</style>
<!-- These are some inputs to the POST command to the function, these will come from the Database -->
<script>
Highcharts.setOptions({
lang: {
thousandsSep: ','
},
credits: {
enabled: false
},
colors: ['#2E93fA', '#66DA26', '#546E7A', '#E91E63', '#FF9800', '#00FFF5', '#9F00FF'],
exporting: {
enabled: true,
scale: 5,
buttons: {
contextButton: {
menuItems: ["downloadPNG", "downloadJPEG", "downloadPDF", "downloadSVG", "separator", "viewFullscreen", "printChart", 'downloadCSV', 'downloadXLS']
}
}
}
});
var minokperc = 70;
var preretire_stockallocation = 70;
var preretire_tbondallocation = 10;
var preretire_corpbondallocation = 20;
var preretire_cashallocation = 0;
var retire_stockallocation = 50;
var retire_tbondallocation = 20;
var retire_corpbondallocation = 20;
var retire_cashallocation = 10;
var age_to_start_adjust_pa = 70;
var age_to_end_adjust_pa = 80;
var client_birthmonth = 7;
var client_birthday = 22;
var client_birthyear = 1960;
var coclient_birthmonth = 7;
var coclient_birthday = 22;
var coclient_birthyear = 1960;
var maxagetoplan = 95;
var coclient_selected = true;
</script>
</head>
<body>
<p>Overview: Data for historical info comes from https://workers.eadvisor.app/gethistdata, Data for monte carlo (simulation) info comes from https://workers.eadvisor.app/getmcdata, Data for investment overview/social security/perc allocations/invest map comes from https://widgets.eadvisor.app/getoverview </p>
<p>Important Highcharts Note: Be sure to load Boost, More, Exporting, and Offline Exporting modules</p>
<br> <br><br>
<p>Link to view validation & fields for POST/GET requests: https://docs.google.com/spreadsheets/d/1EoeZUrTeCG4U1NN_s9dIaDiA4Fl9STOG_5UW2FQhHqk/edit?usp=sharing</p><br>
<input type="checkbox" id="sim_scenarios" value="1" oninput="runWorkers(this)" />Run Scenario GET/POST Request (when checked single scenario is loaded)<br><br>
<hr>
<figure class="highcharts-figure">
<p>Chart 200: Historical Area / When a scenario runs (checkbox at top) this is Chart 203.</p>
<p>Highchart options defined in: histarea.js</p>
<p>Note: functions needed to generate this & other charts located in: functions.for.frontend.js</p>
<div id="container-histarea"></div>
</figure>
<button onclick="zoominonworsthist()">Zoom in On Worst Years</button>
<button onclick="zoominonworsthistreset()">Reset Zoom</button>
<hr>
<figure class="highcharts-figure">
<p>Chart 100: Monte Carlo Area / When a scenario runs (checkbox at top) this is Chart 103</p>
<p>Highchart options defined in: mcarea.js</p>
<div id="container-mcarea"></div>
</figure>
<hr>
<div style="width: 100%; display: table;">
<div style="display: table-row">
<div style="width: 50%; display: table-cell;">
<figure class="highcharts-figure">
<p>Chart 101: Monte Carlo Percent / When a scenario runs (checkbox at top) this is Chart 104</p>
<p>Highchart options defined in: mcperc.js: var MCPAlive</p>
<div id="container-mcperc"></div>
</figure>
</div>
<div style="display: table-cell;">
<figure class="highcharts-figure">
<p>Chart 102: Monte Carlo Legacy Percent / When a scenario runs (checkbox at top) this is Chart 105</p>
<p>Highchart options defined in: mcperc.js: var MCPAliveLegacy</p>
<div id="container-mcperc-legacy"></div>
</figure>
</div>
</div>
</div>
<hr>
<div style="width: 100%; display: table;">
<div style="display: table-row">
<div style="width: 50%; display: table-cell;">
<figure class="highcharts-figure">
<p>Chart 201: Historical Percent / When a scenario runs (checkbox at top) this is Chart 204</p>
<p>Highchart options defined in: histperc.js: var HISTPAliveLegacy</p>
<div id="container-histperc"></div>
</figure>
</div>
<div style="display: table-cell;">
<figure class="highcharts-figure">
<p>Chart 202: Historical Legacy Percent / When a scenario runs (checkbox at top) this is Chart 205</p>
<p>Highchart options defined in: histperc.js: var HISTPAliveLegacy</p>
<div id="container-histperc-legacy"></div>
</figure>
</div>
</div>
</div>
<hr>
<figure class="highcharts-figure">
<p>Chart 150 & 151: P Alive Area (150 for all scenarios false, 151 for the scenario that is currently set as true)</p>
<p>Highchart options defined in: mcpalivearea.js</p>
<div id="palivechart"></div>
</figure>
<hr>
<figure class="highcharts-figure">
<p>Chart 260 & 261: Historical Spending Chart [260 is for all scenarios set to false, 261 is for the actively running scenario selected]</p>
<p>Highchart options defined in: spendingchart.js: var HISTSpending</p>
<div id="histyearlyspendingchart"></div>
</figure>
<hr>
<figure class="highcharts-figure">
<p>Chart 160 & 161: Monte Carlo Spending Chart [160 is for all scenarios set to false, 161 is for the actively running scenario selected]</p>
<p>Highchart options defined in: spendingchart.js: var MCSpending</p>
<div id="mcyearlyspendingchart"></div>
</figure>
<hr>
<div style="width: 100%; display: table;">
<p>Chart 500: % Allocation Chart & Chart 501 Glide Path [Note: to be displayed on the dashboard in accordian & on the cleint information entry on the Investment section]</p>
<p>Highchart options defined in: glidepath.js for the Area Chart & percentallocations.js for the pie charts (starting: var percallocation_preretire & ending: var percallocation_retire)</p>
<div style="display: table-row"></div>
<div style="width: 30%; display: table-cell;">
<figure class="highcharts-figure">
<div id="percallocations-preretire"></div>
</figure>
</div>
<div style="width: 30%; display: table-cell;">
<figure class="highcharts-figure">
<div id="percallocations-retire"></div>
</figure>
</div>
<div style="display: table-cell;">
<figure class="highcharts-figure">
<div id="container-glidechart"></div>
</figure>
</div>
</div>
</div>
<hr>
<h2>Below is the contents of the Marketing Tab</h2>
<p>This is the embed code they will be able to copy, this embed code is also live updating in the main box titled 'Live Form & Lead Generation Tool Rendered Here'</p>
<!--<p id="leadurloutputelement"></p>-->
<xmp id="leadurloutputelement1" style='padding:0px;margin:0px;white-space:nowrap'></xmp>
<script>
var leadurl_output = getLeadEmbedCode("[email protected]", 0, 1, 1); //1st field is email address they enter, 2nd field is a number corresponding to the lead form they select in the dropdown, 3rd field is the enable/disable form checkbox, 4th Field is the Compact Form option
console.log(leadurl_output);
//document.getElementById("leadurloutputelement").innerHTML = leadurl_output;
document.getElementById("leadurloutputelement1").innerHTML = leadurl_output;
</script>
<hr>
<hr>
<hr>
<h2>This is the Card: Simulation Text Description</h2>
<p id="mcworkertext"></p>
<hr>
<h2>This is the Card: Historical Text Description</h2>
<p id="histworkertext"></p>
<hr>
<h2>This is the Card: Financial Overview Text Description</h2>
<p id="financialoverviewtext"></p>
<hr>
<h2>This is the Card: Investment Overview Text Description</h2>
<p id="investmentoverviewtext"></p>
<hr>
<h2>This is the Card on Scenario Tab to describe the scenario being run</h2>
<p id="mcscenariodesc"></p>
<hr>
<h2>This is the Card on Historical Tab to describe the scenario being run</h2>
<p id="histscenariodesc"></p>
<hr>
<hr>
<h2>(Displayed on Social Security Overview Client Entry Area & Dashboard) Social Security Overview Text:</h2>
<p id="socialsecurityoverviewtext"></p>
<h2>(Not Displayed) Social Security Percentage of Full:</h2>
<p id="socialsecuritypercoffull"></p>
<h2>(Not Displayed) Social Security Percentage of Full (Widow):</h2>
<p id="socialsecuritypercoffullwidow"></p>
<hr>
<h2>This is the options for social security array (for everyone) - see source code to copy the array:</h2>
<p id="socialsecurityoptions"></p>
<script>
const socialsecuritydropdownoptions = [
'62',
'62 + 1 month',
'62 + 2 months',
'62 + 3 months',
'62 + 4 months',
'62 + 5 months',
'62 + 6 months',
'62 + 7 months',
'62 + 8 months',
'62 + 9 months',
'62 + 10 months',
'62 + 11 months',
'63',
'63 + 1 month',
'63 + 2 months',
'63 + 3 months',
'63 + 4 months',
'63 + 5 months',
'63 + 6 months',
'63 + 7 months',
'63 + 8 months',
'63 + 9 months',
'63 + 10 months',
'63 + 11 months',
'64',
'64 + 1 month',
'64 + 2 months',
'64 + 3 months',
'64 + 4 months',
'64 + 5 months',
'64 + 6 months',
'64 + 7 months',
'64 + 8 months',
'64 + 9 months',
'64 + 10 months',
'64 + 11 months',
'65',
'65 + 1 month',
'65 + 2 months',
'65 + 3 months',
'65 + 4 months',
'65 + 5 months',
'65 + 6 months',
'65 + 7 months',
'65 + 8 months',
'65 + 9 months',
'65 + 10 months',
'65 + 11 months',
'66',
'66 + 1 month',
'66 + 2 months',
'66 + 3 months',
'66 + 4 months',
'66 + 5 months',
'66 + 6 months',
'66 + 7 months',
'66 + 8 months',
'66 + 9 months',
'66 + 10 months',
'66 + 11 months',
'67',
'67 + 1 month',
'67 + 2 months',
'67 + 3 months',
'67 + 4 months',
'67 + 5 months',
'67 + 6 months',
'67 + 7 months',
'67 + 8 months',
'67 + 9 months',
'67 + 10 months',
'67 + 11 months',
'68',
'68 + 1 month',
'68 + 2 months',
'68 + 3 months',
'68 + 4 months',
'68 + 5 months',
'68 + 6 months',
'68 + 7 months',
'68 + 8 months',
'68 + 9 months',
'68 + 10 months',
'68 + 11 months',
'69',
'69 + 1 month',
'69 + 2 months',
'69 + 3 months',
'69 + 4 months',
'69 + 5 months',
'69 + 6 months',
'69 + 7 months',
'69 + 8 months',
'69 + 9 months',
'69 + 10 months',
'69 + 11 months',
'70'
];
document.getElementById("socialsecurityoptions").innerHTML = socialsecuritydropdownoptions;
</script>
<!--/////////////////////////////////////////////////////////////////////////////////////////////-->
<script src="functions.for.frontend.js"></script>
<script src="histarea.js"></script>
<script src="histperc.js"></script>
<script src="mcarea.js"></script>
<script src="mcperc.js"></script>
<script src="mcpalivearea.js"></script>
<script src="spendingchart.js"></script>
<script src="postoptions.js"></script>
<script src="postoptions_scenarios.js"></script>
<script src="getoptions.js"></script>
<script src="glidepath.js"></script>
<script src="percentallocations.js"></script>
<script>
////////////////////////////////////////////////////////////////////////
// POST Requests (https://workers.eadvisor.app/gethistdata/ is called the Historical & https://workers.eadvisor.app/getmcdata/ is called simulation or Monte Carlo)
function runWorkers(checkbox) {
//If it is checked.
if (checkbox.checked) {
var settingsHIST_scenarios = {
"url": "https://workers.eadvisor.app/gethistdata/",
"method": "POST",
"timeout": 0,
crossDomain: true,
"headers": {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
},
"data": JSON.stringify(postoptions_scenarios),
};
var settingsMC_scenarios = {
"url": "https://workers.eadvisor.app/getmcdata/",
"method": "POST",
"timeout": 0,
crossDomain: true,
"headers": {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
},
"data": JSON.stringify(postoptions_scenarios),
};
$.ajax(settingsHIST_scenarios).done(function (response) {
updateHISTCharts(response);
});
$.ajax(settingsMC_scenarios).done(function (response) {
updateMCCharts(response);
});
}
//If it has been unchecked.
else {
var settingsHIST = {
"url": "https://workers.eadvisor.app/gethistdata/",
"method": "POST",
"timeout": 0,
crossDomain: true,
"headers": {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
},
"data": JSON.stringify(postoptions),
};
var settingsMC = {
"url": "https://workers.eadvisor.app/getmcdata/",
"method": "POST",
"timeout": 0,
crossDomain: true,
"headers": {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
},
"data": JSON.stringify(postoptions),
};
$.ajax(settingsHIST).done(function (response) {
updateHISTCharts(response);
});
$.ajax(settingsMC).done(function (response) {
updateMCCharts(response);
});
}
// GET Request to Overview function
// Request sent to https://widgets.eadvisor.app/getoverview/ with parameters shown below
$.getJSON( "https://widgets.eadvisor.app/getoverview/", getoptionsforoverview,
function(data) {
updateOverviewData(data);
})
.fail(function() {
console.log( "error in get request to .../getoverview/" );
});
}
////////////////////////////////////////////////////////////////
// Updating Charts based on POST Results
function updateMCCharts(response) {
console.log(response);
// P Alive Chart (see mcperc.js for full chart definition)
var palive_mc_val = Number(response.palive);
if (palive_mc_val < 90) { palive_mc_val = Math.round(palive_mc_val); }
let gaugecolorval = perc2color(palive_mc_val, minokperc, 100, "FF");
console.log(gaugecolorval)
MCPAlive.update({
title: {
text: '<h2>' + palive_mc_val + '%</h2>'
},
plotOptions: {
pie: {
colors: [gaugecolorval, "#ffffff"]
}
},
series: [{
data: [
['', palive_mc_val],
['', 100 - palive_mc_val]
]
}]
});
// Legacy P Alive %
var palive_mc_val_legacy = Number(response.palive_legacy);
if (palive_mc_val_legacy < 90) { palive_mc_val = Math.round(palive_mc_val_legacy); }
gaugecolorval = perc2color(palive_mc_val_legacy, minokperc, 100, "FF");
MCPAliveLegacy.update({
title: {
text: '<h2>' + palive_mc_val_legacy + '%</h2>'
},
plotOptions: {
pie: {
colors: [gaugecolorval, "#ffffff"]
}
},
series: [{
data: [
['', palive_mc_val_legacy],
['', 100 - palive_mc_val_legacy]
]
}]
});
// MC Area Chart (see mcarea.js for definition)
//Create Highcharts compatible data
let xval = getXVALArray(response.q10.length);
q10q90 = transposefnc(toMatrix(xval.concat(response.q10).concat(response.q90), xval.length));
q25q75 = transposefnc(toMatrix(xval.concat(response.q25).concat(response.q75), xval.length));
q50 = transposefnc(toMatrix(xval.concat(response.q50), xval.length));
var MCArea_chart_max = getMaxOfArray(response.q75);
var MCArea_chart_min = getMinOfArray(response.q10);
if (MCArea_chart_min < 0) { MCArea_chart_min = 0; }
MCArea.update({
yAxis: {
min: MCArea_chart_min,
max: MCArea_chart_max
},
series: [
{
data: q50 // Average
},
{
data: q25q75 // 25-75%
},
{
data: q10q90 // 10-90%
}]
});
// MC P Alive Chart (see mcpalivearea.js for definition)
MCPAliveArea.update({
xAxis: {
categories: xval
},
series: [{
data: response.palive_chart
}]
});
// Spending & Witdhrawal Chart (see spendingchart.js for definitions)
const withdrawlratecalculated = divide2Arrays(response.spending, response.q50).map(x => x * 100);
MCSpending.update({
xAxis: {
categories: xval
},
series: [{
data: response.spending, // Net Spending/Income
}, {
data: withdrawlratecalculated, // Withdrawal Rate
}]
});
// Description from MC Worker
document.getElementById("mcworkertext").innerHTML = response.description_text;
// Scenario Description from MC Worker
document.getElementById("mcscenariodesc").innerHTML = response.scenario_text;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
var HISTArea_chart_zoomonworst = 1000000;
var HISTArea_chart_max = 1000000;
function updateHISTCharts(response) {
console.log(response);
// P Alive Chart (see histperc.js for full chart definition)
console.log(response.palive);
var palive_hist_val = Number(response.palive);
if (palive_hist_val < 90) { palive_hist_val = Math.round(palive_hist_val); }
let gaugecolorval = perc2color(palive_hist_val, minokperc, 100, "FF");
HISTPAlive.update({
title: {
text: '<h2>' + palive_hist_val + '%</h2>'
},
plotOptions: {
pie: {
colors: [gaugecolorval, "#ffffff"]
}
},
series: [{
data: [
['', palive_hist_val],
['', 100 - palive_hist_val]
]
}]
});
// Legacy P Alive %
var palive_hist_val_legacy = Number(response.palive_legacy);
if (palive_hist_val_legacy < 90) { palive_hist_val = Math.round(palive_hist_val_legacy); }
gaugecolorval = perc2color(palive_hist_val_legacy, minokperc, 100, "FF");
HISTPAliveLegacy.update({
title: {
text: '<h2>' + palive_hist_val_legacy + '%</h2>'
},
plotOptions: {
pie: {
colors: [gaugecolorval, "#ffffff"]
}
},
series: [{
data: [
['', palive_hist_val_legacy],
['', 100 - palive_hist_val_legacy]
]
}]
});
// Area Chart (see histarea.js for full chart definition)
//Create Highcharts compatible data
let xval = getXVALArray(response.averageresult.length);
var chart_averageresult = transposefnc(toMatrix(xval.concat(response.averageresult), xval.length));
var chart_worst = transposefnc(toMatrix(xval.concat(response.worstresult_1st), xval.length));
var chart_2ndworst = transposefnc(toMatrix(xval.concat(response.worstresult_2nd), xval.length));
var chart_3rdworst = transposefnc(toMatrix(xval.concat(response.worstresult_3rd), xval.length));
var chart_best = transposefnc(toMatrix(xval.concat(response.bestresult_1st), xval.length));
var chart_2ndbest = transposefnc(toMatrix(xval.concat(response.bestresult_2nd), xval.length));
var chart_3rdbest = transposefnc(toMatrix(xval.concat(response.bestresult_3rd), xval.length));
HISTArea_chart_max = getMaxOfArray(response.bestresult_1st);
var HISTArea_chart_min = getMinOfArray(response.worstresult_1st);
if (HISTArea_chart_min < 0) { HISTArea_chart_min = 0; }
HISTArea_chart_zoomonworst = getMaxOfArray(response.worstresult_3rd);
HISTArea.update({
yAxis: {
min: HISTArea_chart_min,
max: HISTArea_chart_max
},
series: [{
name: 'Worst Year (' + response.date_worstresult_1st + ')',
data: chart_worst // worst
}, {
name: '2nd Worst Year (' + response.date_worstresult_2nd + ')',
data: chart_2ndworst // 2nd worst
},
{
name: '3rd Worst Year (' + response.date_worstresult_3rd + ')',
data: chart_3rdworst // 3rd worst
}, {
name: 'Best Year (' + response.date_bestresult_1st + ')',
data: chart_best // best
}, {
name: '2nd Best Year (' + response.date_bestresult_2nd + ')',
data: chart_2ndbest // 2nd best
},
{
name: '3rd Best Year (' + response.date_bestresult_3rd + ')',
data: chart_3rdbest // 3rd best
}, {
data: chart_averageresult // Average
}]
});
// Spending & Witdhrawal Chart (see spendingchart.js for definitions)
const withdrawlratecalculated = divide2Arrays(response.spending, response.averageresult).map(x => x * 100);
HISTSpending.update({
xAxis: {
categories: xval
},
series: [{
data: response.spending, // Net Spending/Income
}, {
data: withdrawlratecalculated, // Withdrawal Rate
}]
});
// Text from HIST Worker
document.getElementById("histworkertext").innerHTML = response.description_text;
// Scenario Description from HIST Worker
document.getElementById("histscenariodesc").innerHTML = response.scenario_text;
}
function zoominonworsthist() {
HISTArea.update({
yAxis: {
max: HISTArea_chart_zoomonworst
}
})
};
function zoominonworsthistreset() {
HISTArea.update({
yAxis: {
max: HISTArea_chart_max
}
})
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// GET Request for overview function: https://widgets.eadvisor.app/getoverview/
function updateOverviewData(response) {
console.log(response);
// Financial overview HTML text
document.getElementById("financialoverviewtext").innerHTML = response.financial_overview;
// Investment overview HTML text
document.getElementById("investmentoverviewtext").innerHTML = response.investment_overview;
// Social Security overview HTML text
document.getElementById("socialsecurityoverviewtext").innerHTML = response.social_security_desc;
// Social Security % of Full #
document.getElementById("socialsecuritypercoffull").innerHTML = "For Client: " + response.social_security_percent_client + " for co-client: " + response.social_security_percent_coclient;
// Social Security % of Full for Widow #
document.getElementById("socialsecuritypercoffullwidow").innerHTML = "For Client: " + response.social_security_percentwidow_client + " for co-client: " + response.social_security_percentwidow_coclient;
// Percent Allocations (Pre-Retire Graph)
percallocation_preretire.update({
subtitle: {
text: response.startportadjust
},
series: [{
data: [{
y: response.percent_allocations_preretire[0] // Stock
}, {
y: response.percent_allocations_preretire[1] // T Bond
}, {
y: response.percent_allocations_preretire[2] // Corp Bond
}, {
y: response.percent_allocations_preretire[3] // Cash
}]
}]
});
// Percent Allocations (Retire Graph)
percallocation_retire.update({
subtitle: {
text: response.endportadjust
},
series: [{
data: [{
y: response.percent_allocations_retire[0] // Stock
}, {
y: response.percent_allocations_retire[1] // T Bond
}, {
y: response.percent_allocations_retire[2] // Corp Bond
}, {
y: response.percent_allocations_retire[3] // Cash
}]
}]
});
// Glide Path (chart 501) - percent allocation mapping
glidpathchart.update({
xAxis: {
categories: response.investment_map.xval // Years (X Axis)
},
series: [{
data: response.investment_map.stockpath // Stocks
}, {
data: response.investment_map.tbondpath // Treasury Bonds
}, {
data: response.investment_map.corpbondpath // Corporate Bonds
}, {
data: response.investment_map.cashpath // Cash
}]
});
}
</script>
</body>
</html>