Beispiel #1
0
 * 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);
// Set a title to the graph
$graph->title->set('The title');
// Change graph background color
$graph->setBackgroundColor(new Color(230, 230, 230));
$values = array(8, 2, 6, 1, 3, 5);
// Declare a new BarPlot
$plot = new BarPlot($values);
// Reduce padding around the plot
$plot->setPadding(NULL, NULL, NULL, 20);
// Reduce plot size and move it to the bottom of the graph
$plot->setSize(1, 0.96);
$plot->setCenter(0.5, 0.52);
// Set a background color to the plot
$plot->grid->setBackgroundColor(new White());
// Set a dashed grid
$plot->grid->setType(LINE_DASHED);
$plot->label->set($values);
$plot->label->move(0, -10);
$plot->label->setColor(new DarkBlue());
// Set a shadow to the bars
$plot->barShadow->setSize(2);
// Bar size is at 60%
$plot->setBarSize(0.6);
// Change the color of the bars
$plot->barShadow->smooth(TRUE);
$mois = array('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun', 'Juil', 'Août', 'Sept', 'Oct', 'Nov', 'Déc');
$label = array();
foreach ($mois as $m) {
    $label[] = $m;
}
$label[] = ' ';
foreach ($mois as $m) {
    $label[] = $m;
}
$plot->xAxis->setLabelText($label);
/* ICI */
$max = array_max($values);
$yValues = array();
for ($i = 0; $i <= $max; $i++) {
    $yValues[] = $i;
}
$plot->yAxis->setLabelText($yValues);
// Image::drawError(var_export($yValues, TRUE));
$plot->yAxis->setLabelText($yValues);
$plot->setPadding(30, 5, 20, 15);
$labelAvant = new Label("2005");
$labelAvant->setFont(new TTFFont(ARTICHOW_FONT . '/TuffyBold.ttf', 12));
$labelAvant->move(180, 10);
$labelMaintenant = new Label("2006");
$labelMaintenant->setFont(new TTFFont(ARTICHOW_FONT . '/TuffyBold.ttf', 12));
$labelMaintenant->move(450, 10);
$graph->add($plot);
$graph->addLabel($labelAvant, 0, 0);
$graph->addLabel($labelMaintenant, 0, 0);
$graph->draw();
Beispiel #3
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, 200);
$graph->setAntiAliasing(TRUE);
$x = array(1, 2, 5, 0.5, 3, 8, 6);
$plot = new BarPlot($x);
$plot->setSpace(4, 4, 10, 0);
$plot->setPadding(40, 15, 10, 40);
$plot->title->set("Zoé and friends");
$plot->title->setFont(new TuffyBold(11));
$plot->title->border->show();
$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
$plot->title->setPadding(4, 4, 4, 4);
$plot->title->move(-20, 25);
$plot->yAxis->title->set("Axe des Y");
$plot->yAxis->title->setFont(new TuffyBold(10));
$plot->yAxis->title->move(-4, 0);
$plot->yAxis->setTitleAlignment(LABEL_TOP);
$plot->xAxis->title->set("Axe des X");
$plot->xAxis->title->setFont(new TuffyBold(10));
$plot->xAxis->setTitleAlignment(LABEL_RIGHT);
$plot->setBackgroundGradient(new LinearGradient(new Color(230, 230, 230), new Color(255, 255, 255), 0));
$plot->barBorder->setColor(new Color(0, 0, 150, 20));