public function sectorCapsPieChart($numberOfSectors)
 {
     $graphData = SectorHistoricals::getAllSectorGraphData($numberOfSectors);
     $sectorCaps = \Lava::DataTable();
     $sectorCaps->addStringColumn('Sector Name')->addNumberColumn('Percent')->addRows($graphData);
     return $sectorCaps->toJson();
 }
 /**
  * Admin dashboard
  *
  */
 public function getIndex()
 {
     $results = DB::select('SELECT email FROM users WHERE last_activity > ?', array(time() - 600));
     View::share('whosonline', $results);
     $stocksTable = Lava::DataTable('Stocks');
     $stocksTable->addColumn('number', 'Count', 'count');
     $stocksTable->addColumn('number', 'Projected', 'projected');
     $stocksTable->addColumn('number', 'Official', 'official');
     for ($a = 1; $a < 25; $a++) {
         $data[0] = $a;
         //Count
         $data[1] = rand(800, 1000);
         //Projected Data
         $data[2] = rand(800, 1000);
         //Official Data
         $stocksTable->addRow($data);
     }
     $config = array('title' => 'My Stocks');
     Lava::LineChart('Stocks')->setConfig($config);
     return View::make('admin/dashboard');
 }
 public function show($sectorName)
 {
     $sectorGraphData = SectorHistoricals::getIndividualSectorGraphData($sectorName, 'last_month', 'Market Cap');
     $sectorCaps = \Lava::DataTable();
     $sectorCaps->addStringColumn('Date')->addNumberColumn('Sector Cap')->addRows($sectorGraphData);
     $sectorCapsLava = \Lava::AreaChart('SectorCaps')->dataTable($sectorCaps)->setOptions(['width' => 725, 'height' => 320, 'title' => 'Total Sector Cap (Billions)']);
     return view('pages.sectors')->with(['sectorCapsLava' => $sectorCapsLava, 'selectedSector' => $sectorName, 'selectedSectorDayChange' => SectorHistoricals::getSelectedSectorDayChange($sectorName), 'sectors' => SectorHistoricals::getSectorDayChanges("sectorDayGain", 30), 'sectorWeekDay' => SectorHistoricals::getSectorWeekDay(), 'stocksInSector' => StockMetrics::getMetricsByStockList(Stock::where('sector', $sectorName)->lists('stock_code'), 'all')]);
 }
 /**
  * User  charts
  *
  * @return Response
  */
 private function userChart()
 {
     $chart = Lava::DataTable('activeusers');
     $chart->addColumn('string', 'Active', 'active');
     $chart->addColumn('string', 'Inactive', 'inactive');
     $chart->addRow(array('Active', DB::table('users')->where('confirmed', '=', '1')->count()));
     $chart->addRow(array('In-active', DB::table('users')->where('confirmed', '!=', '1')->count()));
     Lava::PieChart('activeusers')->addOption(array('chartArea' => array('width' => '98%', 'height' => '98%')))->addOption(array('backgroundColor' => 'none'))->addOption(array('is3D' => 'true'))->addOption(array('legend' => 'none'));
 }
Exemple #5
0
 public function getStepsTodayChart()
 {
     $TodaySteps = (new Step())->where('date', Carbon::now()->toDateString())->first();
     if ($TodaySteps === null) {
         $TodaySteps = new Step();
     }
     $steps = \Lava::DataTable();
     $steps->addStringColumn('Steps')->addNumberColumn('Count')->addRow(['Steps', $TodaySteps->steps])->addRow(['Target', $TodaySteps->stepsLeftToTarget]);
     $chart = \Lava::DonutChart('stepToday', $steps, ['title' => 'Steps today', 'legend' => ['position' => 'none'], 'pieSliceTextStyle' => ['color' => 'none'], 'pieHole' => 0.7]);
     return $chart;
 }
 /**
  * Display Lavachart graph for CUCM devices
  *
  * @return \Illuminate\View\View
  */
 public function deviceCounts()
 {
     $data = executeQuery('SELECT t.name, count(*) AS num FROM device d INNER JOIN typemodel t ON d.tkmodel = t.enum GROUP BY t.name ORDER BY num DESC');
     $phoneCounts = \Lava::DataTable();
     $phoneCounts->addStringColumn('Phone Model')->addNumberColumn('Count');
     foreach ($data as $key => $val) {
         $phoneCounts->addRow([$val->name, (int) $val->num]);
     }
     $piechart = \Lava::DonutChart('Cisco IP Phones')->setOptions(['datatable' => $phoneCounts, 'title' => 'Cluster A IP Phones Stats', 'height' => 1000, 'width' => 2000]);
     return view('reports.device.counts', compact('piechart'));
 }
