Lots of changes
This commit is contained in:
@@ -15,13 +15,26 @@ public function __construct(LarapexChart $chart)
|
||||
|
||||
public function build($options = null)
|
||||
{
|
||||
$data = \App\Models\ClientCase::query()
|
||||
->selectRaw('EXTRACT(MONTH from created_at) as month, COUNT(id) as count')
|
||||
->limit(6)
|
||||
->whereRaw('EXTRACT(MONTH from created_at) > EXTRACT(MONTH from (NOW() - INTERVAL \'6 month\')) ')
|
||||
->groupByRaw('EXTRACT(MONTH from created_at)')
|
||||
->orderByRaw('EXTRACT(MONTH from created_at)')
|
||||
->get();
|
||||
|
||||
$months = $data->pluck('month')->map(
|
||||
fn($nu)
|
||||
=> \DateTime::createFromFormat('!m', $nu)->format('F'))->toArray();
|
||||
|
||||
$newCases = $data->pluck('count')->toArray();
|
||||
|
||||
return $this->chart->areaChart()
|
||||
->setTitle('Contracts during last six months.')
|
||||
->setSubtitle('New and Completed.')
|
||||
->addData('New', [4, 9, 5, 2, 1, 8])
|
||||
->addData('Completed', [7, 2, 7, 2, 5, 4])
|
||||
->setTitle('Cases during last six months.')
|
||||
->addData('New cases', $newCases)
|
||||
//->addData('Completed', [7, 2, 7, 2, 5, 4])
|
||||
->setColors(['#1A56DB', '#ff6384'])
|
||||
->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
|
||||
->setXAxis($months)
|
||||
->setToolbar(true)
|
||||
->toVue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user