Any way to use phx-hook in a eex template?

Hey there,

I am trying to render a pdf with a chart in it with an eex template, but I am only getting an empty canvas.

<html><h1>from template <%= @total_zones %></h1>

<%= if @chart_config do %>
<div phx-hook="ChartJS" data-chart-config="<%= Jason.encode!(@chart_config) %>" id="zoning_summary_chart">
  <canvas width="300" height="300" ></canvas>
<% end %>


I have this chart working in another live component for the user.

Any tips?


Outside liveview it will not be working… but You still can do it in JS, and it does not look too complicated to do so.

I have not used Chart.js, and cannot help You more.

1 Like