diff --git a/index.html b/index.html index 92c87f6..9ca9726 100644 --- a/index.html +++ b/index.html @@ -44,14 +44,14 @@

Interactive race nutrition planner

Each marker can optionally have an "effect" range, specified by an offset and duration. This is useful for visualizing when certain nutritional items, like a coffee shot, will take effect.

Move markers up and down with "Track" for better visualization.

-
+
-
+
@@ -87,14 +87,11 @@

Interactive race nutrition planner

}; const margin = { top: 50, right: 100, bottom: 30, left: 30 }; - const width = window.innerWidth - margin.left - margin.right; - const height = 200 - margin.top - margin.bottom; + const svg = d3 .select("#timeline-container") .append("svg") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", `translate(${margin.left},${margin.top})`); @@ -154,6 +151,15 @@

Interactive race nutrition planner

} function render() { + // -20px for scroll. + const width = document.getElementById('timeline-container').clientWidth - margin.left - margin.right - 20; + const height = 200 - margin.top - margin.bottom; + d3 + .select("#timeline-container") + .select('svg') + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom); + svg.selectAll("circle").remove(); svg.selectAll("text").remove(); svg.selectAll("g").remove(); @@ -351,7 +357,7 @@

Interactive race nutrition planner

addCellInput(row, d.position, (v) => (d.position = v), "text", "border p-1 w-20"); addCellInput(row, d.start, (v) => (d.start = v), "text", "border p-1 w-20"); addCellInput(row, d.duration, (v) => (d.duration = v), "text", "border p-1 w-20"); - addCellTextArea(row, d.notes, (v) => (d.notes = v), "border"); + addCellTextArea(row, d.notes, (v) => (d.notes = v), "border w-72"); tbody.appendChild(row); }); @@ -593,6 +599,8 @@

Interactive race nutrition planner

render(); updateControls(); }, 0); + + window.addEventListener('resize', _.throttle(render, 500));