Packages

Athena Event Logistics - Backend / Web

Current section

Files

Jump to
athena_logistics lib athena_web frontend live chart.ex
Raw

lib/athena_web/frontend/live/chart.ex

defmodule AthenaWeb.Chart do
@moduledoc false
use AthenaWeb, :component
def chart(assigns) do
~H"""
<div>
<%= content_tag(
:div,
"",
id: @dom_id <> "_hook",
"phx-hook": "Chart",
hidden: true,
data: [
chart:
@config
|> Map.put(:id, @dom_id <> "_chart")
|> Map.update(:chart, %{height: "50%"}, &Map.put_new(&1, :height, "50%"))
|> Jason.encode!()
]
) %>
<div phx-update="ignore" id={"#{@dom_id}_ignore"} class="position-relative chart-container">
<canvas id={"#{@dom_id}_chart"} />
</div>
</div>
"""
end
end