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 }
function make_graph_multi_line($title, $data_min, $data_avg, $data_max, $is_bar_graph) { include 'phpgraphlib.php'; $graph = new PHPGraphLib(780, 300); if ($is_bar_graph == 'true') { $graph->setBars(true); $graph->setLine(false); } else { $graph->setBars(false); $graph->setLine(true); } $graph->setDataPoints(true); $graph->setDataPointSize(4); $graph->setDataPointColor('purple'); $graph->setLegend(true); if (!isset($data_min)) { $graph->addData($data_avg); $graph->addData($data_max); if ($is_bar_graph == 'true') { $graph->setBarColor('purple', 'red'); } else { $graph->setLineColor('purple', 'red'); } $graph->setLegendTitle('avg', 'max'); } else { $graph->addData($data_min); $graph->addData($data_avg); $graph->addData($data_max); if ($is_bar_graph == 'true') { $graph->setBarColor('blue', 'purple', 'red'); } else { $graph->setLineColor('blue', 'purple', 'red'); } $graph->setLegendTitle('min', 'avg', 'max'); } $graph->setTitle($title); $graph->setTitleColor("88,89,91"); $graph->setXValuesVertical(true); $graph->createGraph(); }
public function gbarra_getImagen($titulo = " ", $width = "500", $height = "350") { $config = XTConfig::singleton(); $data = $this->barra_data; $nombreimagen = uniqid() . "barraimagen.png"; $file = $config->get("XTSITE_PATH_ABSOLUTE") . "tmp/pie/" . $nombreimagen; $file_url = $config->get("XTSITE_PATH") . "tmp/pie/" . $nombreimagen; $graph = new PHPGraphLib($width, $height, $file); $graph->addData($data); //$graph->setBarColor('255,255,204'); $graph->setGradient('255,255,204', '254,254,154'); if ($titulo != "") { $graph->setTitle($titulo); } $graph->setLineColor('maroon'); $graph->setDataPointColor('maroon'); $graph->setXValuesHorizontal(true); $graph->setLine(true); $graph->setDataPoints(true); $graph->setDataValues(true); $graph->createGraph(); print "<img src=\"{$file_url}\">"; }
<?php include '../phpgraphlib.php'; $graph = new PHPGraphLib(350, 280); $data = array("Roger" => 145, "Ralph" => 102, "Rhonda" => 123, "Ronaldo" => 137, "Rosario" => 149, "Robin" => 99, "Robert" => 88, "Rustof" => 111); $graph->setBackgroundColor("black"); $graph->addData($data); $graph->setBarColor('255, 255, 204'); $graph->setTitle('IQ Scores'); $graph->setTitleColor('yellow'); $graph->setupYAxis(12, 'yellow'); $graph->setupXAxis(20, 'yellow'); $graph->setGrid(false); $graph->setGradient('silver', 'gray'); $graph->setBarOutlineColor('white'); $graph->setTextColor('white'); $graph->setDataPoints(true); $graph->setDataPointColor('yellow'); $graph->setLine(true); $graph->setLineColor('yellow'); $graph->createGraph();
<?php include '../phpgraphlib.php'; $set1 = array(1917 => 4011, 1918 => 4886, 1919 => 5411, 1920 => 5831, 1921 => 5865, 1922 => 5704, 1923 => 5337, 1924 => 5144, 1925 => 5018, 1926 => 4971, 1927 => 4630, 1928 => 4411, 1929 => 4287, 1930 => 4116, 1931 => 3940, 1932 => 3764, 1933 => 3592, 1934 => 3447, 1935 => 3280, 1936 => 3215, 1937 => 3366, 1938 => 3569, 1939 => 3598, 1940 => 4436, 1941 => 5939, 1942 => 7397, 1943 => 8855, 1944 => 9835, 1945 => 9998, 1946 => 10631, 1947 => 11340, 1948 => 11549, 1949 => 11642); $set2 = array(1910 => 2059, 1911 => 2135, 1912 => 2209, 1913 => 2332, 1914 => 2437, 1915 => 2786, 1916 => 3747, 1917 => 5011, 1918 => 5886, 1919 => 6411, 1920 => 6831, 1921 => 6865, 1922 => 6704, 1923 => 6337, 1924 => 6144, 1925 => 6018, 1926 => 5971, 1927 => 5630, 1928 => 5411, 1929 => 5287, 1930 => 5116, 1931 => 4940, 1932 => 4764, 1933 => 4592, 1934 => 4447, 1935 => 4280, 1936 => 4215, 1937 => 4366, 1938 => 4569, 1939 => 4598, 1940 => 5436, 1941 => 5939, 1942 => 8397, 1943 => 9855, 1944 => 10835); $graph = new PHPGraphLib(600, 400); $graph->addData($set1, $set2); $graph->setTitleLocation('left'); $graph->setTitle("Two sets with different start points"); $graph->setBars(false); $graph->setLine(true); $graph->setDataPoints(false); $graph->setLineColor('blue', 'red'); $graph->setDataValues(false); $graph->setXValuesInterval(5); $graph->setDataValueColor('blue', 'red'); $graph->setLegend(true); $graph->setLegendTitle("set1", "set2"); $graph->createGraph();