Exemple #7
0
 public function getCharts($testResultTotals)
 {
     $chart = new Helper();
     $smoke = \Lava::DataTable();
     $integration = \Lava::DataTable();
     $regression = \Lava::DataTable();
     $smoke->addStringColumn('TestResults')->addNumberColumn('Percent')->addRow(array('Passed', $testResultTotals['Passed']))->addRow(array('Failed', $testResultTotals['Failed']))->addRow(array('Skipped', $testResultTotals['Skipped']));
     $integration->addStringColumn('TestResults')->addNumberColumn('Percent')->addRow(array('Passed', 90))->addRow(array('Failed', 5))->addRow(array('Skipped', 5));
     $regression->addStringColumn('TestTesults')->addNumberColumn('Percent')->addRow(array('Passed', 82))->addRow(array('Failed', 18))->addRow(array('Skipped', 20));
     $chart->getChart('SmokeTestChart', 'PieChart', 250, 250, array('078B3E', 'CD1E35', 'FCDC27'), $smoke);
     $chart->getChart('IntegrationTestChart', 'PieChart', 250, 250, array('078B3E', 'CD1E35', 'FCDC27'), $integration);
     $chart->getChart('RegressionTestChart', 'PieChart', 250, 250, array('078B3E', 'CD1E35', 'FCDC27'), $regression);
 }
 public function index()
 {
     //Line graph for market cap
     $totalMarketCapGraphData = SectorHistoricals::getIndividualSectorGraphData('All', 'last_month', 'Market Cap');
     $marketCaps = \Lava::DataTable();
     $marketCaps->addStringColumn('Date')->addNumberColumn('Market Cap')->addRows($totalMarketCapGraphData);
     $marketCapsLava = \Lava::AreaChart('MarketCaps')->dataTable($marketCaps)->setOptions(['width' => 725, 'height' => 360, 'title' => 'ASX Market Cap (Billions)']);
     //PieChart for Sectors' Market Caps
     $individualSectorCapsGraphData = SectorHistoricals::getAllSectorGraphData('top_5');
     $sectorCaps = \Lava::DataTable();
     $sectorCaps->addStringColumn('Sector Name')->addNumberColumn('Percent')->addRows($individualSectorCapsGraphData);
     $sectorCapsLava = \Lava::PieChart('Sectors')->dataTable($sectorCaps)->customize(['tooltip' => ['text' => 'percentage']])->setOptions(['width' => 725, 'height' => 360, 'title' => 'Sector Caps (Billions)', 'pieSliceText' => 'label']);
     return view('pages.home')->with(['marketCapsLava' => $marketCapsLava, 'sectorDayGains' => SectorHistoricals::getSectorDayChanges('sectorDayGain'), 'sectorDayLosses' => SectorHistoricals::getSectorDayChanges('sectorDayLoss'), 'sectorDayGainTitle' => SectorHistoricals::getSectorDayChangeTitle('sectorDayGain'), 'sectorDayLossTitle' => SectorHistoricals::getSectorDayChangeTitle('sectorDayLoss')]);
 }
 private function reportPidStatusGeral()
 {
     $sql = 'SELECT COUNT(idPid) AS total FROM pids WHERE (created_at = updated_at) AND (updated_at NOT BETWEEN "' . Carbon::now()->subMonth(12) . '" AND "' . Carbon::now() . '") AND ativo = 1 AND idPid NOT IN (SELECT DISTINCT pid_id FROM pid_revisao)';
     $total = DB::select($sql)[0]->total;
     $sql2 = 'SELECT COUNT(DISTINCT idPid) AS total FROM pids WHERE (created_at <> updated_at) AND (updated_at BETWEEN "' . Carbon::now()->subMonth(12) . '" AND "' . Carbon::now() . '") AND ativo = 1 AND idPid NOT IN (SELECT DISTINCT pid_id FROM pid_revisao)';
     $atualizados = DB::select($sql2)[0]->total;
     $revisao = DB::select('SELECT COUNT(DISTINCT pid_id) AS total FROM pid_revisao')[0]->total;
     $dados = \Lava::DataTable();
     $dados->addStringColumn('Status');
     $dados->addNumberColumn('Qtd');
     $dados->addRow(['Não Revisados', $total]);
     $dados->addRow(['Revisados', $atualizados]);
     $dados->addRow(['Em Revisão', $revisao]);
     return $dados;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request, $id)
 {
     if ($request->stockCodeFind) {
         return redirect('stocks/' . $request->stockCodeFind);
     }
     if (Stock::where('stock_code', $id)->first()) {
         $priceGraphData = Stock::getGraphData($id, 'last_month', 'Price');
         $prices = \Lava::DataTable();
         $prices->addStringColumn('Date')->addNumberColumn('Price')->addNumberColumn('50 Day Moving Average')->addNumberColumn('200 Day Moving Average')->addRows($priceGraphData);
         $stockPriceLava = \Lava::LineChart('StockPrice')->dataTable($prices)->customize(['explorer' => ['actions' => ['dragToZoom', 'rightClickToReset']]])->setOptions(['width' => 620, 'height' => 360, 'title' => 'Price of ' . strtoupper($id)]);
         $sector = Stock::where('stock_code', $id)->pluck('sector');
         $motRecentSectorHistoricalsDate = SectorHistoricals::getMostRecentSectorHistoricalsDate();
         return view('pages.individualstock')->with(['stockPriceLava' => $stockPriceLava, 'stock' => Stock::where('stock_code', $id)->first(), 'relatedStocks' => StockMetrics::getMetricsByStockList(Stock::getRelatedStocks($id), 'omit'), 'metrics' => StockMetrics::where('stock_code', $id)->first(), 'mostRecentStockHistoricals' => Historicals::where('stock_code', $id)->orderBy('date', 'DESC')->limit(1)->first(), 'sectorAverage' => SectorHistoricals::where(['sector' => $sector, 'date' => $motRecentSectorHistoricalsDate])->first()]);
     }
     return redirect('/');
 }
 public static function googleGraph($minigraph_data, $type = 'activity')
 {
     switch ($type) {
         case 'activity':
             $stocksTable = Lava::DataTable('Stocks');
             $stocksTable->addColumn('string', 'Week', 'count');
             $stocksTable->addColumn('number', 'Hits', 'projected');
             $stocksTable->addColumn('number', 'Unique', 'projected');
             foreach (array_reverse($minigraph_data['activity']['data'], true) as $i => $d) {
                 $data[0] = $i == 0 ? "This week" : Carbon::now()->subWeeks($i)->diffForHumans();
                 $data[1] = $d;
                 $data[2] = $minigraph_data['activity_unique']['data'][$i];
                 $stocksTable->addRow($data);
             }
             Lava::LineChart('Stocks')->setConfig();
             break;
     }
 }
 /**
  * Generates the view with statistics for a chosen timeframe.
  * Includes all persons with LDAP-id set AND status "aktiv" and "kandidat" 
  * OR persons with LDAP-id and other status if they used a schedule in the last 3 month.
  *
  * @return int $from
  * @return int $till
  * @return RedirectResponse
  */
 public function showStatistics()
 {
     // Setting timeframe
     $from = is_null(Input::get('from')) ? date('Y-m-01') : Input::get('from');
     $till = is_null(Input::get('till')) ? date('Y-m-t') : Input::get('till');
     // Selecting persons to evaluate
     $timeSpan = new DateTime("now");
     $timeSpan = $timeSpan->sub(DateInterval::createFromDateString('3 months'));
     $persons = Person::whereRaw("prsn_ldap_id IS NOT NULL \n\t\t\t\t\t\t\t\t\t  AND (prsn_status IN ('aktiv', 'kandidat') \n\t\t\t\t\t\t\t\t\t  OR updated_at>='" . $timeSpan->format('Y-m-d H:i:s') . "')")->orderBy('prsn_name')->get();
     foreach ($persons as $person) {
         // Define new attribute 'total' for each person object, fill it with the sum received
         $person->total = $this->countStatisticsById($person->id, $from, $till);
     }
     // Generating charts with lavacharts
     $graphData = Lava::DataTable();
     $graphData->addStringColumn('Name')->addNumberColumn('Dienste');
     foreach ($persons as $person) {
         $graphData->addRow(array($person->prsn_name . "(" . substr($person->prsn_status, 0, 1) . ")" . "(" . $person->getClub->clb_title . ")", $person->total));
     }
     $columnchart = Lava::ColumnChart('Dienste')->setOptions(array('datatable' => $graphData));
     return View::make('statisticsView', compact('persons', 'from', 'till'));
 }
 public function viewServerStat($id)
 {
     $servers = DB::table('servers')->lists('server', 'id');
     $server = DB::table('servers')->select('server', 'id')->where('id', $id)->first();
     $server_statistics = DB::table('server_statistics')->where('server_id', $id)->get();
     $linechart = \Lava::DataTable();
     $linechart->addDateColumn('Date')->addNumberColumn('Sample Value');
     foreach ($server_statistics as $key => $value) {
         # code...
         $rowData = array($value->data_label, $value->data_value);
         $linechart->addRow($rowData);
     }
     $lineChart = \Lava::LineChart('server-stat')->setOptions(array('datatable' => $linechart, 'title' => 'Server statistics for ' . ucfirst($server->server)));
     //dd($rowData);
     $server_statistics_low = DB::table('server_statistics')->select('data_value')->where('server_id', $id)->orderBy('data_value', 'asc')->first();
     $server_statistics_high = DB::table('server_statistics')->select('data_value')->where('server_id', $id)->orderBy('data_value', 'desc')->first();
     $server_statistics_avg = DB::table('server_statistics')->select('data_value')->where('server_id', $id)->avg('data_value');
     if (!Request::ajax()) {
         return view('home', array('server_statistics_low' => $server_statistics_low, 'server_statistics_high' => $server_statistics_high, 'server_statistics_avg' => $server_statistics_avg, 'server_statistics' => $server_statistics, 'servers' => $servers, 'server_id' => $id));
     } else {
         return view('pull-servers-stat-ajax', array('server_statistics_low' => $server_statistics_low, 'server_statistics_high' => $server_statistics_high, 'server_statistics_avg' => $server_statistics_avg, 'server_statistics' => $server_statistics, 'servers' => $servers, 'server_id' => $id));
     }
 }
 public function comparative($society, Request $request)
 {
     $startdate = $request->input('yr') . "-01-01";
     $enddate = $request->input('yr') . "-12-31";
     $groups = $request->input('groups');
     $values = \Lava::DataTable();
     $values->addNumberColumn('Weeks');
     $charttitle = $request->input('yr') . " Comparative attendance by weeks: ";
     foreach ($groups as $gid) {
         $tot = 0;
         $group = Group::find($gid);
         $charttitle = $charttitle . $group->groupname . " v ";
         $values->addNumberColumn($group->groupname);
         $stats = Statistic::with('group')->where('group_id', '=', $group->id)->where('statdate', '>=', $startdate)->where('statdate', '<=', $enddate)->orderBy('statdate')->get();
         foreach ($stats as $stat) {
             $tstamp = strtotime($stat->statdate);
             $week = 1 + ceil(($tstamp - strtotime($startdate)) / (86400 * 7));
             $halfstats[$gid][$week] = $stat->attendance;
             $tot = $tot + $stat->attendance;
         }
         $halfstats[$gid]['avg'] = round($tot / count($stats), 2);
         $avg[$gid] = $group->groupname . ": " . $halfstats[$gid]['avg'];
     }
     $charttitle = substr($charttitle, 0, -2);
     for ($i = 1; $i < 53; ++$i) {
         $dum = array();
         array_push($dum, $i);
         foreach ($halfstats as $hs) {
             if (array_key_exists($i, $hs)) {
                 array_push($dum, $hs[$i]);
             } else {
                 array_push($dum, $hs['avg']);
             }
         }
         $values->addRow($dum);
     }
     $linechart = \Lava::LineChart('Chart')->dataTable($values)->title($charttitle);
     return View::make('statistics.comparative', compact('linechart', 'avg'));
 }
 private function getTeamsChart()
 {
     $teamHoursDataTable = \Lava::DataTable();
     foreach (Team::all()->sortBy('name') as $team) {
         $teamHoursDataTable->addNumberColumn($team->name);
     }
     foreach (Team::all() as $team) {
         $teamHoursDataTable->addRow([$team->workActivities()->sum('hours')]);
     }
     \Lava::LineChart('Overview')->dataTable($clubOverviewChart)->title('Stundenübersicht nach Team, Zeitraum 1 Jahr, Intervall 2 Wochen')->setOptions(array('legend' => \Lava::Legend(array('position' => 'in'))));
 }
 /**
  * ChartController constructor.
  */
 public function __construct()
 {
     $this->lavaDataTable = \Lava::DataTable();
 }
 public function index()
 {
     $user = Auth::user();
     $foods = $user->getFoodHistory();
     $nutrients = Nutrient::orderBy('name', 'ASC')->get();
     $data = [];
     $dailyCalories = $user->daily_calories;
     //for calculating individual food nutrient values scaled by quantity
     foreach ($foods as $food) {
         $allNutrients1 = $food->nutrients;
         $foodid1 = $food->id;
         $quantity1 = $food->pivot->quantity;
         foreach ($allNutrients1 as $nutrient) {
             $data[$foodid1][$nutrient->id] = $nutrient->pivot->amount_in_food * $quantity1 / 100;
         }
         $otherNutrients = Nutrient::whereNotIn('id', $food->nutrients()->lists('nutrient_id')->toArray())->get();
         foreach ($otherNutrients as $nutrient) {
             $data[$foodid1][$nutrient->id] = 0;
         }
     }
     //gets user's recommended daily values
     $vals = RecommendedValue::GetRecommendedValues($user);
     //for calculating daily total
     $todayTotalCalories = 0;
     $todayData = [];
     $todayNutrientTotals = [];
     $numDays = 5;
     //Index these arrays by $dayNumber - 1 (so that 1 day ago is in index 0), $nutrient->id
     $previousTotalCalories = [];
     $previousNutrientTotals = [];
     foreach ($nutrients as $nutrient) {
         $todayNutrientTotals[$nutrient->id] = 0;
         $previousNutrientTotals[$nutrient->id] = array_pad([], $numDays, 0);
         $previousTotalCalories = array_pad([], $numDays, 0);
     }
     foreach ($foods as $food) {
         $daysSinceEaten = Carbon::Parse($food->pivot->timestamp)->diffInDays();
         $actualCalories = $food->pivot->quantity / 100 * $food->getCalories();
         $food->actualCalories = $actualCalories;
         if ($daysSinceEaten == 0) {
             //We ate this today - it goes in a separate thing
             $todayTotalCalories += $actualCalories;
             $allNutrients = $food->nutrients;
             $foodid = $food->id;
             $quantity = $food->pivot->quantity;
             foreach ($allNutrients as $nutrient) {
                 $todayData[$foodid][$nutrient->id] = $nutrient->pivot->amount_in_food * $quantity / 100;
                 if (!array_key_exists($nutrient->id, $todayNutrientTotals)) {
                     $todayNutrientTotals[$nutrient->id] = $todayData[$foodid][$nutrient->id];
                 } else {
                     $todayNutrientTotals[$nutrient->id] = $todayNutrientTotals[$nutrient->id] + $todayData[$foodid][$nutrient->id];
                 }
             }
             $otherNutrients = Nutrient::whereNotIn('id', $food->nutrients()->lists('nutrient_id')->toArray())->get();
             foreach ($otherNutrients as $nutrient) {
                 $todayData[$foodid][$nutrient->id] = 0;
             }
         } else {
             if ($daysSinceEaten <= $numDays) {
                 //We want this many days worth of food data aggregated
                 $previousTotalCalories[$daysSinceEaten - 1] += $actualCalories;
                 $allNutrients = $food->nutrients;
                 $quantity = $food->pivot->quantity;
                 foreach ($allNutrients as $nutrient) {
                     $actualNutrientValue = $nutrient->pivot->amount_in_food * $quantity / 100;
                     $previousNutrientTotals[$nutrient->id][$daysSinceEaten - 1] += $actualNutrientValue;
                 }
             } else {
                 //Ignore this. Ideally, we would filter the query to only return items that fall in the previous two categories.
             }
         }
     }
     //for creating graphs
     $caloriesG = \Lava::DataTable();
     $caloriesG->addStringColumn('When')->addNumberColumn('Calories');
     $sugarFatG = \Lava::DataTable();
     $sugarFatG->addStringColumn('When')->addNumberColumn('Sugar (g)')->addNumberColumn('Fat (g)');
     $mineralsG = \Lava::DataTable();
     $mineralsG->addStringColumn('When')->addNumberColumn('Calcium')->addNumberColumn('Copper')->addNumberColumn('Iron')->addNumberColumn('Magnesium')->addNumberColumn('Manganese')->addNumberColumn('Phosphorus')->addNumberColumn('Potassium')->addNumberColumn('Sodium')->addNumberColumn('Zinc');
     $vitaminsG = \Lava::DataTable();
     $vitaminsG->addStringColumn('When')->addNumberColumn('Vitamin A')->addNumberColumn('Vitamin B12')->addNumberColumn('Vitamin B6')->addNumberColumn('Vitamin C')->addNumberColumn('Vitamin D')->addNumberColumn('Vitamin E')->addNumberColumn('Vitamin K');
     return view('history')->with(compact('foods', 'dates', 'todayTotalCalories', 'data', 'total', 'nutrients', 'allNutrients1', 'allNutrients', 'todayNutrientTotals', 'previousTotalCalories', 'previousNutrientTotals', 'vals', 'dailyCalories', 'caloriesG', 'sugarFatG', 'mineralsG', 'vitaminsG'));
 }
