Compare commits

...

2 Commits

Author SHA1 Message Date
xenofem dec6b52394 update chrono 2022-10-22 22:52:06 -04:00
xenofem 461097f046 Add buttons to open shareable data URLs 2022-10-22 22:48:20 -04:00
3 changed files with 170 additions and 5 deletions

138
Cargo.lock generated
View File

@ -282,6 +282,15 @@ dependencies = [
"alloc-no-stdlib",
]
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]]
name = "askama_escape"
version = "0.10.3"
@ -416,14 +425,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.19"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
dependencies = [
"libc",
"iana-time-zone",
"js-sys",
"num-integer",
"num-traits",
"time 0.1.44",
"wasm-bindgen",
"winapi",
]
@ -436,6 +447,16 @@ dependencies = [
"generic-array",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
dependencies = [
"termcolor",
"unicode-width",
]
[[package]]
name = "colored"
version = "2.0.0"
@ -464,6 +485,12 @@ dependencies = [
"version_check",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "cpufeatures"
version = "0.2.2"
@ -519,6 +546,50 @@ dependencies = [
"syn",
]
[[package]]
name = "cxx"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e599641dff337570f6aa9c304ecca92341d30bf72e1c50287869ed6a36615a6"
dependencies = [
"cc",
"cxxbridge-flags",
"cxxbridge-macro",
"link-cplusplus",
]
[[package]]
name = "cxx-build"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60e2434bc22249c056e12d2e87db46380730da0f2648471edea3e8e11834a892"
dependencies = [
"cc",
"codespan-reporting",
"once_cell",
"proc-macro2",
"quote",
"scratch",
"syn",
]
[[package]]
name = "cxxbridge-flags"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3894ad0c6d517cb5a4ce8ec20b37cd0ea31b480fe582a104c5db67ae21270853"
[[package]]
name = "cxxbridge-macro"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34fa7e395dc1c001083c7eed28c8f0f0b5a225610f3b6284675f444af6fab86b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "deflate"
version = "0.9.1"
@ -936,6 +1007,30 @@ dependencies = [
"tokio-rustls",
]
[[package]]
name = "iana-time-zone"
version = "0.1.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5a6ef98976b22b3b7f2f3a806f858cb862044cfa66805aa3ad84cb3d3b785ed"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"winapi",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
dependencies = [
"cxx",
"cxx-build",
]
[[package]]
name = "idna"
version = "0.2.3"
@ -1037,9 +1132,18 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.121"
version = "0.2.135"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
[[package]]
name = "link-cplusplus"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369"
dependencies = [
"cc",
]
[[package]]
name = "local-channel"
@ -1680,6 +1784,12 @@ dependencies = [
"tendril",
]
[[package]]
name = "scratch"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
[[package]]
name = "sct"
version = "0.7.0"
@ -1920,6 +2030,15 @@ dependencies = [
"utf-8",
]
[[package]]
name = "termcolor"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
"winapi-util",
]
[[package]]
name = "thin-slice"
version = "0.1.1"
@ -2333,6 +2452,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"

View File

@ -20,6 +20,22 @@
align-items: center;
gap: 20px 20px;
}
canvas {
margin-bottom: 10px;
}
a.share {
font-family: sans-serif;
color: #000;
background-color: #ccc;
border: 1px solid #bbb;
border-radius: 4px;
padding: 6px 12px;
cursor: pointer;
text-decoration: none;
}
a.share:hover {
background-color: #aaa;
}
</style>
<title>💩📈</title>
</head>
@ -41,9 +57,11 @@
</div>
<div class="chart">
<canvas id="northCanvas"></canvas>
<a class="share" id="northShare" href="about:blank" target="_blank">Share</a>
</div>
<div class="chart">
<canvas id="southCanvas"></canvas>
<a class="share" id="southShare" href="about:blank" target="_blank">Share</a>
</div>
<script src="poopGraph.js"></script>
<div>

View File

@ -133,6 +133,17 @@ function maxExcludingOmicron(data, start, end) {
return secondMax;
}
function updateShareLink(chart, link) {
const ctx = chart.canvas.getContext('2d');
ctx.save();
ctx.globalCompositeOperation = 'destination-over';
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, chart.width, chart.height);
ctx.restore();
link.href = chart.canvas.toDataURL();
chart.update();
}
function plot(data) {
const northData = extractWithErrorBars(data, 'Northern');
const southData = extractWithErrorBars(data, 'Southern');
@ -329,4 +340,12 @@ function plot(data) {
cutOmicronInput.addEventListener('change', (e) => {
update();
});
const northShare = document.getElementById('northShare');
northShare.addEventListener('click', () => {
updateShareLink(northChart, northShare);
});
const southShare = document.getElementById('southShare');
southShare.addEventListener('click', () => {
updateShareLink(southChart, southShare);
});
}