<?php require $_SERVER['DOCUMENT_ROOT'] . '/y/includes/config.php'; include "phpgraphlib.php"; $graph = new PHPGraphLib(500, 300); $dataArray = array(); $sql = "SELECT purchase_date, SUM(totalcost) AS 'tot' FROM item_purchase GROUP BY purchase_date"; $result = mysql_query($sql) or die('Query failed: ' . mysql_error()); if ($result) { while ($row = mysql_fetch_assoc($result)) { $purchaseDate = $row["purchase_date"]; $sum = $row["tot"]; $dataArray[$purchaseDate] = $sum; } } $graph->addData($dataArray); $graph->setBars(false); $graph->setLine(true); $graph->setDataPoints(true); $graph->setDataPointColor('maroon'); $graph->setDataValues(true); $graph->setDataValueColor('maroon'); $graph->setGoalLine(8000); $graph->setGoalLineColor('red'); $graph->createGraph();
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 create_graph($graph_type = '') { $graph = new PHPGraphLib(1400, 600); $model = new TwextraModel(); //$data = array("Alex"=>99, "Mary"=>98, "Joan"=>70, "Ed"=>90); if ($graph_type == 'daily_stats') { $data = $model->get_stats_daily(); $graph->setTitle("Daily Unique Traffic"); } else { if ($graph_type == 'message_history') { //this graph is currently not plotted! $screen_name = 'rajen4126'; $message_from = 0; $next = 20; $order = 'created'; $asc_desc = 'desc'; $length = 20; $data = $model->get_message_history($screen_name, $message_from, $next, $order, $asc_desc, $length); foreach ($data as $entry) { $data[$entry[message_id]] = $entry[view_count]; } $graph->setTitle("Message History"); } else { if ($graph_type == 'monthly_stats') { $data = $model->get_monthly_uniques(); $graph->setTitle("Monthly Unique Traffic"); } else { if ($graph_type == 'messages_stats') { $data = $model->get_messages_stats(); $graph->setTitle("Daily Messages Created"); } else { $data = array(); } } } } $graph->addData($data); $graph->setTextColor("blue"); //additions for a line graph.......... $graph->setBars(false); $graph->setLine(true); //$graph->setDataPoints(true); $graph->setDataPointColor('maroon'); $graph->setDataValues(true); $graph->setDataValueColor('maroon'); $graph->setGoalLine(0.0025); $graph->setGoalLineColor('red'); //........ return $graph->createGraph(); }
<?php include '../phpgraphlib.php'; $graph = new PHPGraphLib(450, 300); $data = array("Jan" => -10.1, "Feb" => -3.6, "Mar" => 11.0, "Apr" => 30.7, "May" => 48.6, "Jun" => 59.8, "Jul" => 62.5, "Aug" => 56.8, "Sep" => 45.5, "Oct" => 25.1, "Nov" => 2.7, "Dec" => -6.5); $graph->addData($data); $graph->setBarColor('navy'); $graph->setupXAxis(20, 'blue'); $graph->setTitle('Average Temperature by Month, in Fairbanks Alaska'); $graph->setTitleColor('blue'); $graph->setGridColor('153,204,255'); $graph->setDataValues(true); $graph->setDataValueColor('navy'); $graph->setDataFormat('degrees'); $graph->setGoalLine('32'); $graph->setGoalLineColor('red'); $graph->createGraph();
<?php include 'phpgraphlib.php'; $graph = new PHPGraphLib(650, 200); $data = array("1" => 0.0032, "2" => 0.0028, "3" => 0.0021, "4" => 0.0033, "5" => 0.0034, "6" => 0.0031, "7" => 0.0036, "8" => 0.0027, "9" => 0.0024, "10" => 0.0021, "11" => 0.0026, "12" => 0.0024, "13" => 0.0036, "14" => 0.0028, "15" => 0.0025); $graph->addData($data); $graph->setTitle('PPM Per Container'); $graph->setBars(false); $graph->setLine(true); $graph->setDataPoints(true); $graph->setDataPointColor('maroon'); $graph->setDataValues(true); $graph->setDataValueColor('maroon'); $graph->setGoalLine(0.0025); $graph->setGoalLineColor('red'); $graph->createGraph();
$link = mysql_connect('localhost', 'root', 'Cookiemonster1!') or die('Could not connect: ' . mysql_error()); mysql_select_db('healthbuddies') or die('Could not select database'); $dataArray = array(); //get data from database $sql = "SELECT date, steps FROM steps"; $result = mysql_query($sql) or die('Query failed: ' . mysql_error()); if ($result) { while ($row = mysql_fetch_assoc($result)) { $salesgroup = $row["date"]; $count = $row["steps"]; //add to data areray $dataArray[$salesgroup] = $count; } } //configure graph //$graph->addData($dataArray); //$graph->setTitle("Steps"); //$graph->setGradient("lime", "green"); //$graph->setBarOutlineColor("black"); //$graph->createGraph(); $graph->addData($dataArray); $graph->setTitle('Steps'); $graph->setBars(false); $graph->setLine(true); $graph->setDataPoints(true); $graph->setDataPointColor('black'); $graph->setDataValues(true); $graph->setDataValueColor('black'); $graph->setGoalLine(6000); $graph->setGoalLineColor('blue'); $graph->createGraph();
<?php include '../phpgraphlib.php'; $graph = new PHPGraphLib(450, 300); $data = array("Jan" => -10.1, "Feb" => -3.6, "Mar" => 11.0, "Apr" => 30.7, "May" => 48.6, "Jun" => 59.8, "Jul" => 62.5, "Aug" => 56.8, "Sep" => 45.5, "Oct" => 25.1, "Nov" => 2.7, "Dec" => -6.5); $graph->addData($data); $graph->setBarColor('navy'); $graph->setupXAxis(20, 'blue'); $graph->setTitle('Average Temperature by Month, in Fairbanks Alaska'); $graph->setTitleColor('blue'); $graph->setGridColor('153,204,255'); $graph->setDataValues(true); $graph->setDataValueColor('navy'); $graph->setDataFormat('degrees'); $graph->setGoalLine('32', 'fuscia', 'dashed'); $graph->createGraph();
<?php include 'phpgraphlib.php'; $graph = new PHPGraphLib(450, 500); $data = array("Jan" => 100.1, "Feb" => 300.6, "Mar" => 110.0, "Apr" => 450.7, "May" => 400.6, "Jun" => 505.8, "Jul" => 280.5); $graph->addData($data); $graph->setBarColor('navy'); $graph->setupXAxis(20, 'blue'); $graph->setTitleColor('blue'); $graph->setGridColor('153,204,255'); $graph->setDataValues(true); $graph->setDataValueColor('navy'); $graph->setDataFormat('degrees'); $graph->setGoalLine('300'); $graph->setGoalLineColor('red'); $graph->createGraph();