PHP code example of flatroy / nova-treemap-chart-card
1. Go to this page and download the library: Download flatroy/nova-treemap-chart-card library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flatroy / nova-treemap-chart-card example snippets
// 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],
];
}
...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.