<div class="well well-lg col-md-6">
<h4>Planes Por Empresas</h4>
<?php 
use Carbon\Carbon;
$stocksTable = Lava::DataTable();
$empresas = Empresas::all()->toArray();
$stocksTable->addStringColumn('Empresa')->addNumberColumn('Cantidad');
foreach ($empresas as $key => $empresa) {
    $rowData = array($empresa["nombre"], App\Planes::where("empresa_id", "=", $empresa["id"])->count());
    $stocksTable->addRow($rowData);
}
$lineChart = Lava::PieChart('Stocks')->setOptions(array('datatable' => $stocksTable));
echo Lava::render('PieChart', 'Stocks', 'stocks-div', true);
?>
	
</div>
 public function postPerfReports()
 {
     $filter = "go";
     $deptL = Input::get('deptid');
     $sem = Input::get('semester');
     $year = Input::get('year');
     /*if($dept == "*"){
     
     			$users = Performance::all();
     			$deptid = "*";
     
     		}else{
     
     			$users = User::where('department_id', $dept)->get();
     			$deptid = Department::where('id', $dept)->get();
     
     		}*/
     $sampleArray = ['dept_id' => '1', 'semester' => '2015'];
     $sample = Performance::where($sampleArray)->get();
     $users = 'Performance';
     $matchThese = array();
     //If user chooses from dropdown
     if ($deptL != "*") {
         //If true insert this to variable
         $matchThese = array_add($matchThese, 'dept_id', $deptL);
         /***********Add Array*****************/
         //If user chooses from dropdown
         if ($sem != "*") {
             //If true insert this to variable
             $matchThese = array_add($matchThese, 'semester', $sem);
             if ($year != "All") {
                 $matchThese = array_add($matchThese, 'year', $year);
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             } else {
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             }
         } else {
             //===========Else of Semester
             if ($year != "All") {
                 $matchThese = array_add($matchThese, 'year', $year);
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             } else {
                 //===========Else of Year
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             }
             $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
         }
         /***********End Add Array*****************/
     } else {
         //===========Else of Department
         /*************Add Array***************/
         if ($sem != "*") {
             //If true insert this to variable
             $matchThese = array_add($matchThese, 'semester', $sem);
             if ($year != "All") {
                 $matchThese = array_add($matchThese, 'year', $year);
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             } else {
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             }
         } else {
             //===========Else of Semester
             if ($year != "All") {
                 $matchThese = array_add($matchThese, 'year', $year);
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             } else {
                 //===========Else of Year
                 $query = $users::all();
             }
         }
         /************End Add Array****************/
     }
     $count = $query->count();
     if (empty($count)) {
         return Redirect::route('perf-reports');
     }
     $out = 0;
     $exemP = 0;
     $exem = 0;
     $noteP = 0;
     $note = 0;
     $satP = 0;
     $sat = 0;
     $fair = 0;
     $un = 0;
     foreach ($query as $perf) {
         $u = $perf->utilities;
         $qow = $perf->workQuality;
         $pffp = $perf->potential;
         $overall = number_format(($u + $qow + $pffp) / 3, 2);
         $rating = ParRatingsRef::where('upper_limit', '>=', $overall)->where('lower_limit', '<=', $overall)->first();
         //============================Conditions=================//
         if ($rating->adjectival == 'O') {
             $out++;
         } elseif ($rating->adjectival == 'E+') {
             $exemP++;
         } elseif ($rating->adjectival == 'E') {
             $exem++;
         } elseif ($rating->adjectival == 'N+') {
             $noteP++;
         } elseif ($rating->adjectival == 'N') {
             $note++;
         } elseif ($rating->adjectival == 'S+') {
             $satP++;
         } elseif ($rating->adjectival == 'S') {
             $sat++;
         } elseif ($rating->adjectival == 'F') {
             $fair++;
         } elseif ($rating->adjectival == 'U') {
             $un++;
         }
     }
     //========================Percentage================//
     $percent_out = $out / $count * 100;
     $percent_exemP = $exemP / $count * 100;
     $percent_exem = $exem / $count * 100;
     $percent_satP = $satP / $count * 100;
     $percent_sat = $sat / $count * 100;
     $percent_noteP = $noteP / $count * 100;
     $percent_note = $note / $count * 100;
     $percent_fair = $fair / $count * 100;
     $percent_un = $un / $count * 100;
     //====================================LavaChart==================================//
     $lava = new Lavacharts();
     // See note below for Laravel
     $overall = Lava::DataTable();
     $overall->addStringColumn('Reasons')->addNumberColumn('Percent')->addRow(array('Outstanding (' . $out . ')', $percent_out))->addRow(array('Exemplary Plus (' . $exemP . ')', $percent_exemP))->addRow(array('Exemplary (' . $exem . ')', $percent_exem))->addRow(array('Noteworthy Plus(' . $noteP . ')', $percent_noteP))->addRow(array('Noteworthy (' . $note . ')', $percent_note))->addRow(array('Satisfactory Plus (' . $satP . ')', $percent_satP))->addRow(array('Satisfactory (' . $sat . ')', $percent_sat))->addRow(array('Fair (' . $fair . ')', $percent_fair))->addRow(array('Unutilized (' . $un . ')', $percent_un));
     $piechart = Lava::PieChart('IMDB')->setOptions(array('datatable' => $overall, 'title' => 'Performance Overall Rating (Total: ' . $count . ')', 'is3D' => true, 'slices' => array(Lava::Slice(array('offset' => 0.2)), Lava::Slice(array('offset' => 0.25)), Lava::Slice(array('offset' => 0.3)))));
     /*
     		$userquery = User::query();
     		$deptidquery = Department::query();
     
     		if($dept == "*"){
     
     			$deptidquery = "*";
     			$users = User::all();
     		}else{
     
     			$userquery = $userquery->where('department_id', $dept);
     			$deptidquery = $deptidquery->where('id', $dept);
     		}
     
     
     		$users = $userquery->get();
     		$deptid = $deptidquery->get();*/
     Session::put('deptpdf', $deptL);
     if ($deptL == '*') {
         $deptL = 'All';
     } else {
         $deptL = Department::where('id', $deptL)->pluck('name');
     }
     //------------------------------
     if ($sem == '*') {
         $sem = 'All';
     }
     if ($year == '*') {
         $year = 'All';
     }
     Session::put('sempdf', $sem);
     Session::put('yearpdf', $year);
     $audit = AuditTrail::create(['user_id' => Auth::id(), 'role' => 'Performance System Admin', 'action' => 'filtered the performance reports.']);
     return View::make('perf.perf-reports')->with('query', $query)->with('filter', $filter)->with('deptL', $deptL)->with('sem', $sem)->with('year', $year);
     /*
     		if($dept == "*"){
     
     			$users = User::all();
     			$deptid = "*";
     
     		}else{
     
     			$users = User::where('department_id', $dept)->get();
     			$deptid = Department::where('id', $dept)->get();
     
     		}
     
     
     
     		return View::make('emp.ems-reports')
     		->with('users', $users)
     		->with('deptid', $deptid);*/
 }
 public function createCharts($filter = null)
 {
     $stocksTable = \Lava::DataTable();
     $format = new DateFormat();
     $stocksTable->addDateColumn('Day of Month', $format->pattern("MMMM"))->addNumberColumn('2015')->addNumberColumn('2014');
     // Random Data For Example
     for ($a = 1; $a <= 12; $a++) {
         $firstDayOfMonth = Carbon::createFromDate(2015, $a, 1)->toDateString();
         $lastDay = date("t", Carbon::createFromDate(2015, $a, 1)->timestamp);
         $lastDayOfMonth = Carbon::createFromDate(2015, $a, $lastDay)->toDateString();
         $filter2015 = $filter . "AND fecfac >= '{$firstDayOfMonth}' AND fecfac <= '{$lastDayOfMonth}'";
         $rows = $this->model->getRows(["params" => $filter2015]);
         $priceMonth2015 = 0;
         foreach ($rows['rows'] as $row) {
             $priceMonth2015 += $row->totfac;
         }
         $firstDayOfMonth = Carbon::createFromDate(2014, $a, 1)->toDateString();
         $lastDay = date("t", Carbon::createFromDate(2014, $a, 1)->timestamp);
         $lastDayOfMonth = Carbon::createFromDate(2014, $a, $lastDay)->toDateString();
         $filter2014 = $filter . "AND fecfac >= '{$firstDayOfMonth}' AND fecfac <= '{$lastDayOfMonth}'";
         $rows = $this->model->getRows(["params" => $filter2014]);
         $priceMonth2014 = 0;
         foreach ($rows['rows'] as $row) {
             $priceMonth2014 += $row->totfac;
         }
         $rowData = array("2015-{$a}-1", $priceMonth2015, $priceMonth2014);
         $stocksTable->addRow($rowData);
     }
     $chart = \Lava::LineChart('myFancyChart');
     $chart->datatable($stocksTable);
 }
 public function graficarBarras(Request $request)
 {
     $datos = array();
     $productos = Producto::all();
     if ($request->id == 'Id') {
         $opcion = $request->id;
         foreach ($productos as $producto) {
             $datos1 = array($producto->nombre, $producto->id);
             array_push($datos, $datos1);
         }
     }
     if ($request->existencias == 'Existencias') {
         $opcion = $request->existencias;
         foreach ($productos as $producto) {
             $datos1 = array($producto->nombre, $producto->existencias);
             array_push($datos, $datos1);
         }
     }
     if ($request->precio == 'Precio') {
         $opcion = $request->precio;
         foreach ($productos as $producto) {
             $datos1 = array($producto->nombre, $producto->precio);
             array_push($datos, $datos1);
         }
     }
     if ($request->id == null && $request->existencias == null && $request->precio == null) {
         $opcion = "ighjh";
         $datos = null;
         return view('admi.graficas')->with(['errorBarras' => 'Tiene que seleccionar por lo menos una opcion']);
     }
     $tabla = \Lava::DataTable();
     $tabla->addStringColumn('Nombre')->addNumberColumn($opcion);
     foreach ($datos as $dato) {
         $tabla->addRow($dato);
     }
     $barchart = \lava::ColumnChart('Barras')->dataTable($tabla)->title('Grafica de Barras');
     return view('admi.graficas')->with(['barchart' => $barchart]);
 }
 * Advanced Line Chart
 */
Route::get('/line/basic', function () {
    $stocksTable = Lava::DataTable('Stocks');
    $stocksTable->addColumn('date', 'Date', 'date')->addColumn('number', 'Projected', 'projected')->addColumn('number', 'Closing', 'closing');
    for ($a = 1; $a < 30; $a++) {
        $data = array(Lava::jsDate(2011, 5, $a), rand(9500, 10000), rand(9500, 10000));
        $stocksTable->addRow($data);
    }
    Lava::LineChart('Stocks')->title('Stock Market Trends');
    return View::make('lavacharts::line.basic');
});
/**
 * Advanced Line Chart
 */
Route::get('/line/advanced', function () {
    $timesTable = Lava::DataTable('Times');
    $timesTable->addColumn('date', 'Dates', 'dates')->addColumn('number', 'Estimated Time', 'schedule')->addColumn('number', 'Actual Time', 'run');
    for ($a = 1; $a < 30; $a++) {
        $data = array(Lava::jsDate(2013, 8, $a), rand(5, 30), rand(5, 30));
        $timesTable->addRow($data);
    }
    //Either Chain functions together and assign to variables
    $legendStyle = Lava::textStyle()->color('#F3BB00')->fontName('Arial')->fontSize(20);
    $legend = Lava::legend()->position('bottom')->alignment('start')->textStyle($legendStyle);
    //Or pass in arrays with set options into the function's constructor
    $tooltip = Lava::tooltip(array('showColorCode' => TRUE, 'textStyle' => Lava::textStyle(array('color' => '#C0C0B0', 'fontName' => 'Courier New', 'fontSize' => 10))));
    $config = array('backgroundColor' => Lava::backgroundColor(array('stroke' => '#113bc9', 'strokeWidth' => 4, 'fill' => '#ffd')), 'chartArea' => Lava::chartArea(array('left' => 100, 'top' => 75, 'width' => '85%', 'height' => '55%')), 'titleTextStyle' => Lava::textStyle(array('color' => '#FF0A04', 'fontName' => 'Georgia', 'fontSize' => 18)), 'legend' => $legend, 'tooltip' => $tooltip, 'title' => 'Times for Deliveries', 'titlePosition' => 'out', 'curveType' => 'function', 'width' => 1000, 'height' => 450, 'pointSize' => 3, 'lineWidth' => 1, 'colors' => array('#4F9CBB', 'green'), 'hAxis' => Lava::hAxis(array('baselineColor' => '#fc32b0', 'gridlines' => array('color' => '#43fc72', 'count' => 6), 'minorGridlines' => array('color' => '#b3c8d1', 'count' => 3), 'textPosition' => 'out', 'textStyle' => Lava::textStyle(array('color' => '#C42B5F', 'fontName' => 'Tahoma', 'fontSize' => 10)), 'slantedText' => TRUE, 'slantedTextAngle' => 30, 'title' => 'Delivery Dates', 'titleTextStyle' => Lava::textStyle(array('color' => '#BB33CC', 'fontName' => 'Impact', 'fontSize' => 14)), 'maxAlternation' => 6, 'maxTextLines' => 2)), 'vAxis' => Lava::vAxis(array('baseline' => 5, 'baselineColor' => '#CF3BBB', 'format' => '## Min.', 'textPosition' => 'out', 'textStyle' => Lava::textStyle(array('color' => '#DDAA88', 'fontName' => 'Arial Bold', 'fontSize' => 10)), 'title' => 'Delivery Time', 'titleTextStyle' => Lava::textStyle(array('color' => '#5C6DAB', 'fontName' => 'Verdana', 'fontSize' => 14)))));
    Lava::LineChart('Times')->setConfig($config);
    return View::make('lavacharts::line.advanced');
});
 /**
  * Returns a calendar chart of the graph of the specified computer's statuses.
  *
  * @param Computer $computer
  *
  * @return mixed
  */
 public function graphOfStatus(Computer $computer)
 {
     $statuses = $computer->statuses()->thisMonth()->get();
     $dataTable = Lava::DataTable();
     $dataTable->addDateColumn('Date')->addNumberColumn('Status');
     foreach ($statuses as $status) {
         $dataTable->addRow([$status->created_at, $status->online]);
     }
     return Lava::LineChart('Status')->setOptions(['title' => "{$computer->name} Status This Month Over Time", 'datatable' => $dataTable, 'legend' => (new Legend())->position('bottom'), 'vAxis' => (new VerticalAxis())->title('Offline / Online')]);
 }
 private function reportIniciativaInstituicaoByCidade($cidade)
 {
     $dados = \Lava::DataTable();
     $dados->addStringColumn('Instituição')->addNumberColumn('Total')->addNumberColumn('Apoiadoras')->addNumberColumn('Mantenedoras');
     //com
     $ci = DB::table('iniciativas')->join('enderecos', 'enderecos.idEndereco', '=', 'iniciativas.endereco_id')->where('enderecos.cidade_id', $cidade)->whereRaw('iniciativas.idIniciativa IN (SELECT iniciativa_id FROM iniciativa_instituicoes)')->get();
     //sem
     $si = DB::table('iniciativas')->join('enderecos', 'enderecos.idEndereco', '=', 'iniciativas.endereco_id')->where('enderecos.cidade_id', $cidade)->whereRaw('iniciativas.idIniciativa NOT IN (SELECT iniciativa_id FROM iniciativa_instituicoes)')->get();
     //apoiador
     $ip = DB::table('iniciativas')->join('enderecos', 'enderecos.idEndereco', '=', 'iniciativas.endereco_id')->where('enderecos.cidade_id', $cidade)->whereRaw('iniciativas.idIniciativa IN (SELECT iniciativa_id FROM iniciativa_instituicoes WHERE tipoVinculo = 1)')->get();
     //mantenedor
     $im = DB::table('iniciativas')->join('enderecos', 'enderecos.idEndereco', '=', 'iniciativas.endereco_id')->where('enderecos.cidade_id', $cidade)->whereRaw('iniciativas.idIniciativa IN (SELECT iniciativa_id FROM iniciativa_instituicoes WHERE tipoVinculo = 2)')->get();
     $dados->addRow(['C/ Instituições', count($ci), count($ip), count($im)]);
     $dados->addRow(['S/ Instituições', count($si)]);
     return $dados;
 }
 public function getViewResults($id)
 {
     $perf = Performance::find($id);
     $user_perfs = Performance::where('user_id', $perf->user_id)->orderBy('year')->orderBy('semester')->get();
     if (!$perf) {
         App::abort(404);
     }
     //=================Variable Declaration============
     $u = $perf->utilities;
     $qow = $perf->workQuality;
     $pffp = $perf->potential;
     //========================Computation=================
     $overall = number_format(($u + $qow + $pffp) / 3, 2);
     $rating = ParRatingsRef::where('upper_limit', '>=', $overall)->where('lower_limit', '<=', $overall)->first();
     $overpercent = number_format($overall / 6 * 100, 2);
     //========================= The color of the percent bar ===============//
     if ($overpercent >= 85) {
         $color = 'progress-bar-success';
     } elseif ($overpercent >= 75 and $overpercent <= 84.98999999999999) {
         $color = '';
     } elseif ($overpercent >= 40 and $overpercent <= 74.98999999999999) {
         $color = 'progress-bar-warning';
     } else {
         $color = 'progress-bar-danger';
     }
     //======================================Line Graph===============================//
     $lava = new Lavacharts();
     // See note below for Laravel
     $overall_chart = Lava::DataTable();
     $overall_chart->addStringColumn('Date')->addNumberColumn('Overall Rating');
     foreach ($user_perfs as $user_perf) {
         $overall_chart->addRow([$user_perf->year . ' (' . $user_perf->semester . ' sem)', $user_perf->overall]);
     }
     $linechart = Lava::LineChart('Overall')->setOptions(['datatable' => $overall_chart, 'title' => 'Overall Performance Line Chart', 'pointSize' => 10, 'lineWidth' => 6]);
     //======================================Line Graph===============================//
     return View::make('viewresults')->with('perf', $perf)->with('overall', $overall)->with('rating', $rating)->with('overpercent', $overpercent)->with('color', $color);
 }
