Skip to content

Commit

Permalink
Restore $missingDataLabels default value
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseekn committed May 6, 2024
1 parent 95ac629 commit 0bad178
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/DatesFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ protected function getLabelsData(): array
$result = [];

$labelColumn = explode('.', $this->labelColumn)[1];
$missingDataLabels = DB::table($this->table)->get()->pluck($labelColumn)->toArray();

$missingDataLabels = empty($this->missingDataLabels)
? DB::table($this->table)->get()->pluck($labelColumn)->toArray()
: $this->missingDataLabels;

foreach ($missingDataLabels as $label) {
$result[$label] = $this->missingDataValue;
Expand Down
7 changes: 5 additions & 2 deletions src/LaravelMetrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class LaravelMetrics

protected bool $fillMissingData = false;

protected array $missingDataLabels = [];

protected int $missingDataValue = 0;

protected string $groupBy;
Expand Down Expand Up @@ -441,10 +443,11 @@ public function labelColumn(string $column): self
return $this;
}

public function fillMissingData(int $missingDataValue = 0): self
public function fillMissingData(int $missingDataValue = 0, array $missingDataLabels = []): self
{
$this->fillMissingData = true;
$this->missingDataValue = $missingDataValue;
$this->missingDataLabels = $missingDataLabels;

return $this;
}
Expand Down Expand Up @@ -592,7 +595,7 @@ protected function asData(): string
return "$this->aggregate($this->column) as data";
}

protected function asLabel(string $label = null, bool $format = true): string
protected function asLabel(?string $label = null, bool $format = true): string
{
if (is_null($this->labelColumn)) {
$label = ! $format ? $label : $this->formatPeriod($label);
Expand Down

0 comments on commit 0bad178

Please sign in to comment.