PHPackages                             square1/nova-metrics - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. square1/nova-metrics

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

square1/nova-metrics
====================

Add support for resource-filters on your laravel nova metrics

1.0.0(6y ago)27278.7k↓16%4[6 issues](https://github.com/square1-io/nova-metrics/issues)[1 PRs](https://github.com/square1-io/nova-metrics/pulls)MITPHPPHP &gt;=7.1.0

Since Feb 3Pushed 5y ago7 watchersCompare

[ Source](https://github.com/square1-io/nova-metrics)[ Packagist](https://packagist.org/packages/square1/nova-metrics)[ RSS](/packages/square1-nova-metrics/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Custom Nova Metrics Components
==============================

[](#custom-nova-metrics-components)

This package will allow you to access your resource-filters on any Laravel Nova Metric class, and will update these cards dynamically every time you select a new filter on your resources-list.

---

Charts are a great way to display graphic information on your dashboard, and with Laravel Nova you can create beautiful **Metrics Cards** really fast.

You can use these charts on your resource views as well.

[![Custom Trend](./img/custom-trend.png "CustomTrend")](./img/custom-trend.png)

Usually when you add those metrics to any resource, you'd expect the chart to be a representation of the data you are seeing in the list down below. Currently on Nova this is not possible - when you change a filter selection, the resources-list is updated, but the corresponding charts are not.

[![Custom Trend](./img/metrics-before.gif "Nova Filters")](./img/metrics-before.gif)

This happens because the requests to populate the list are independent from the request used to get the metrics-data. This means that updating the filters breaks the connection with the charts, leaving them outdated.

This package restores that connection, ensuring that the charts and data on-screen remain in sync.

[![Custom Trend](./img/after.gif "Nova Filters")](./img/after.gif)

Install
-------

[](#install)

Install via composer

```
composer require square1/nova-metrics
```

Usage
-----

[](#usage)

You can create new metrics using the default nova commands:

```
php artisan nova:partition NewPartition
php artisan nova:trend NewTrend
php artisan nova:value NewValue
```

Then you only need to update your recently created metric class. Extend from one of the following classes to have access to your resource filters:

```
use Square1\NovaMetrics\CustomTrend;
use Square1\NovaMetrics\CustomValue;
use Square1\NovaMetrics\CustomPartition;
```

For example:

```
