ExTeal.Metric.Partition behaviour (ExTeal v0.21.0) View Source
Partition metrics displays a pie chart of values.
Link to this section 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
Link to this section Types
Specs
Link to this section Callbacks
Specs
calculate(ExTeal.Metric.Request.t()) :: [result()]
Specs
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)
Link to this section Functions
Specs
By default sort the partition results by the group field