DonutChart

Donut Chart

A donut chart is generated by adding the --donut flag to the artisan command lit:chart {name}.

php artisan lit:chart SalesProductsChart --donut

Configuration

Which data is displayed in your chart is configured in the value method as shown below. Unlike other chart types, an array with the desired data must be returned.

public function value($query)
{
    return [
        $this->count((clone $query)->where('product', 't-shirt')),
        $this->count((clone $query)->where('product', 't-shirt')),
    ];
}

Possible methods:

return $this->count($query);
return $this->average($query, 'price');
return $this->min($query, 'price');
return $this->max($query, 'price');
return $this->sum($query, 'price');

For each array item that is returned in the value method, a label must be specified in the labels method:

public function labels(): array
{
    return [
        'T-shirt',
        'Jacket',
    ];
}
Join us on our discord server