Beispiel #1
0
function _stats_build_graph($data, $labels, $filename, $stat, $width, $height, $vars)
{
    if (file_exists($filename)) {
        unlink($filename);
    }
    $data_orig = $data;
    foreach ($data as $key => $val) {
        if (!is_numeric($val)) {
            $data[$key] = 0;
        }
    }
    // $vars["color_tab_black"]
    $bg_grey = _stats_color($vars["bg_grey"], 0);
    $bg_light_blue = _stats_color($vars["bg_light_blue"], 25);
    $graph = new Graph($width, $height);
    $group = new PlotGroup();
    $group->setSpace(2, 2);
    $group->grid->setType(LINE_DASHED);
    $group->grid->hideVertical(TRUE);
    $group->setPadding(30, 10, 25, 20);
    $graph->setBackgroundColor($bg_grey);
    $graph->title->set($stat);
    $graph->title->setFont(new Tuffy(10));
    $plot = new BarPlot($data, 1, 1, 0);
    $plot->setBarColor($bg_light_blue);
    $plot->label->set($data_orig);
    $plot->label->move(0, -5);
    $group->add($plot);
    $group->axis->bottom->setLabelText($labels);
    $group->axis->bottom->hideTicks(TRUE);
    $graph->add($group);
    $graph->draw($filename);
}
Beispiel #2
0
function Artichow_Histogram($Name, $File, $Lines, $Labels, $Colors)
{
    #-----------------------------------------------------------------------------
    $Graph = new Graph(800, 500);
    $Graph->setDriver('gd');
    $Graph->setAntiAliasing(TRUE);
    $Graph->title->set($Name);
    $Graph->title->move(0, -5);
    $Graph->border->hide();
    $Graph->setBackgroundGradient(new LinearGradient(new Color(240, 240, 240, 0), new White(), 0));
    #-----------------------------------------------------------------------------
    $Group = new PlotGroup();
    $Group->grid->hide(FALSE);
    $Group->setBackgroundColor(new Color(240, 240, 240));
    $Group->setSpace(2, 2, 20, 0);
    $Group->setPadding(60, 10, NULL, NULL);
    #-----------------------------------------------------------------------------
    foreach ($Lines as $LineID => $Value) {
        #---------------------------------------------------------------------------
        $Legend = $Value['Name'];
        unset($Value['Name']);
        #---------------------------------------------------------------------------
        $Plot = new BarPlot($Value, 1, 1, 0);
        $Plot->barShadow->setPosition(Shadow::RIGHT_TOP);
        $Plot->barShadow->setColor(new Color(160, 160, 160, 10));
        $Color = Color_RGB_Explode($Colors[$LineID]);
        $Plot->setBarColor(new Color($Color['R'], $Color['G'], $Color['B'], 56));
        #---------------------------------------------------------------------------
        $Group->add($Plot);
        $Group->legend->add($Plot, $Legend, Legend::BACKGROUND);
    }
    #-----------------------------------------------------------------------------
    $Group->axis->bottom->setLabelText($Labels);
    $Group->axis->bottom->hideTicks(TRUE);
    #-----------------------------------------------------------------------------
    $Group->legend->shadow->setSize(4);
    $Group->legend->setAlign(Legend::BOTTOM);
    $Group->legend->setSpace(5);
    $Group->legend->setTextFont(new Tuffy(8));
    $Group->legend->setPosition(0.3, 0.2);
    $Group->setPadding(50, 10, 50, 30);
    $Group->legend->setBackgroundColor(new Color(255, 255, 255, 25));
    #-----------------------------------------------------------------------------
    $Graph->add($Group);
    #-----------------------------------------------------------------------------
    $Graph->draw($File);
    #-----------------------------------------------------------------------------
    return TRUE;
}
 function create()
 {
     $group = new PlotGroup();
     $group->setSpace(2, 2, 2, 0);
     $group->setPadding(30, 10, NULL, NULL);
     $group->grid->hideVertical(TRUE);
     $group->grid->setType(LINE_DASHED);
     $yForeground = $this->getArg('yForeground');
     $yBackground = $this->getArg('yBackground');
     $legendForeground = $this->getArg('legendForeground');
     $legendBackground = $this->getArg('legendBackground');
     $colorForeground = $this->getArg('colorForeground', new LightBlue(10));
     $colorBackground = $this->getArg('colorBackground', new Orange(25));
     if ($yForeground === NULL) {
         awImage::drawError("Class BarDepthPattern: Argument 'yForeground' must not be NULL.");
     }
     // Background
     if ($yBackground !== NULL) {
         $plot = $this->getPlot($yBackground, 6);
         $plot->setBarColor($colorBackground);
         $group->add($plot);
         if ($legendBackground !== NULL) {
             $group->legend->add($plot, $legendBackground, LEGEND_BACKGROUND);
         }
     }
     // Foreground
     $plot = $this->getPlot($yForeground, 0);
     $plot->setBarColor($colorForeground);
     $group->add($plot);
     if ($legendForeground !== NULL) {
         $group->legend->add($plot, $legendForeground, LEGEND_BACKGROUND);
     }
     $group->axis->bottom->hideTicks(TRUE);
     $group->legend->shadow->setSize(0);
     $group->legend->setAlign(LEGEND_CENTER);
     $group->legend->setSpace(6);
     $group->legend->setTextFont(new Tuffy(8));
     $group->legend->setPosition(0.5, 0.1);
     $group->legend->setBackgroundColor(new Color(255, 255, 255, 10));
     $group->legend->setColumns(2);
     return $group;
 }
