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();
//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();
<?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());
<?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();
<?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();
<?php if ($_REQUEST['mode'] == 'graph' || $_REQUEST['mode'] == 'graph_line') { include '../lib/phpgraphlib.php'; $graph = new PHPGraphLib(1120, 600); $graph->addData(unserialize($_REQUEST['graph_data'])); if ($_REQUEST['mode'] == 'graph_line') { $graph->setBars(false); $graph->setLine(true); $graph->setLineColor(); } else { $graph->setGradient(); } $graph->setLegend(true); $graph->setLegendTitle(unserialize($_REQUEST['titles'])); $graph->createGraph(); } elseif ($_REQUEST['mode'] == 'graph_pie') { include '../lib/phpgraphlib.php'; include '../lib/phpgraphlib_pie.php'; $graph = new PHPGraphLibPie(1120, 600); $graph->addData(unserialize($_REQUEST['graph_data'])); $graph->setLabelTextColor("50,50,50"); $graph->createGraph(); }
/** * Function to generate a file containing a graph of power (kW) against * solar radiation (W/m2) using data from the given tables. A date range * can be specified to restrict the x-axis. * @param string $imageFilename Name of file to write graph to * @param string $powerTable Name of table to get power data from * @param string $solRadTable Name of table to get solar radiation data from * @param array $dateRange An optional array of two DateTime objects to limit * the range of data used */ public function createGraphImage($imageFilename, $powerTable, $powerColumn, $solRadTable, &$dateRange = NULL) { global $verbose; if (!$this->graphsEnabled) { return; } // We inner join the tables on the datetime field. This is expected to be called on // a solar radiation data table and a instananeous power data table so the two can // be easily compared. They will need different y-axes. if ($verbose > 0) { print "Generating power graph in file {$imageFilename}\n"; } $sql = "SELECT {$powerTable}.datetime, {$powerTable}.{$powerColumn}, sol_rad\n FROM {$solRadTable} INNER JOIN {$powerTable}\n ON {$powerTable}.datetime = {$solRadTable}.datetime"; $whereClause = ''; $whereClausePower = ''; if ($dateRange != NULL) { $whereClause = " WHERE DATE({$solRadTable}.datetime) > '" . $dateRange[0]->format('Y-m-d') . "' &&\n DATE({$solRadTable}.datetime) < '" . $dateRange[1]->format('Y-m-d') . "'"; $whereClausePower = str_replace($solRadTable, $powerTable, $whereClause); } $sql .= $whereClause; $data = $this->fetchQuery($sql); $maxSolRad = $this->fetchQuery("SELECT MAX(sol_rad) FROM {$solRadTable}" . $whereClause, PDO::FETCH_NUM); $maxPower = $this->fetchQuery("SELECT MAX({$powerColumn}) FROM {$powerTable}" . $whereClausePower, PDO::FETCH_NUM); if ($maxPower[0][0] == 0) { // If there was never any power, divide by 1 rather than 0 when scaling! $maxPower[0][0] = 1; } $graph = new PHPGraphLib(10000, 1000, $imageFilename); $graph->setTitle($powerTable . ' against solar radiation (both scaled to % of maximum recorded value)'); $graph->setBars(FALSE); $graph->setLine(TRUE); $graph->setLineColor('red', 'yellow'); $graph->setLegend(TRUE); $graph->setLegendTitle('Power', 'Solar radiation'); // Reassmble the data into the form needed for PHPGraphLib and scale values so they can be plotted on the same // y-axis (a limitation of PHPGraphLib...if we can go GPLv3, we can use PCharts2 which can do multiple y-axes, // or there's SVGGraph which is LGPL). foreach ($data as $entry) { $powerData[$entry['datetime']] = $entry[$powerColumn] / $maxPower[0][0] * 100; $solRadData[$entry['datetime']] = $entry['sol_rad'] / $maxSolRad[0][0] * 100; } // Free up memory (maybe!) $data = NULL; $graph->addData($powerData, $solRadData); $graph->createGraph(); }