<% if @serve_static %> const data = <%= JSON.generate(@values) %>; <% else %> (async () => { const data = await (await fetch("/values")).json(); const suggestions = await (await fetch("/suggestions")).json(); const suggestHTML = suggestions.map(sugg => `${sugg.file_path}${sugg.x}${Math.round(sugg.y)}${Math.round(sugg.x * sugg.y)}`).join(); document.querySelector("#suggestions-table").innerHTML = suggestHTML; <% end %> const svg = chart(data); <% if @serve_static %> document.addEventListener('DOMContentLoaded', () => { document.querySelector('#graph').appendChild(svg.node()); }); <% else %> document.querySelector('#graph').appendChild(svg.node()); })(); <% end %>