Exemple #26
0
 public function createDataTable()
 {
     $dataTable = \Lava::DataTable();
     return $dataTable;
 }
 public function getIndex()
 {
     $minigraph_data = array();
     $minigraph_data['account_created'] = $this->graphDataBuild('account_created');
     $minigraph_data['login'] = $this->graphDataBuild('login');
     $minigraph_data['activity'] = $this->graphDataBuild('activity');
     $minigraph_data['activity_unique'] = $this->graphDataBuild('activity', '5', true);
     View::share('minigraph_data', $minigraph_data);
     View::share('minigraph_json', json_encode($minigraph_data));
     $widgets = $this->widgets();
     View::share('widgets', $widgets);
     $results = DB::select('SELECT email FROM users WHERE UNIX_TIMESTAMP(`last_activity`) > ?', array(time() - 600));
     View::share('whosonline', $results);
     $stocksTable = Lava::DataTable('Stocks');
     $stocksTable->addColumn('string', 'Week', 'count');
     $stocksTable->addColumn('number', 'Hits', 'projected');
     $stocksTable->addColumn('number', 'Unique', 'projected');
     foreach (array_reverse($minigraph_data['activity']['data'], true) as $i => $d) {
         $data[0] = $i == 0 ? "This week" : Carbon::now()->subWeeks($i)->diffForHumans();
         $data[1] = $d;
         $data[2] = $minigraph_data['activity_unique']['data'][$i];
         $stocksTable->addRow($data);
     }
     Lava::LineChart('Stocks')->setConfig();
     return Theme::make('admin/dashboard');
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $stocksTable = \Lava::DataTable();
     // Lava::DataTable() if using Laravel
     $stocksTable->addColumns(array(array('string', 'Date'), array('number', 'On'), array('number', 'Off')));
     $sql = "select TIME(created_at) as createdat,\n \n    COUNT(IF(sensor_state=1, 1, NULL)) AS on_state,\n    COUNT(IF(sensor_state=0, 1, NULL)) AS off_state\n   FROM smoke_sensors GROUP BY created_at";
     //$sql="select count(sensor_state) as count_val,TIME(created_at) as createdat from smoke_sensors
     //  group by createdat ";
     $result = DB::select($sql);
     foreach ($result as $data) {
         $rowData = array($data->createdat, $data->on_state, $data->off_state);
         $stocksTable->addRow($rowData);
     }
     /*for ($a = 1; $a < 30; $a++)
         {
             $rowData = array(
               "2014-8-$a", rand(800,1000), rand(800,1000)
             );
     
             $stocksTable->addRow($rowData);
         }*/
     $lineChart = \Lava::ColumnChart('Stocks')->setOptions(array('datatable' => $stocksTable, 'title' => 'Smoke Sensor States'));
     //$chart->datatable($stocksTable);
     return View('Home.charts');
 }
