Add buttons to open shareable data URLs
This commit is contained in:
parent
5cb8ca0732
commit
461097f046
|
@ -20,6 +20,22 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 20px 20px;
|
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>
|
</style>
|
||||||
<title>💩📈</title>
|
<title>💩📈</title>
|
||||||
</head>
|
</head>
|
||||||
|
@ -41,9 +57,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="chart">
|
<div class="chart">
|
||||||
<canvas id="northCanvas"></canvas>
|
<canvas id="northCanvas"></canvas>
|
||||||
|
<a class="share" id="northShare" href="about:blank" target="_blank">Share</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="chart">
|
<div class="chart">
|
||||||
<canvas id="southCanvas"></canvas>
|
<canvas id="southCanvas"></canvas>
|
||||||
|
<a class="share" id="southShare" href="about:blank" target="_blank">Share</a>
|
||||||
</div>
|
</div>
|
||||||
<script src="poopGraph.js"></script>
|
<script src="poopGraph.js"></script>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -133,6 +133,17 @@ function maxExcludingOmicron(data, start, end) {
|
||||||
return secondMax;
|
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) {
|
function plot(data) {
|
||||||
const northData = extractWithErrorBars(data, 'Northern');
|
const northData = extractWithErrorBars(data, 'Northern');
|
||||||
const southData = extractWithErrorBars(data, 'Southern');
|
const southData = extractWithErrorBars(data, 'Southern');
|
||||||
|
@ -329,4 +340,12 @@ function plot(data) {
|
||||||
cutOmicronInput.addEventListener('change', (e) => {
|
cutOmicronInput.addEventListener('change', (e) => {
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
|
const northShare = document.getElementById('northShare');
|
||||||
|
northShare.addEventListener('click', () => {
|
||||||
|
updateShareLink(northChart, northShare);
|
||||||
|
});
|
||||||
|
const southShare = document.getElementById('southShare');
|
||||||
|
southShare.addEventListener('click', () => {
|
||||||
|
updateShareLink(southChart, southShare);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue