Я хочу спросить, могу ли я использовать laravel-dompdf при рендеринге chartjs в pdf.Я пытаюсь код в контроллере
TotalsController
public function create(Request $request)
{
$recy = Recyclable::whereBetween('recycled_on', [$request->search1,$request->search2])->get();
$comp = Composing::whereBetween('composted_on', [$request->search1,$request->search2])->get();
$resi = Disposal::whereBetween('disposed_on', [$request->search1,$request->search2])->get();
$disposecollect = Disposecollect::where(DB::raw("(DATE_FORMAT(created_at, '%Y'))"),date('Y'))->get();
$totals = Charts::database($disposecollect,'bar','highcharts')
->title('ESWM Data')
->elementLabel("Total Weight in KGS")
->labels(['Recyclables','Compostables','Residuals'])
->dimensions(1000, 500)
->values([ $recy->sum('weight'), $comp->sum('weight'), $resi->sum('weight')])
->colors(["blue", "green", "gray"])
->responsive(false);
// Send data to the view using loadView function of PDF facade
$pdf = PDF::loadView('totalspdf', compact('totals'));
// If you want to store the generated pdf to the server then you can use the store function
$pdf->save(storage_path().'_filename.pdf');
// Finally, you can download the file using download function
return $pdf->download('overallreport.pdf');
}
totalspdf.blade.php
<!DOCTYPE html>
<html>
<head>
<h1 align="center">ECOTENEO</h1>
</head>
<body>
<h3 align="center">Overall Collection Graph</h3>
<br>
{!! $totals->render() !!}
</body>
</html>
Работает, но проблема в том, что диаграмма не отображается в PDF.