Exemple #29
-1
 public function getChart(Request $request)
 {
     $reasons = \Lava::DataTable();
     $reasons->addStringColumn('Reasons')->addNumberColumn('Percent')->addRow(array('Passed', 50))->addRow(array('Failed', 30))->addRow(array('Skipped', 20));
     $piechart = \Lava::PieChart('myPieChart')->setOptions(array('datatable' => $reasons, 'legend' => \Lava::Legend(array('position' => 'none')), 'chartArea' => \Lava::ChartArea(['width' => 250, 'height' => 250]), 'colors' => array('078B3E', 'CD1E35', 'FCDC27')));
     $threedpiechart = \Lava::PieChart('myThreeDPieChart')->setOptions(array('datatable' => $reasons, 'legend' => \Lava::Legend(array('position' => 'none')), 'chartArea' => \Lava::ChartArea(['width' => 250, 'height' => 250]), 'colors' => array('368DB9', 'A41034', 'FCDC27'), 'is3D' => true));
     $donutchart = \Lava::DonutChart('myDonut')->setOptions(array('datatable' => $reasons, 'legend' => \Lava::Legend(array('position' => 'none')), 'chartArea' => \Lava::ChartArea(['width' => 250, 'height' => 250]), 'colors' => array('368DB9', 'A41034', 'FCDC27')));
 }