Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<![endif]-->
<section class="data-vis responsive" id="chart"></section>

<nav id="footer">
<!-- <nav id="footer">
<a href="https://www.datavisualizationsociety.org/" target=_blank>
<img src="./src/globals/styles/images/dvs.png" /> </a>
<div>Made with ♥ by Mia Szarvas. Thank you to my teammates at Two-N for the help and advice.</div>
<a href="https://two-n.com/" target=_blank>
<img src="./src/globals/styles/images/2N-logo.svg" /> </a>
</nav>
</nav> -->
</div>
<script src="./index.js" type="module" async defer></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chart/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ body {

.disclaimer {
font-size: $fontSizeXSmall;
margin-top: 50px;
margin: 50px 0;
text-align: justify;
strong {
font-size: $fontSizeXSmall;
Expand Down
2 changes: 1 addition & 1 deletion src/globals/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const TEXT = {
EMPTY: "Sorry, there is no data for your selected filters.",
WEALTH: `in wealth over 30 years,
assuming you invest that amount today in an index fund tracking the S&P 500.
This is assuming an inflation adjusted return of over year,
This is assuming an inflation adjusted return of 8.29% year over year,
as is the historical return of the S&P 500.`,
TOGGLE: { color: "Color Blind Mode", gray: "gray" }
}
Expand Down
14 changes: 13 additions & 1 deletion src/globals/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,26 @@ const getAreaData = (gap) => {
return [lineData, wealth_sum, growth, loss]
}


// source https://observablehq.com/@hugodf/add-days-to-a-javascript-date
function addDays(date, days) {
const copy = new Date(Number(date))
copy.setDate(date.getDate() + days)
return copy
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool fix!

const getDonutData = (gapPercent) => {
// typical number of work days in a year
const WORK_DAYS = 262
// days extra worked to add to date
const days = 365 * gapPercent

// start counting from Jan 1st of this year
const new_year = new Date(new Date().getFullYear(), 0, 1)
const date = FORMATTERS.date(new Date().setDate(new_year.getDate() + days))

const unformattedDate = addDays(new_year, days)

const date = FORMATTERS.date(unformattedDate)

// always fill array for outer donut
const donutData = [{ type: "worked_days", value: WORK_DAYS + gapPercent * WORK_DAYS }]
Expand Down