I'm sending a json via javascript and I send them to the laravel driver, all right up there but when I go back to elaborate the graphic in the lower part it shows me some numbers but not the dates and I do not know what I have to do to show me the numbers, here I leave the codes
$("#elaborar_grafica_anual").click(elaborar_grafica_anual);
function elaborar_grafica_anual() {
var datachart = new Array();
var desde_anual = $("#desde_anual").val();
var hasta_anual = $("#hasta_anual").val();
var token = $("#token").val();
var json ={
desde: desde_anual,
hasta: hasta_anual
}
// console.log(json);
if (desde_anual == '' || hasta_anual == '') {
swal({
title:"Las Fechas Deben ser Obligatorias.",
text:'',
type:'warning',
showCancelButton:false,
confirmButtonClass:'btn-warning',
confirmButtonText:'Corregir',
});
}else{
$.ajax({
method:'POST',
headers: {'X-CSRF-TOKEN': token},
url:'http://201.236.212.130:82/intranetcercafe/public/admin/report_precebo_anual',
data:json
}).done(function (msg) {
datachart=msg.data;
if (datachart.length == 0) {
swal('No hay Resultados','','error');
}else{
console.log(msg);
Highcharts.chart('grafica', {
chart: {
type: 'column'
},
title: {
text: 'Reportes de la Conversion Ajustada'
},
xAxis: {
type: 'category',
labels: {
rotation: -45,
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif'
}
}
},
yAxis: {
min: 0,
title: {
text: 'Conversion Ajustada Final.'
}
},
legend: {
enabled: false
},
tooltip: {
pointFormat: 'Conversion Final: <b>{point.y} </b>'
},
series: [{
name: 'Conversion Ajustada Final',
data: datachart
,
dataLabels: {
enabled: true,
rotation: -90,
color: '#FFFFFF',
align: 'right',
format: '{point.y}', // one decimal
y: 10, // 10 pixels down from the top
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif'
}
}
}]
});
}
});
}
}
laravel driver code
public function grafica_anual(Request $request)
{
if ($request->ajax()) {
$collection = Precebo::select('año_destete', DB::raw('sum(numero_inicial) as total'))
->whereBetween('año_destete',[$request->desde,$request->hasta])
->groupBy('año_destete')
->orderBy('año_destete','desc')->get();
$arrayT = [];
foreach ($collection as $value) {
$arrayT[] = [$value->año_destete,$value->total];
}
// dd($arrayT);
return response()->json(['status'=>'success','data'=>$arrayT],200);
}
}