feat: charts
This commit is contained in:
33
app/Livewire/Charts/Server.php
Normal file
33
app/Livewire/Charts/Server.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Charts;
|
||||
|
||||
use App\Models\Server as ModelsServer;
|
||||
use Livewire\Component;
|
||||
|
||||
class Server extends Component
|
||||
{
|
||||
public ModelsServer $server;
|
||||
public $chartId = 'server';
|
||||
public $data;
|
||||
public $categories;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.charts.server');
|
||||
}
|
||||
public function mount()
|
||||
{
|
||||
$this->loadData();
|
||||
}
|
||||
public function loadData()
|
||||
{
|
||||
$metrics = $this->server->getMetrics();
|
||||
$metrics = collect($metrics)->map(function ($metric) {
|
||||
return [$metric[0], $metric[1]];
|
||||
});
|
||||
$this->dispatch("refreshChartData-{$this->chartId}", [
|
||||
'seriesData' => $metrics,
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user