Charts
Labels
Labels represent the grouping or axis field within a chart. They define the categories or time periods along which your datasets are plotted (e.g., dates, months, product categories).
Label
The Label class is a Visualizable that defines the grouping expression for your chart data.
php
use SettleUp\Visualizations\Charts\Labels\Label;
public function getLabel(): Label
{
return Label::make('DATE_FORMAT(orders.created_at, "%Y-%m")', 'Month');
}The first argument is the SQL expression, and the second is the field name that will appear in the output and schema.
Custom Header
By default, the header displayed to the front end matches the field name. You can override it:
php
Label::make('DATE_FORMAT(orders.created_at, "%Y-%m")', 'Month')
->header('Order Month');NullLabel
Some chart types (such as pie charts) don't have a label axis. In these cases, use NullLabel:
php
use SettleUp\Visualizations\Charts\Labels\NullLabel;
public function getLabel(): Label
{
return NullLabel::create();
}The NullLabel serializes as an empty object in the schema and does not add a select expression to the query.