View Source Backpex.Metric behaviour (Backpex v0.10.0)

Behaviour implemented by all metrics.

Metrics are info boxes for your resources displaying key indicators prominently on the index view in your application. An example could be to show the current total of all orders received today. You may create your own metrics by implementing this behaviour.

Summary

Callbacks

Used to render the metric as a heex template on the index views.

Functions

Builds string of css classes for basic metric box

Determine if metrics are visible for given live_resource.

Callbacks

format(data, format)

@callback format(data :: any(), format :: any()) :: term()

query(query, select, repo)

@callback query(query :: Ecto.Queryable.t(), select :: any(), repo :: Ecto.Repo.t()) ::
  Ecto.Schema.t() | term() | nil

render(assigns)

@callback render(assigns :: map()) :: %Phoenix.LiveView.Rendered{
  caller: term(),
  dynamic: term(),
  fingerprint: term(),
  root: term(),
  static: term()
}

Used to render the metric as a heex template on the index views.

Functions

metric_box_class(metric)

Builds string of css classes for basic metric box

metrics_visible?(visibility, resource)

Determine if metrics are visible for given live_resource.