Widget
A Widget object stores one dashboard component's Source, View, metric and display settings. Obtain widgets through Metrix's Widgets service when extending dashboard behaviour; use the Control Panel for ordinary widget configuration.
Properties
Type: string|int|null
The unique identifier for the widget.
Type: verbb\metrix\base\SourceInterface|null
The Source the widget reads from.
Type: verbb\metrix\models\View|null
The View the widget belongs to.
Type: string|null
Period class for data (unless inheriting the View range).
Type: bool|null
When true, use the View’s dashboard date range.
Type: string|null
Metric key for the widget.
Type: string|null
Dimension key (table/pie and similar).
Type: string|null
Normalised keys across providers.
Type: int|null
Layout width (1–3 thirds).
Type: string|null
Optional display labels.
Type: int|null
Optional row limit for table/pie-style widgets.
Methods
Returns: verbb\metrix\base\SourceInterface|null
Resolves the Widget's Source.
Assigns a Source object or configured Source handle.
Returns: verbb\metrix\models\View|null
Resolves the Widget's View.
Assigns a View object.
Returns: string|null
Returns the provider-native metric after resolving a canonical metric for the Widget's Source.
Returns: string|null
Returns the provider-native dimension after resolving a canonical dimension for the Widget's Source.
Returns: string|null
Returns the supplied global period when the Widget inherits the dashboard range, otherwise the Widget's configured period. An inheriting Widget with neither value uses Last 30 Days.
Returns: int
Returns the effective row limit for dimension widgets. The default is 10 and the maximum is 500.
The following example assigns a configured Source by handle and inspects the provider-native values Metrix will request:
$widget->setSource('analytics');
$metric = $widget->getResolvedMetric();
$dimension = $widget->getResolvedDimension();