I have previously dabbled in rails a bit to develop a GUI for a database with very basic user authentication and various ways to navigate the data and display it.
Part of this is an external javascript package called phylocanvas.gl (https://www.phylocanvas.gl/) - which allows me to display phylogenetic trees (biological relationships).
The issue I am having is that the darn script only loads after a manual page refresh - which seems to be related to turbo. Now, being the rails noob that I am, I am very stuck. Any suggestions on how to modify the script to load when I open the page without manual reloading?
Snippet from the erb template:
<script>
const tree = new phylocanvas.PhylocanvasGL(
document.querySelector("#phylocanvas"),
{
size: { width: 1600, height: 800 },
source: `<%= @xref_analysis_partition.cluster_analysis.tree %>`,
type: phylocanvas.TreeTypes.Radial,
interactive: true,
showLabels: true,
showBranchLengths: true,
showLeafLabels: true,
fontSize: 10,
branchLabelsFontSize: 10,
styles: {
<% @profiles.each do |cp| %>
<% if @sample_colors.has_key?(cp.name) %>
<% colour = @sample_colors[cp.name] %>
<% else %>
<% colour = "997aae" %>
<% end %>
"<%= cp.name %>": { fillColour: "#<%= colour %>" , label: "<%= cp.name %>" },
<% end %>
},
}
);
</script>