defmodule Phoenix.LiveDashboard.ChartComponent do use Phoenix.LiveDashboard.Web, :live_component @default_prune_threshold 1_000 @default_bucket_size 20 @impl true def mount(socket) do {:ok, socket, temporary_assigns: [data: []]} end @impl true def update(assigns, socket) do {metric, assigns} = Map.pop(assigns, :metric) socket = if metric do kind = chart_kind(metric.__struct__) socket |> apply_metric(kind, metric) |> assign( title: chart_title(metric), description: metric.description, kind: kind, label: chart_label(metric), tags: Enum.join(metric.tags, "-"), unit: chart_unit(metric.unit), prune_threshold: prune_threshold(metric) ) else socket end {:ok, assign(socket, assigns)} end @impl true def render(assigns) do ~H"""