View Source ExTeal.Metric.Partition behaviour (ExTeal v0.27.0)
Partition metrics displays a pie chart of values.
Summary
Callbacks
Often, the column values that divide your partition metrics into
groups will be simple keys, and not something that is human readable.
Or, if you are displaying a partition metric grouped by a column that is a
boolean, Teal will display labels as "false" and "true". For this reason, Teal
provides the label_for/1
callback that can be overriden on a partition metric
to provide a custom label for each value.
Functions
By default sort the partition results by the group field
Types
Callbacks
@callback calculate(ExTeal.Metric.Request.t()) :: [result()]
Often, the column values that divide your partition metrics into
groups will be simple keys, and not something that is human readable.
Or, if you are displaying a partition metric grouped by a column that is a
boolean, Teal will display labels as "false" and "true". For this reason, Teal
provides the label_for/1
callback that can be overriden on a partition metric
to provide a custom label for each value.
@impl true
def label_for(false), do: "User"
def label_for(true), do: "Admin"
It's also useful for handling null values:
@impl true
def label_for(null), do: "None"
def label_for(key), do: String.capitalize(key)
Functions
By default sort the partition results by the group field