Beispiel #4
0
 public function create()
 {
     $group = new PlotGroup();
     $group->setSpace(2, 2, 2, 0);
     $group->setPadding(30, 10, NULL, NULL);
     $group->grid->hideVertical(TRUE);
     $group->grid->setType(Line::DASHED);
     $yForeground = $this->getArg('yForeground');
     $yBackground = $this->getArg('yBackground');
     $legendForeground = $this->getArg('legendForeground');
     $legendBackground = $this->getArg('legendBackground');
     $colorForeground = $this->getArg('colorForeground', new LightBlue(10));
     $colorBackground = $this->getArg('colorBackground', new Orange(25));
     if ($yForeground === NULL) {
         trigger_error("Argument 'yForeground' must not be NULL", E_USER_ERROR);
     }
     // Background
     if ($yBackground !== NULL) {
         $plot = $this->getPlot($yBackground, 6);
         $plot->setBarColor($colorBackground);
         $group->add($plot);
         if ($legendBackground !== NULL) {
             $group->legend->add($plot, $legendBackground, Legend::BACKGROUND);
         }
     }
     // Foreground
     $plot = $this->getPlot($yForeground, 0);
     $plot->setBarColor($colorForeground);
     $group->add($plot);
     if ($legendForeground !== NULL) {
         $group->legend->add($plot, $legendForeground, Legend::BACKGROUND);
     }
     $group->axis->bottom->hideTicks(TRUE);
     $group->legend->shadow->setSize(0);
     $group->legend->setAlign(Legend::CENTER);
     $group->legend->setSpace(6);
     $group->legend->setTextFont(new Tuffy(8));
     $group->legend->setPosition(0.5, 0.1);
     $group->legend->setBackgroundColor(new Color(255, 255, 255, 10));
     $group->legend->setColumns(2);
     return $group;
 }
<?php

