Pass more than two data in laravel and highcharts

0

I'm running a query by laravel to bring me an average consumption, and the months according to the parameter that I'm sending that is the year, to show them in highcharts shows me but I want you to show me the sum of the initial number , is there any way to show me these three data in the graph, I want you to show me the average consumption, the initial_summary and the months

public function report_precebo_anual_consumo_promedio(Request $request)
{

    $collection = Precebo::select(DB::raw('date_format(str_to_date(mes_traslado,"%m") ,"%M") as mes,avg(cons_promedio_ini) as total'))
    ->where('año_destete',[$request->ano])
    ->groupBy(DB::raw('date_format(str_to_date(mes_traslado,"%m"),"%m")'))->get();

    $months = ['January'=>'enero','February'=>'febrero','March'=>'marzo','April'=>'abril','May'=>'mayo','June'=>'junio','July'=>'julio','August'=>'agosto','September'=> 'septiembre','October'=>'octubre','November'=>'noviembre','December'=>'diciembre'];
    $arrayT = [];
    foreach ($collection as $value) {
        $arrayT[] = [$months[$value->mes],$value->total];
    }
    // dd($arrayT);
    return response()->json(['status'=>'success','data'=>$arrayT],200); 
}

and this is the image that shows when plotting it

is there any way you can show me the initial number ??

I will also leave you the SQL query I do

SELECT DATE_FORMAT(STR_TO_DATE(mes_traslado,"%m") ,"%M") AS mes,
AVG(cons_promedio_ini) AS total FROM formulario_precebo
WHERE año_destete = '2017' GROUP BY mes_traslado ORDER BY 
DATE_FORMAT(STR_TO_DATE(mes_traslado, '%m'), '%m');

what is month_translated and cons_average_ini are two of 30 fields that that table has (I think they are 30).

    
asked by Juan Esteban Yarce 01.03.2018 в 17:16
source

0 answers