$monthlySales = OrderProduct::selectRaw('sum(amount) as total_sales, month(created_at) as month, year(created_at) as year') ->groupBy('month', 'year') ->get();
$labels = $monthlySales->pluck('month')->toArray();
$data = $monthlySales->pluck('total_sales')->toArray();
this is the line graph
var xValues = ['January','Febuary','March','April','May','June','July','August','September','October','November','December']; var yValues = [];
new Chart("myChart", {
type: "line",
data: {
labels: xValues,
datasets: [{
fill: false,
lineTension: 0,
backgroundColor: "rgba(0,0,255,1.0)",
borderColor: "rgba(0,0,255,0.1)",
data: yValues
}]
},
options: {
legend: {display: false},
scales: {
yAxes: [{ticks: {min: 0, max:}}],
}
}
});
I tried to use for loop to make a array for the data but still no visible data or maybe I dont have enough data in database?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/LlVnt4N
via IFTTT
Aucun commentaire:
Enregistrer un commentaire