i'm trying to get data to chart from the database. this how i wanted the data from database get row count according to the month in the date in Laravel
so i add that query. this is how controller looks like
class DashboardController extends Controller
{
public function admin()
{
$suppliers = SupplierData::all();
$repcounter= SalesRep::count();
$totalsales= SalesData::count();
$totalrevenue=SalesData::sum('total_price');
$chartdata = SalesData::selectRaw('COUNT(*) as count, YEAR(dateOfSale) year, MONTH(dateofSale) month')
->groupBy('year', 'month')
->get();
$chart=Charts::database($chartdata,'bar','highcharts')
->title("Sales Details")
->elementLabel("Total Sales")
->dimensions(1000,500)
->responsive(false);
return view('dashboard', compact('suppliers','repcounter','totalsales','totalrevenue','chart'));
}
and here is my html code part
<div>
{!! $chart->html() !!}
</div>
but this gives me empty chart. i don't know where i got it wrong. this is how it shows.
edited here is the console error,
Uncaught TypeError: Cannot read property 'querySelectorAll' of null
at Object.c.createSvg (chartist.min.js:8)
at e.d [as createChart] (chartist.min.js:8)
at e.h (chartist.min.js:8)