public function doGet(WebAppRequest $req, WebAppResponse $res) { // Bootstraps Innomatic require_once 'innomatic/core/InnomaticContainer.php'; $innomatic = InnomaticContainer::instance('innomaticcontainer'); // Sets Innomatic base URL $baseUrl = ''; $webAppPath = $req->getUrlPath(); if (!is_null($webAppPath) && $webAppPath != '/') { $baseUrl = $req->generateControllerPath($webAppPath, true); } $innomatic->setBaseUrl($baseUrl); $innomatic->setInterface(InnomaticContainer::INTERFACE_WEB); $home = WebAppContainer::instance('webappcontainer')->getCurrentWebApp()->getHome(); $innomatic->bootstrap($home, $home . 'core/conf/innomatic.ini'); $id = basename($req->getParameter('id')); //$id = basename($_GET['id']); $args = unserialize(file_get_contents(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id)); require_once 'phplot/PHPlot.php'; $graph = new PHPlot($args['width'], $args['height']); $graph->SetIsInline('1'); //$graph->SetDataColors( array("blue",'white'),array("black") ); //$graph->$line_style = array('dashed','dashed','solid','dashed','dashed','solid'); // Base $graph->SetDataValues($args['data']); $graph->SetPlotType($args['plottype']); // Appearance $graph->SetPointShape($args['pointshape']); $graph->SetPointSize($args['pointsize']); $graph->SetTitle($args['title']); // Color $graph->SetBackgroundColor($args['backgroundcolor']); $graph->SetGridColor($args['gridcolor']); if (count($args['legend'])) { $graph->SetLegend($args['legend']); } $graph->SetLineWidth($args['linewidth']); $graph->SetTextColor($args['textcolor']); $graph->SetDataColors(array(array(145, 165, 207), array(114, 167, 112), array(71, 85, 159), array(175, 83, 50), array(247, 148, 53), array(240, 231, 125), array(154, 204, 203), array(201, 164, 196)), 'black'); //$graph->data_color = array( array(145,165,207), array(114,167,112), array(71,85,159), array(175,83,50), array(247,148,53), array(240,231,125), array(154,204,203), array(201,164,196) ); //array('blue','green','yellow','red','orange'); $graph->DrawGraph(); unlink(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id); }
$graph->SetMarginsPixels(50, 50, 50, 50); $graph->SetLegend(array('Time in Flight', 'Time to Stop')); //Lets have a legend $graph->SetLegendWorld(1, 8); //Lets have a legend position //Draw it $graph->DrawGraph(); //////////////////////NEXT SETTINGS $example_data = array(array("a", 60), array("b", 40), array("c", 50), array("d", 50), array("e", 80), array("f", 90), array("f", 40)); $graph->SetDataValues($example_data); $graph->SetDataColors(array("red"), array("green")); $graph->SetDrawXDataLabels(0); //We already got them in the first graph $graph->SetPlotAreaWorld(0, 0, 7.5, 100); //New Plot Area $graph->SetLegend(array('Size of Dog')); //Lets add a second legend $graph->DrawLegend(55, 55, ''); //Set Params of another Y Axis $graph->SetVertTickPosition('yaxis'); $graph->SetYGridLabelType('right'); $graph->SetYAxisPosition(7.5); $graph->SetPrecisionY(0); $graph->SetTickColor('red'); $graph->SetTextColor('red'); $graph->SetGridColor('red'); $graph->DrawYAxis(); //Draw the New data over the first graph $graph->DrawLines(); $graph->DrawDots(); $graph->PrintImage();
function guifi_stats_chart07() { include drupal_get_path('module', 'guifi') . '/contrib/phplot/phplot.php'; $gDirTTFfonts = drupal_get_path('module', 'guifi') . '/contrib/fonts/'; if (isset($_GET['width'])) { $gwidth = $_GET['width']; } else { $gwidth = 500; } if (isset($_GET['height'])) { $gheight = $_GET['height']; } else { $gheight = 450; } $today = getdate(); $year = $today[year]; $month = $today[mon]; $month = $month - 12; $n = 0; $tot = 0; if ($month < 1) { $year = $year - 1; $month = 12 + $month; } $datemin = mktime(0, 0, 0, $month, 1, $year); if (isset($_GET['zone'])) { $zone_id = $_GET['zone']; if ($zone_id == "0") { $zone_id = "0"; } //"3671"; } else { $zone_id = "0"; } $avalue = array(); $adata = array(); for ($i = 0; $i < 10; $i++) { $adata[] = array(0, 0); } $vsql = "select sum(if(timestamp_created >= " . $datemin . ",1,0)) as num, count(*) as total, zone_id\n from {guifi_location}\n where status_flag='Working' "; if ($zone_id != "0") { $achilds = guifi_zone_childs($zone_id); $v = ""; foreach ($achilds as $key => $child) { if ($v == "") { $v .= "zone_id=" . $child; } else { $v .= " or zone_id=" . $child; } } $vsql .= "AND (" . $v . ") "; } $vsql .= "GROUP BY zone_id "; $result = db_query($vsql); while ($record = db_fetch_object($result)) { if ($record->total >= 20) { $vn = $record->num / $record->total * 100; $vmin = 0; for ($i = 1; $i < 10; $i++) { if ($adata[$vmin][1] > $adata[$i][1]) { $vmin = $i; } } if ($vn > $adata[$vmin][1]) { $adata[$vmin][0] = $record->zone_id; $adata[$vmin][1] = $vn; } } } for ($i = 0; $i < 10; $i++) { if ($adata[$i][1] != 0) { $avalue[$adata[$i][0]] = $adata[$i][1]; } } arsort($avalue); foreach ($avalue as $key => $value) { if ($value != 0) { $data[] = array(substr(guifi_get_zone_name($key), 0, 20) . " �", $value); } } $shapes = array('none'); $plot = new PHPlot($gwidth, $gheight); $plot->SetPlotAreaWorld(0, 0, NULL, NULL); $plot->SetFileFormat('png'); $plot->SetDataType("text-data"); $plot->SetDataValues($data); $plot->SetPlotType("bars"); $plot->SetXTickIncrement(1); $plot->SetSkipBottomTick(TRUE); $plot->SetSkipLeftTick(TRUE); $plot->SetTickLength(0); //$plot->SetXTickPos('none'); $plot->SetYDataLabelPos('plotin'); $plot->SetYLabelType('data', 0); $plot->SetTickColor('grey'); $plot->SetTTFPath($gDirTTFfonts); $plot->SetFontTTF('title', 'Vera.ttf', 12); $plot->SetFontTTF('x_label', 'Vera.ttf', 8); if (isset($_GET['title'])) { $plot->SetTitle("guifi.net \n" . t($_GET['title'])); } else { if ($zone_id == "0") { $plot->SetTitle("guifi.net \n" . t('Largest annual increase')); } else { $plot->SetTitle("guifi.net " . t('zone') . ": " . guifi_get_zone_name($zone_id) . "\n" . t('Largest annual increase')); } } //$plot->SetXTitle(t('Zones')); $plot->SetYTitle(t('% increase')); $plot->SetXDataLabelPos('plotdown'); //$plot->SetXLabelAngle(45); $plot->SetXDataLabelAngle(75); $plot->SetGridColor('red'); $plot->SetPlotBorderType('left'); $plot->SetDataColors(array('orange')); $plot->SetTextColor('DimGrey'); $plot->SetTitleColor('DimGrey'); $plot->SetLightGridColor('grey'); $plot->SetBackgroundColor('white'); $plot->SetTransparentColor('white'); $plot->SetIsInline(TRUE); $plot->DrawGraph(); }
# $Id$ # PHPlot test: Coloring various items require_once 'phplot.php'; $data = array(); $x = 0.0; $dx = M_PI / 4.0; for ($i = 0; $i < 50; $i++) { $y = $x * sin($x); $data[] = array('', $i, $y); $x += $dx; } $plot = new PHPlot(800, 600); $plot->SetPlotType('lines'); $plot->SetDataType('data-data'); $plot->SetDataValues($data); $plot->SetLineWidths(2); $plot->SetPlotAreaWorld(0, -40, 50, 40); # Turn everything on to test colors: $plot->SetTitle("Color Tests\n" . " SetGridColor blue (used for axes, legend border)\n" . " SetLightGridColor magenta\n" . " SetTextColor red\n" . " SetTickColor green\n" . " SetTitleColor gold"); $plot->SetDrawXGrid(True); $plot->SetDrawYGrid(True); $plot->SetLegend('Color Tests'); $plot->SetXTitle('X Title Here'); $plot->SetYTitle('Y Title Here'); # Set colors: $plot->SetGridColor('blue'); $plot->SetLightGridColor('magenta'); $plot->SetTextColor('red'); $plot->SetTickColor('green'); $plot->SetTitleColor('gold'); $plot->DrawGraph();
function plot_guifi() { include drupal_get_path('module', 'guifi') . '/contrib/phplot/phplot.php'; $result = db_query("select COUNT(*) as num, MONTH(FROM_UNIXTIME(timestamp_created)) as mes, YEAR(FROM_UNIXTIME(timestamp_created)) as ano from {guifi_location} where status_flag='Working' GROUP BY YEAR(FROM_UNIXTIME(timestamp_created)),MONTH(FROM_UNIXTIME(timestamp_created)) "); $inicial = 5; $nreg = $inicial; $tot = 0; $ano = 2004; $mes = 5; $items = 2004; $label = ""; while ($record = db_fetch_object($result)) { if ($record->ano >= 2004) { if ($mes == 12) { $mes = 1; $ano++; } else { $mes++; } while ($ano < $record->ano || $mes < $record->mes) { $nreg++; if ($mes == 6) { $label = $ano; } else { $label = ''; } $data[] = array("{$label}", $nreg, $tot, ''); if ($mes == 12) { $mes = 1; $ano++; } else { $mes++; } } $tot += $record->num; $nreg++; if ($mes == 6) { $label = $ano; } else { $label = ''; } $data[] = array("{$label}", $nreg, $tot, ''); } else { $tot += $record->num; } } while ($mes < 12) { $nreg++; $mes++; if ($mes == 6) { $label = $ano; } else { $label = ''; } $data[] = array("{$label}", $nreg, ""); } $items = ($ano - $items + 1) * 12; if ($tot % 1000 < 30) { $data[$nreg - $inicial - 1][3] = $tot; $vt = floor($tot / 1000) * 1000; $vtitle = $vt . " " . t('Nodes') . "!!!"; $tcolor = 'red'; } else { $vtitle = t('Working nodes'); $tcolor = 'DimGrey'; } $shapes = array('none', 'circle'); $plot = new PHPlot(200, 150); $plot->SetPlotAreaWorld(0, 0, $items, NULL); $plot->SetFileFormat('png'); $plot->SetDataType("data-data"); $plot->SetDataValues($data); $plot->SetPlotType("linepoints"); $plot->SetYTickIncrement(2000); $plot->SetXTickIncrement(12); $plot->SetSkipBottomTick(TRUE); $plot->SetSkipLeftTick(TRUE); $plot->SetXAxisPosition(0); $plot->SetPointShapes($shapes); $plot->SetPointSizes(10); $plot->SetTickLength(3); $plot->SetDrawXGrid(TRUE); $plot->SetTickColor('grey'); $plot->SetTitle($vtitle); $plot->SetDrawXDataLabelLines(FALSE); $plot->SetXLabelAngle(0); $plot->SetXLabelType('custom', 'Plot1_LabelFormat'); $plot->SetGridColor('red'); $plot->SetPlotBorderType('left'); $plot->SetDataColors(array('orange')); $plot->SetTextColor('DimGrey'); $plot->SetTitleColor($tcolor); $plot->SetLightGridColor('grey'); $plot->SetBackgroundColor('white'); $plot->SetTransparentColor('white'); $plot->SetXTickLabelPos('none'); $plot->SetXDataLabelPos('plotdown'); $plot->SetIsInline(TRUE); $plot->DrawGraph(); }
<?php require 'amproot.php'; init_amp_root(); OpenLibrary('phplot.library'); $id = basename($_GET['id']); $args = unserialize(file_get_contents(TMP_PATH . 'phplot/' . $id)); $graph = new PHPlot($args['width'], $args['height']); $graph->SetIsInline('1'); //$graph->SetDataColors( array("blue",'white'),array("black") ); //$graph->$line_style = array('dashed','dashed','solid','dashed','dashed','solid'); // Base $graph->SetDataValues($args['data']); $graph->SetPlotType($args['plottype']); // Appearance $graph->SetPointShape($args['pointshape']); $graph->SetPointSize($args['pointsize']); $graph->SetTitle($args['title']); // Color $graph->SetBackgroundColor($args['backgroundcolor']); $graph->SetGridColor($args['gridcolor']); if (count($args['legend'])) { $graph->SetLegend($args['legend']); } $graph->SetLineWidth($args['linewidth']); $graph->SetTextColor($args['textcolor']); $graph->SetDataColors(array(array(145, 165, 207), array(114, 167, 112), array(71, 85, 159), array(175, 83, 50), array(247, 148, 53), array(240, 231, 125), array(154, 204, 203), array(201, 164, 196)), 'black'); //$graph->data_color = array( array(145,165,207), array(114,167,112), array(71,85,159), array(175,83,50), array(247,148,53), array(240,231,125), array(154,204,203), array(201,164,196) ); //array('blue','green','yellow','red','orange'); $graph->DrawGraph(); unlink(TMP_PATH . 'phplot/' . $id);
# case 1) GridColor set, PieLabelColor not set. Labels use GridColor. # case 2) GridColor set, PieLabelColor set. Labels use PieLabelColor. # For post-5.6.0 with new color control function. require_once 'phplot.php'; if (empty($case)) { $case = 0; } $colors = array('grid' => 'green', 'pielabel' => 'blue'); $data = array(array('Baseball', 100), array('Football', 85), array('Basketball', 53), array('Hockey', 48)); $plot = new PHPlot(800, 600); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); $plot->SetPlotType('pie'); $title = "Pie Chart Label Color\n"; if ($case == 1 || $case == 2) { $plot->SetGridColor($colors['grid']); $title .= "GridColor set to {$colors['grid']}\n"; } else { $title .= "GridColor is NOT set\n"; } if ($case == 2) { $plot->SetPieLabelColor($colors['pielabel']); $title .= "PieLabelColor set to {$colors['pielabel']}\n"; } else { $title .= "PieLabelColor is NOT set\n"; } $plot->SetPieLabelType(array('label', 'value')); foreach ($data as $row) { $plot->SetLegend($row[0]); } $plot->SetTitle($title);
$row[] = sin($x + $i * $phase_factor); } $data[] = $row; } $plot = new PHPlot(1000, 800); $plot->SetPlotType('linepoints'); $plot->SetDataType('data-data'); $plot->SetDataValues($data); $plot->SetTitle("Line Plot, {$n} phases of Sin(x)"); $plot->SetPlotAreaWorld(0, -1, 2 * M_PI, 1); # Range: [0,-1] : [2 Pi, 1] $plot->SetXTickIncrement(M_PI / 8.0); # X tick step $plot->SetYTickIncrement(0.2); # Y tick step $plot->SetXLabelType('data', 3); # Format X tick labels as N.NNN $plot->SetLineStyles('solid'); # Make all lines solid $plot->SetYLabelType('data', 1); # Format Y tick labels as N.N $plot->SetDrawXGrid(True); # Draw X grid lines $plot->SetDrawYGrid(True); # Draw Y grid lines # Because one of the data colors is almost white, switch to black background: $plot->SetBackgroundColor('black'); $plot->SetTitleColor('white'); $plot->SetTextColor('white'); $plot->SetGridColor('white'); $plot->DrawGraph();
$title .= ', Width: '; if (empty($tp['ibwidth'])) { $title .= '(default)'; } else { $title .= $tp['ibwidth']; } $p->SetTitle($title); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetDrawXGrid(False); $p->SetDrawYGrid(False); if (!empty($tp['plotborder'])) { $p->SetPlotBorderType($tp['plotborder']); } if (!empty($tp['pbcolor'])) { $p->SetGridColor($tp['pbcolor']); } if (!empty($tp['imageborder'])) { $p->SetImageBorderType($tp['imageborder']); } if (!empty($tp['ibcolor'])) { $p->SetImageBorderColor($tp['ibcolor']); } if (!empty($tp['ibwidth'])) { $p->SetImageBorderWidth($tp['ibwidth']); } # Move Y axis in so affect of plot area borders is more visible: $p->SetYAxisPosition(0); # Turn on all side labels, ticks, titles: $p->SetXTickLabelPos('both'); $p->SetXTickPos('both');
} else { $c = 'default'; } if (isset($grid_color)) { $g = $grid_color; } else { $g = 'default'; } if (isset($shading)) { $shade = "Shading: {$shading}"; } else { $shade = "Unshaded"; } $title = "Test Pie Border Control, {$shade}\n" . "Border: {$b}, Border color: {$c}, Grid color: {$g}"; $plot = new PHPlot(800, 600); $plot->SetTitle($title); $plot->SetImageBorderType('plain'); $plot->SetPlotType('pie'); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); $plot->SetShading(isset($shading) ? $shading : 0); if (isset($border_color)) { $plot->SetPieBorderColor($border_color); } if (isset($border_on)) { $plot->SetDrawPieBorders($border_on); } if (isset($grid_color)) { $plot->SetGridColor($grid_color); } $plot->DrawGraph();