public function getGraphData() { $company = Input::get('company'); $interval = Input::get('interval'); $precision = Input::get('prc'); $company_symbol = isset($company) && !empty($company) ? $company : 'goog'; $interval = isset($interval) && !empty($interval) ? $interval : 'd'; $precision = isset($precision) && !empty($precision) && is_numeric($precision) ? $precision : 1; $stock_market = new StockMarket($company_symbol, $interval, $precision); //<---class declared here and passed the datas /* // <--utilizing the function for finding the Company name from Symbol //<-- to check the given company symbol is correct or not */ $company_name = $stock_market->find_company_name_from_symbol(); if ($company_name) { //<-- if company name given is not false go further $stock_records = $stock_market->get_the_market_data(); //<--function to collect Historical data for given company symbol if ($stock_records) { //<----if it retuns a record then proceed $range_from = $stock_market->get_graph_range_start(); //<--this function helps to calculate historical Graph area minmum range $range_to = $stock_market->get_graph_range_ends(); //<--this function helps to calculate historical Graph area maximum range $lower_range_coords = $stock_market->get_lower_price_data(); //<--this function helps to return the lower price data for graph $higher_range_coords = $stock_market->get_higher_price_data(); //<--this function helps to return the higher price data for graph $graph = new PHPGraphLib(470, 270); $graph->addData($lower_range_coords); $graph->addData($higher_range_coords); $graph->setRange($range_from, $range_to); $graph->setTitle($company_name . ' Graph'); $graph->setBars(false); $graph->setLine(true); $graph->setDataPoints(true); $graph->setDataPointColor('maroon'); $graph->setDataPointColor('red'); $graph->setDataValues(true); $graph->setDataValueColor('blue'); $graph->setGoalLine(0.25); $graph->setGoalLineColor('red'); $graph->createGraph(); //<--this draw the graph $contents = View::make('graph')->with('graph', $graph); // Create a response and modify a header value $response = Response::make($contents, 200); $response->header('Content-Type', 'image/png'); return $response; } //<-- stock data checks ends } //<--company name check ends }