flatroy / nova-treemap-chart-card
一个用于显示Treemap图表的Laravel Nova卡片
0.0.2
2022-07-20 17:22 UTC
Requires
- php: ^7.4|^8.0
README
此包允许您将三图字段添加到您的资源详情页面和Nova中的仪表板Nova。
免责声明
此包仍在开发中。欢迎帮助改进它。
要求
安装
只需运行
composer require flatroy/nova-treemap-chart-card
安装后,您可以使用此处列出的组件。
基本用法
// in App\Nova\User ... use Flatroy\NovaTreemapChartCard\NovaTreemapChartCard; ... /** * Get the fields displayed by the resource. * * @param \Laravel\Nova\Http\Requests\NovaRequest $request * @return array */ public function fields(NovaRequest $request) { $data = [ ['x' => 'Design', 'y' => 0.051], ['x' => 'Accounting', 'y' => 0.050], ['x' => 'Data Science', 'y' => 0.048], ['x' => 'Marketing', 'y' => 0.046], ['x' => 'Quality Assurance', 'y' => 0.046], ['x' => 'R&D', 'y' => 0.046], ]; return [ ... (new NovaTreemapChartCard()) ->title('Some custom title') ->series($data) ->onlyOnDetail(), // or you can use like that: (new NovaTreemapChartCard()) ->title('Some other custom title') ->series($this->model()?->find($request->resourceId)?->chartData) ->onlyOnDetail(), // or you can suggest how to do it better? ... ]; } // if you want to put logic inside model - add this inside model: namespace App\Models; ... class User extends Model { ... protected function getChartDataAttribute() { return [ ['x' => 'Design', 'y' => 0.051], ['x' => 'Accounting', 'y' => 0.050], ['x' => 'Data Science', 'y' => 0.048], ['x' => 'Marketing', 'y' => 0.046], ['x' => 'Quality Assurance', 'y' => 0.046], ['x' => 'R&D', 'y' => 0.046], ]; } ... }
请随时提出改进建议。