$base_time = mktime(0, 0, 12, 6, 30, 2004); $interval = 60 * 60; $data = array(); # This is a quadratic from 0,0 to 50,20 to 100,0: for ($i = 0; $i <= 100; $i++) { if ($i % 24 == 0) { $t = $base_time + $i * $interval; } else { $t = ''; } $data[] = array($t, $i, $i * (0.8 - 0.008 * $i)); } $p = new PHPlot(800, 600); $p->SetTitle('Date X labels - 8 hour ticks, 24 hour labels'); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetPlotAreaWorld(0, 0, 100, 20); $p->SetXLabelType('time'); # For example: # %Y-%m-%d 2004-12-31 # %b %Y Dec 2004 # %b %d, %Y Dec 31, 2004 # %d %b 31 Dec $p->SetXTimeFormat('%m/%d %H:%M'); # Turn off X tick labels, use our data labels only: $p->SetXTickLabelPos('none'); # But we can use the tick marks themselves if we make them line up right. $p->SetXTickIncrement(8); $p->SetDrawXGrid(True); $p->SetPlotType('lines'); $p->DrawGraph();
include "./data_date2.php"; include "../phplot.php"; $graph = new PHPlot(600, 400); $graph->SetPrintImage(0); //Don't draw the image yet $graph->SetDataType("data-data-error"); //Must be called before SetDataValues $graph->SetNewPlotAreaPixels(90, 40, 540, 190); $graph->SetDataValues($example_data); $graph->SetXGridLabelType("time"); $graph->SetXDataLabelAngle(90); $graph->SetXLabel(""); $graph->SetYLabel("Price"); $graph->SetVertTickIncrement(20); $graph->SetHorizTickIncrement(2679000); $graph->SetXTimeFormat("%b %y"); $graph->SetPlotType("lines"); $graph->SetErrorBarShape("line"); $graph->SetPointShape("halfline"); $graph->SetYScaleType("log"); $graph->SetLineWidth(1); $graph->SetPlotAreaWorld(883634400, 1, 915095000, 140); $graph->DrawGraph(); //Now do the second chart on the image unset($example_data); $graph->SetPrintImage(1); //Now draw the image $graph->SetYScaleType("linear"); include "./data_date.php"; $graph->SetDataType("data-data"); //Must be called before SetDataValues
# To get a repeatable test with 'random' data: mt_srand(1); # Need a base date/time: Can't just use 0 due to UTC/local differences: $base_time = mktime(0, 0, 0, 1, 1, 2000); # Twenty minutes: $interval = 20 * 60; # Random data at intervals: $data = array(); $t = $base_time; for ($i = 1; $i <= 12; $i++) { $data[] = array('', $t, mt_rand(0, 100)); $t += $interval; } $p = new PHPlot(600, 400); $p->SetTitle('Meaningless Data with Time X Tick Labels'); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetXLabelType('time'); $p->SetXTimeFormat('%H:%M'); $p->SetXTitle('Elapsed Time (hours:minutes)'); # Turn off X data labels, use tick labels only: $p->SetXDataLabelPos('none'); $p->SetXTickLabelPos('plotdown'); # Even though tick values are given, it makes up its own unless: $p->SetXTickIncrement($interval); $p->SetDrawXGrid(True); # Set the Y min and max, since the data is 0:100 $p->SetPlotAreaWorld(NULL, 0, NULL, 100); $p->SetYTitle('Meaningless Value'); $p->SetPlotType('lines'); $p->DrawGraph();
$prevDOfMonth = $DayOfMonth; } if ($debug) { print_r($allDays); } if ($debug) { print "I" . $maxValue . "I"; } include "../include/phplot/phplot.php"; $graph = new PHPlot(600, 300); $graph->SetDataType("text-data"); $graph->SetDataValues($allDays); $graph->SetYTickIncrement(); $graph->y_tick_increment = ceil(@$graph->y_tick_increment); $graph->SetXLabelType("time"); $graph->SetXTimeFormat("%b %d"); if ($incoming == '2') { $graph->SetLegend(array("Outgoing")); $graph->SetDataColors(array('green')); } elseif ($incoming == '3') { $graph->SetLegend(array("Incoming")); $graph->SetDataColors(array('orange')); } else { $graph->SetLegend(array("All", "Outgoing", "Incoming")); } $graph->SetYTitle("Quantity of calls"); $graph->SetPlotType("bars"); $graph->SetXLabelAngle(90); // Turn off X tick labels and ticks because they don't apply here: $graph->SetXTickLabelPos('none'); $graph->SetXTickPos('none');
<?php # $Id$ # Testing phplot - Date X axis labels, with data-data require_once 'phplot.php'; # H M S m d y $base_time = mktime(0, 0, 12, 6, 30, 2001); $one_day = 60 * 60 * 24; $data = array(array(0, 0, 2), array(0, 0, 4), array(0, 0, 2), array(0, 0, 4), array(0, 0, 2), array(0, 0, 4)); # Store time values as both label and X value: for ($i = 0; $i < 6; $i++) { $data[$i][0] = $data[$i][1] = $base_time + $i * $one_day; } $p = new PHPlot(600, 400); $p->SetTitle('lines, date-data with date X labels'); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetXLabelType('time'); # For example: # %Y-%m-%d 2004-12-31 # %b %Y Dec 2004 # %b %d, %Y Dec 31, 2004 # %d %b 31 Dec $p->SetXTimeFormat('%Y-%m-%d'); # Turn off X tick labels, use our data labels only: $p->SetXTickLabelPos('none'); # Then we have to turn off the ticks too, because they aren't placed right: $p->SetXTickPos('none'); $p->SetDrawXGrid(True); $p->SetPlotType('lines'); $p->DrawGraph();
<?php # $Id$ # Testing phplot - Date X axis labels require_once 'phplot.php'; # H M S m d y $base_time = mktime(0, 0, 0, 6, 30, 2001); $one_day = 60 * 60 * 24; $data = array(array(0, 2), array(0, 4), array(0, 6), array(0, 8), array(0, 7), array(0, 5)); for ($i = 0; $i < 6; $i++) { $data[$i][0] = $base_time + $i * $one_day; } $p = new PHPlot(600, 400); $p->SetTitle('bars, text-data with date X labels'); $p->SetDataType('text-data'); $p->SetDataValues($data); $p->SetXLabelType('time'); # For example: # %Y-%m-%d 2004-12-31 # %b %Y Dec 2004 # %b %d, %Y Dec 31, 2004 # %d %b 31 Dec $p->SetXTimeFormat('%d %b'); # Turn off X tick labels, use our data labels only: $p->SetXTickLabelPos('none'); # Then we have to turn off the ticks too, because they aren't placed right: $p->SetXTickPos('none'); $p->SetDrawXGrid(True); $p->SetPlotType('bars'); $p->DrawGraph();