Skip to content

Instantly share code, notes, and snippets.

@blackode
Created October 3, 2020 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackode/fb452f1984feb40ff21b6771dd502d94 to your computer and use it in GitHub Desktop.
Save blackode/fb452f1984feb40ff21b6771dd502d94 to your computer and use it in GitHub Desktop.
A template to render the linecharr.js with dynamic data
<hr>
<h2> The Line Graph on Revenues & Years </h2>
<hr>
<div>
<canvas id="lineChart" width="100%" height="100%"></canvas>
</div>
<script type="text/javascript">
window.chart_data = <%= raw(Jason.encode!(fetch_chart_data @revenues)) %>
window.chart_labels = <%= raw(Jason.encode!(fetch_chart_labels @revenues)) %>
</script>
<script src='<%= Routes.static_path(@conn, "/js/linechart.js") %>' type="text/javascript"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment