iaotle/nova-bar-metrics
Composer 安装命令:
composer require iaotle/nova-bar-metrics
包简介
A Laravel Nova tool for bar chart metrics and frequency distributions.
README 文档
README
A Laravel Nova tool for bar chart metrics and frequency distributions
This Nova tool lets you:
- create bar charts
- create frequency distribution charts (using pie charts and/or bar charts)
Bar Chart Metric Screenshot
Frequency Distribution Metric Screenshot (Bar Chart)
Frequency Distribution Metric Screenshot (Pie Chart)
Bar Chart Metrics
For a bar chart metric, just create a metric class like you normally would for a Partition metric. All the available methods in a Partition metric are also available for BarChartMetric! Instead of extending Partition you would just need to extend BarChartMetric like so:
use Insenseanalytics\NovaBarMetrics\BarChartMetric; class BrandsPerCategory extends BarChartMetric { public function calculate(Request $request) { return $this->count($request, BrandCategory::class, 'category_name'); } }
You can also use the suffix, prefix, dollars and euros methods like in a TrendMetric in Laravel Nova. Besides this, we also have a precision method to set the precision of the avg metric shown in the top right corner of the bar chart.
Frequency Distributions for Bar Chart Metrics and Partition Metrics
To create a frequency distributions chart, either extend the BarChartMetric class or extend the Partition class and use the trait HasFrequencyDistributions. You can use the distributions helper method to create the frequency distribution chart like so:
Example for BarChartMetric
use Insenseanalytics\NovaBarMetrics\BarChartMetric; class BrandFacebookFollowers extends BarChartMetric { public function calculate(Request $request) { return $this->distributions($request, Brand::class, 'facebook_followers', 100000); } }
In the example above, 100000 is the step size to use for the ranges in the frequency distribution and facebook_followers is the column to distribute by ranges.
Instead of providing the step size, you may provide the max number of steps instead using the distributionsWithSteps method and the package would automatically calculate the step size like so:
use Insenseanalytics\NovaBarMetrics\BarChartMetric; class BrandFacebookFollowers extends BarChartMetric { public function calculate(Request $request) { return $this->distributionsWithSteps($request, Brand::class, 'facebook_followers', 15); } }
For friendly formatted ranges (K for thousands, M for millions, B for billions), you can use the withFormattedRangeLabels method like so:
public function calculate(Request $request) { return $this->distributions($request, Brand::class, 'facebook_followers', 100000) ->withFormattedRangeLabels(); }
Example for Partition Metric
use Laravel\Nova\Metrics\Partition; use Insenseanalytics\NovaBarMetrics\HasFrequencyDistributions; class BrandFacebookFollowers extends Partition { use HasFrequencyDistributions; public function calculate(Request $request) { return $this->distributions($request, Brand::class, 'facebook_followers', 100000); } }
Requirements & Dependencies
There are no PHP dependencies except the Laravel Nova package. On the frontend JS, this package uses vue, chartist, chartist-plugin-tooltips and laravel-nova, all of which are also used by Nova itself.
Installation
You can install this tool into a Laravel app that uses Nova via composer:
composer require insenseanalytics/nova-bar-metrics
Next, if you do not have package discovery enabled, you need to register the provider in the config/app.php file.
'providers' => [ ..., Insenseanalytics\NovaBarMetrics\NovaBarMetricsServiceProvider::class, ]
Usage
You can use the console command php artisan nova:barmetric <classname> to create new BarMetric classes
Contributing
Contributions are welcome and will be fully credited as long as you use PSR-2, explain the issue/feature that you want to solve/add and back your code up with tests. Happy coding!
License
The MIT License (MIT). Please see License File for more information.
iaotle/nova-bar-metrics 适用场景与选型建议
iaotle/nova-bar-metrics 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nova」 「laravel」 「bar chart」 「frequency distributions」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 iaotle/nova-bar-metrics 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 iaotle/nova-bar-metrics 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 iaotle/nova-bar-metrics 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bar with versions list of vendor libraries for Tracy
A Laravel Nova card that shows you your system information.
Simple PHP chart drawing library
A Laravel Nova card.
A fork of runcmf/runtracy
A Laravel Nova package for publishable fields
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-08