limit('1440') ->orderBy('created_at', 'desc') ->pluck('temperature'); $humidity = Stats::select('humidity') ->limit('1440') ->orderBy('created_at', 'desc') ->pluck('humidity'); $gm3 = Stats::select('gm3') ->limit('1440') ->orderBy('created_at', 'desc') ->pluck('gm3'); $created_at = Stats::select('created_at') ->limit('1440') ->orderBy('created_at', 'desc') ->pluck('created_at'); $latestTemp = Stats::select('temperature') ->orderBy('created_at', 'desc') ->limit('1') ->pluck('temperature'); $latestHumidity = Stats::select('humidity') ->orderBy('created_at', 'desc') ->limit('1') ->pluck('humidity'); $latestGM3 = Stats::select('gm3') ->orderBy('created_at', 'desc') ->limit('1') ->pluck('gm3'); $latestTemp = '' . $latestTemp[0]; $latestHumidity = '' . $latestHumidity[0]; $latestGM3 = '' . $latestGM3[0]; $latestShit = 'Temp: ' . $latestTemp . ' Hum: ' . $latestHumidity . ' g/m³: ' . $latestGM3; $chart = Charts::multi('line', 'material') ->title("Temperatur, Luftfeuchtigkeit, g/m³") ->dimensions(0, 400) // Width x Height // This defines a preset of colors already done:) ->template("material") // You could always set them manually // ->colors(['#2196F3', '#F44336', '#FFC107']) // Setup the diferent datasets (this is a multi chart) ->dataset('Temperatur', $temperature) ->dataset('Luftfeuchtigkeit', $humidity) ->dataset('g/m³', $gm3) // Setup what the values mean ->labels($created_at); return view('dashboard')->with([ 'pagetitle' => $pagetitle, 'activeNav' => $activeNav, 'chart' => $chart, 'latestTemp' => $latestTemp, 'latestHumidity' => $latestHumidity, 'latestGM3' => $latestGM3, 'latestShit' => $latestShit, ]); } }