require_once "../../ScatterPlot.class.php";
$graph = new Graph(280, 280);
$graph->title->move(-40, 0);
$graph->title->set('Two circles');
$group = new PlotGroup();
$group->setBackgroundGradient(new LinearGradient(new VeryLightGray(), new Color(245, 245, 245), 0));
$group->setPadding(25, 20, 40, 15);
$group->setSpace(5, 5, 5, 5);
$group->legend->setPosition(0.82, 0.1);
$group->legend->setAlign(LEGEND_CENTER, LEGEND_MIDDLE);
function getCircle($size)
{
    $center = 0;
    $x = array();
    $y = array();
    for ($i = 0; $i <= 20; $i++) {
        $rad = $i / 20 * 2 * M_PI;
        $x[] = $center + cos($rad) * $size;
        $y[] = $center + sin($rad) * $size;
    }
    return array($x, $y);
}
list($x, $y) = getCircle(3);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkBlue());
$plot->mark->setFill(new DarkPink());
$plot->mark->setType(MARK_CIRCLE, 6);
$group->legend->add($plot, 'Circle #1', LEGEND_MARK);
$group->add($plot);
Beispiel #6
0
     $plot->setSize(0.65, 0.7);
     $plot->set3D(10);
     $plot->setLabelPosition(10);
     $plot->setLegend($keys);
     $plot->legend->setPosition(1.37);
     $plot->legend->shadow->setSize(0);
     $plot->legend->setBackgroundColor(new Color(235, 235, 235));
     $graph->add($plot);
 } else {
     if ($type == "line" or $type == "linesteps") {
         require INCLUDE_PATH . "/LinePlot.class.php";
         $graph = new Graph($width, $height);
         $graph->title->set($title);
         $graph->title->setFont(new Tuffy(11));
         $group = new PlotGroup();
         $group->setSpace(1, 0);
         $group->setPadding(25, 15, 27, 20);
         $group->grid->setType(LINE_DASHED);
         $group->grid->hideVertical(TRUE);
         if ($type == "linesteps") {
             list($data_new, $data_label, $keys_new) = build_line_steps($width, $data, $keys);
         } else {
             $data_new = $data;
             $data_label = $data;
             $keys_new = $keys;
         }
         $plot = new LinePlot($data_new);
         $plot->setColor(new Color(0, 0, 255));
         $plot->setFillColor(new LightBlue(40));
         $plot->label->set($data_label);
         $plot->label->move(5, -7);
Beispiel #7
0
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
$graph = new Graph(280, 280);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setSpace(6, 6, 5, 5);
$group->setBackgroundGradient(new LinearGradient(new Color(235, 235, 235), new White(), 0));
$group->setPadding(40, 10, 10, 50);
$group->axis->left->setLabelPrecision(2);
$group->axis->bottom->label->hide(TRUE);
$group->axis->bottom->hideTicks(TRUE);
$group->grid->setType(LINE_DASHED);
$group->grid->hideHorizontal(TRUE);
$gradients = array(new LinearGradient(new Color(30, 30, 160, 10), new Color(120, 120, 160, 10), 0), new LinearGradient(new Color(30, 160, 30, 10), new Color(120, 160, 120, 10), 0), new LinearGradient(new Color(160, 30, 30, 10), new Color(160, 120, 120, 10), 0));
for ($n = 0; $n < 3; $n++) {
    $x = array();
    for ($i = 0; $i < 6; $i++) {
        $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 900) / 1000 - 0.5) * ($n % 2 ? -0.5 : 1) + ($n % 2 ? -0.4 : 0);
    }
    $plot = new BarPlot($x, $n + 1, 3);
    $plot->setXAxis(PLOT_BOTTOM);
    $plot->barShadow->setSize(1);
    $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../LinePlot.class.php";
require_once "../../BarPlot.class.php";
$graph = new Graph(600, 250);
$graph->setBackgroundColor(new Color(0xf4, 0xf4, 0xf4));
$graph->shadow->setSize(3);
$graph->title->set("Evolution");
$graph->title->setFont(new Tuffy(15));
$graph->title->setColor(new Color(0x0, 0x0, 0x8b));
$group = new PlotGroup();
$group->setSize(0.82, 1);
$group->setCenter(0.41, 0.5);
$group->setPadding(35, 26, 40, 27);
$group->setSpace(2, 2);
$group->grid->setColor(new Color(0xc4, 0xc4, 0xc4));
$group->grid->setType(LINE_DASHED);
$group->grid->hideVertical(TRUE);
$group->grid->setBackgroundColor(new White());
$group->axis->left->setColor(new DarkGreen());
$group->axis->left->label->setFont(new Font2());
$group->axis->right->setColor(new DarkBlue());
$group->axis->right->label->setFont(new Font2());
$group->axis->bottom->label->setFont(new Font2());
$group->legend->setPosition(1.18);
$group->legend->setTextFont(new Tuffy(8));
$group->legend->setSpace(10);
// Add a bar plot
$x = array(16, 16, 12, 13, 11, 18, 10, 12, 11, 12, 11, 16);
$plot = new BarPlot($x, 1, 2);
Beispiel #9
0
/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
function labelFormat($value)
{
    return round($value, 2);
}
$graph = new Graph(280, 200);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setSpace(5, 5, 15, 0);
$group->setPadding(40, 40);
$group->axis->left->setLabelPrecision(2);
$group->axis->right->setLabelPrecision(2);
$colors = array(new Color(80, 105, 190, 10), new Color(105, 190, 80, 10));
$darkColor = array(new Color(40, 55, 120, 10), new Color(55, 120, 40, 10));
$axis = array(PLOT_LEFT, PLOT_RIGHT);
$group->axis->left->setColor($darkColor[0]);
$group->axis->left->label->setColor($darkColor[0]);
$group->axis->right->setColor($darkColor[1]);
$group->axis->right->label->setColor($darkColor[1]);
$group->setBackgroundGradient(new LinearGradient(new Color(225, 225, 225), new Color(255, 255, 255), 0));
for ($n = 0; $n < 2; $n++) {
    $x = array();
    for ($i = 0; $i < 4; $i++) {
        $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * ($n % 2 ? -0.5 : 1) + ($n % 2 ? -0.4 : 0) + 1;
Beispiel #10
0
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../BarPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Two bars with depth');
$group = new PlotGroup();
$group->setPadding(NULL, NULL, 35, NULL);
$group->setSpace(5, 5, NULL, NULL);
$group->grid->hide(TRUE);
$values = array(1, 7, 2, 10, 6, 3, 4, 7);
$plot = new BarPlot($values, 1, 1, 5);
$plot->setBarColor(new LightBlue(25));
$group->add($plot);
$values = array(12, 8, 13, 2, 4, 8, 4, 3);
$plot = new BarPlot($values, 1, 1, 0);
$plot->setBarColor(new LightRed(25));
$group->add($plot);
$graph->add($group);
$graph->draw();
Beispiel #11
0
function dis_chart_bar_multiple($chart) {
  global $chart_colors;

  $title = $chart["title"];
  $xlabels = $chart["xlabels"];
  $values = $chart["plots"]["values"];
  $labels = $chart["plots"]["labels"];
  $legends = $chart["plots"]["legends"];
  $new_bar = $chart["plots"]["new_bar"];

  $graph = new Graph(600, 250);
  $graph->setAntiAliasing(TRUE);
  $graph->setBackgroundColor(new Color(240, 240, 240));
  $group = new PlotGroup;
  $group->grid->hideVertical();
  $group->setPadding(45, 22 ,30, 40);
  $group->setSpace(3, 3, NULL, NULL);
  $group->legend->setAlign(NULL, LEGEND_TOP);
  $group->legend->setPosition(1,0);

  // X axis Labels infos
  $xlabel = new Label($xlabels);
  $group->axis->bottom->setlabelText($xlabels);

  // Title infos
  if ($title != "") {
    $graph->title->set("$title");
  }

  $num = 0;
  $nb_bars = array_sum($new_bar);
  $num_bar = 0;

  // $num_plot is the plot number
  // $num_bar is the bar number (1 bar can cumul more than one plot)
  foreach ($values as $num_plot => $plot_values) {
    // Chart infos : colors, size, shadow
    if ($new_bar[$num_plot] == 1) {
      $num_bar++;
    }
    $plot = new BarPlot($plot_values, $num_bar, $nb_bars);
    $plot->setBarColor(new Color($chart_colors[$num_plot][0], $chart_colors[$num_plot][1], $chart_colors[$num_plot][2]));
    $plot->setBarSize(0.6);
    if ($new_bar[$num_plot] == 1) {
      $plot->barShadow->setSize(2);
      $plot->barShadow->smooth(TRUE);
      // Labels infos
      $label = new Label($labels[$num_plot]);
      $label->setFont(new Tuffy(8));
      $label->setAlign(NULL, LABEL_TOP);
      $plot->label = $label;
    }
    $group->add($plot);
    $group->legend->add($plot, utf8_decode($legends[$num_plot]), LEGEND_BACKGROUND);
  }

  $graph->add($group);
  $graph->draw();
}
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
function color($a = NULL)
{
    if ($a === NULL) {
        $a = 0;
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph(400, 400);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setSpace(3, 3, 5, 5);
$group->setBackgroundGradient(new LinearGradient(new Color(200, 200, 200), new Color(240, 240, 240), 0));
$group->setPadding(NULL, NULL, 25, 25);
$group->axis->left->setLabelPrecision(2);
for ($n = 0; $n < 4; $n++) {
    $x = array();
    for ($i = 0; $i < 5; $i++) {
        $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * ($n % 2 ? -0.5 : 1) + ($n % 2 ? -0.4 : 0);
    }
    $plot = new BarPlot($x, $n + 1, 4);
    $plot->barBorder->hide();
    $plot->setXAxis(PLOT_TOP);
    $plot->barShadow->setSize(4);
    $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
    $plot->barShadow->setColor(new Color(255, 255, 255, 20));
    $plot->barShadow->smooth(TRUE);
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
function color($a = NULL)
{
    if ($a === NULL) {
        $a = 0;
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph(500, 400);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setSpace(5, 10, 15, 15);
$group->setPadding(40, 40, 25, 25);
$group->axis->left->setLabelPrecision(2);
for ($n = 0; $n < 4; $n++) {
    $x = array();
    for ($i = 0; $i < 6; $i++) {
        $x[] = cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 1400) / 1000 - 0.5 + 1;
    }
    $plot = new BarPlot($x, 1, 1, (3 - $n) * 7);
    $plot->barBorder->setColor(color());
    $plot->barShadow->setSize(3);
    $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
    $plot->barShadow->setColor(new Color(180, 180, 180, 10));
    $plot->barShadow->smooth(TRUE);
    $plot->setBarColor(color(5));
    $group->add($plot);
Beispiel #14
0
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../BarPlot.class.php";
$graph = new Graph(300, 200);
$graph->setAntiAliasing(TRUE);
$graph->border->hide();
$group = new PlotGroup();
$group->grid->hide(TRUE);
$group->setSpace(2, 2, 20, 0);
$group->setPadding(30, 10, NULL, NULL);
$colors = array(new Orange(25), new LightBlue(10));
for ($n = 0; $n < 2; $n++) {
    $x = array();
    for ($i = 0; $i < 3 - $n * 3; $i++) {
        $x[] = NULL;
    }
    for ($i = 3 - $n * 3; $i < 12 - $n * 3; $i++) {
        $x[] = cos($i * M_PI / 100) * mt_rand(800, 1200) / 1000 * (((1 - $n) * 5 + 10) / 10);
    }
    for ($i = 0; $i < $n * 3; $i++) {
        $x[] = NULL;
    }
    $plot = new BarPlot($x, 1, 1, (1 - $n) * 6);
    //	$plot->setBarPadding(2, 2);