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
 }
Пример #2
0
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();
}
Пример #3
0
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();
}
Пример #4
0
 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}\">";
 }
Пример #5
0
<?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();
Пример #6
0
//mysqli_select_db($link,'gfb11176') or die('Could not select database');
//mysql_select_db("mydatabase") or die("MySQL Error: " . mysql_error());
$dataArray = array();
// Get the values from the COReadings table for the currently logged in user.
$sql = "SELECT COValue, AddedOn FROM COReadings \n\t\tJOIN COUsers ON COUsers.id = COReadings.UserID\n\t\tWHERE COUsers.Email = '{$email}'";
$result = mysqli_query($link, $sql) or die('Query failed: ' . mysql_error());
if ($result) {
    while ($row = mysqli_fetch_assoc($result)) {
        $dateAdded = $row["AddedOn"];
        $count = $row["COValue"];
        // Add to data array
        $dataArray[$dateAdded] = $count;
    }
}
// Configure graph
$graph->addData($dataArray);
$graph->setTitle("Carbon Monoxide Readings");
$graph->setTitleColor('navy');
$graph->setGradient("lime", "green");
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataValues(true);
$graph->setDataValueColor('navy');
$graph->setDataPointColor('navy');
$graph->setXValuesHorizontal(true);
//$graph->setBackgroundColor("black");
$graph->setYAxisTextColor('black');
$graph->setXAxisTextColor('black');
$graph->setLineColor('navy');
$graph->createGraph();
Пример #7
0
<?php

session_start();
require_once "../Includes.php";
//print("<img src=\"../Utilities/Charts.php?chart=padaliniu_paraiskos&menuo=2008-01-01\">");
$graph = new PHPGraphLib(650, 200);
$data1 = array(0);
$data2 = array(8, 15, 4, 12);
$data3 = array(1, 2, 3, 4);
$graph->addData($data2);
$graph->setTitle('PPM Per Container');
$graph->setBars(false);
$graph->setLine(true);
$graph->setLineColor('#FF0000', 'green', 'red');
$graph->setDataPoints(true);
$graph->setDataPointColor('maroon');
$graph->setDataValues(true);
$graph->setDataValueColor('maroon');
$graph->setLegend(true);
$graph->setLegendTitle("PA1", "PA2", "PA3");
$graph->createGraph();
p(ErrorMessages::getErrors());
$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();
Пример #9
0
<?php

include 'phpgraphlib.php';
$graph = new PHPGraphLib(350, 280);
$data = array("Day1" => 0.5, "Day2" => 0, "Day3" => 0.5, "Day4" => 0, "Day5" => 0.5, "Day6" => 0, "Day7" => 1, "Day8" => 0, "Day9" => 2.5);
//$graph->setBackgroundColor("black");
$graph->addData($data);
$graph->setBarColor('255,255,204');
$graph->setTitle('Workout Summary');
$graph->setTitleColor('black');
$graph->setupYAxis(15, 'black');
$graph->setupXAxis(20, 'black');
$graph->setGrid(false);
$graph->setGradient('blue', 'white');
$graph->setBarOutlineColor('white');
$graph->setTextColor('black');
$graph->setDataPoints(true);
$graph->setDataPointColor('red');
$graph->setLine(true);
$graph->setLineColor('red');
$graph->createGraph();
Пример #10
0
                         $data[$name] = count($db->dbArrayResults($value));
                     }
                 }
             }
             // generate our graphs but check for gd lib extensions first
             if (function_exists('imagedestroy')) {
                 $graph = new PHPGraphLib(450, 200);
                 // push the image and assign attributes
                 $graph->addData($data, $all);
                 $graph->setTitle("Total Leases: " . $total_leases);
                 $graph->setTitleLocation("left");
                 $graph->setLegendTitle("Available", "In Use");
                 $graph->setBars(true);
                 $graph->setLegend(true);
                 $graph->setDataPoints(true);
                 $graph->setDataPointColor("red");
                 $graph->setDataValueColor("gray");
                 $graph->createGraph();
             }
         } else {
             // page view restricted by access level
             $ERROR = $err->GenerateErrorLink("help/help.html", "#undef", $defined['error'], $errors['level']);
         }
     } else {
         // general authentication error
         $ERROR = $err->GenerateErrorLink("help/help.html", "#undef", $defined['error'], $errors['auth_n']);
     }
 } else {
     // Possible XSS attack
     $ERROR = $err->GenerateErrorLink("help/help.html", "#undef", $defined['error'], $errors['xss_config'], NULL, NULL);
 }