Skip to content

Commit 2f6f509

Browse files
committed
- Added option to pass custom metrics list to component
1 parent 176b856 commit 2f6f509

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

docs/time-series/model-specific-stats.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ The `stats::time-series` component accepts the following attributes:
108108
- **`filters`**: Associative array of filter values.
109109
- **`api-url`**: The API url to call for generating the stats graph. Defaults to the route defined by `TimeSeriesStats::registerApiRoute`.
110110
- **`user`**: The user who you want to display the stats for. Defaults to the current user.
111+
- **`metrics`**: Key-Value array of metrics to show. Defaults to the metrics visible to the given user for the given filters.
111112
- **`framework`**: Which CSS framework to use. Defaults to framework defined in the package config.
112113

113114
# Add links

src/Views/Components/TimeSeries.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct(
2626
string $url = '',
2727
string $apiUrl = '',
2828
array $filters = [],
29+
array $metrics = [],
2930
?Authorizable $user = null,
3031
string $framework = ''
3132
) {
@@ -35,6 +36,6 @@ public function __construct(
3536
$this->user = $user ?: auth()->user();
3637
$this->url = $url ?: action([TimeSeriesStatsController::class, 'export']);
3738
$this->apiUrl = $apiUrl ?: action([TimeSeriesStatsApiController::class, 'index']);
38-
$this->metrics = TimeSeriesStats::getMetricNames($this->filters, $this->user);
39+
$this->metrics = $metrics ?: TimeSeriesStats::getMetricNames($this->filters, $this->user);
3940
}
4041
}

0 commit comments

Comments
 (0)