$a = 0;
    }
    return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph();
$graph->setTiming(TRUE);
$graph->setSize(400, 400);
$graph->setAntiAliasing(TRUE);
$x = array();
$k = array();
for ($i = 0; $i < 100; $i++) {
    $x[] = cos($i / 10);
    $k[] = sprintf("%.1f", $i / 10);
}
$plot = new LinePlot($x, $k);
$plot->setBackgroundColor(color(80));
$plot->setYAxis(PLOT_BOTH);
$plot->setColor(color());
$plot->grid->setInterval(mt_rand(1, 4), mt_rand(1, 4));
$plot->yAxis->setLabelNumber(20);
$plot->yAxis->setLabelPrecision(1);
$plot->xAxis->setTickInterval(5);
$plot->xAxis->setLabelInterval(2);
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->label->hideLast(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 1);
$plot->xAxis->setLabelText($k);
foreach ($x as $k => $v) {
    $x[$k] = sprintf("%.2f", $v);
}
$plot->label->set($x);
<?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 "../../LinePlot.class.php";
$graph = new Graph(450, 400);
$graph->setAntiAliasing(TRUE);
$values = array();
for ($i = 0; $i < 15; $i++) {
    $values[] = mt_rand(4, 20);
}
$graph->title->set('Mon graphique');
$plot = new LinePlot($values, LINEPLOT_MIDDLE);
$plot->setFillColor(new Color(0, 200, 0, 75));
$plot->mark->setType(MARK_CIRCLE);
$plot->mark->setSize(8);
$plot->mark->setFill(new Color(255, 255, 255));
$plot->mark->border->show();
$plot->setSpace(5, 5, 5, 5);
$plot->setBackgroundColor(new Color(240, 240, 240));
$graph->add($plot);
$graph->draw();
Exemplo n.º 3
0
 private function _renderPlotScatter($groupID, $bubble)
 {
     $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
     $scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
     $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
     $seriesPlots = array();
     //	Loop through each data series in turn
     for ($i = 0; $i < $seriesCount; ++$i) {
         $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
         $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
         foreach ($dataValuesY as $k => $dataValueY) {
             $dataValuesY[$k] = $k;
         }
         $seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY);
         if ($scatterStyle == 'lineMarker') {
             $seriesPlot->SetLinkPoints();
             $seriesPlot->link->setBackgroundColor(self::$_colourSet[self::$_plotColour]);
         } elseif ($scatterStyle == 'smoothMarker') {
             $spline = new Spline($dataValuesY, $dataValuesX);
             list($splineDataY, $splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20);
             $lplot = new LinePlot($splineDataX, $splineDataY);
             $lplot->setBackgroundColor(self::$_colourSet[self::$_plotColour]);
             $this->_graph->Add($lplot);
         }
         if ($bubble) {
             $this->_formatPointMarker($seriesPlot, 'dot');
             $seriesPlot->mark->setBackgroundColor('black');
             $seriesPlot->mark->SetSize($bubbleSize);
         } else {
             $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
             $this->_formatPointMarker($seriesPlot, $marker);
         }
         $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
         $seriesPlot->SetLegend($dataLabel);
         $this->_graph->Add($seriesPlot);
     }
 }
Exemplo n.º 4
0
<?php

require_once "../../LinePlot.class.php";
$graph = new Graph(400, 300);
$graph->setAntiAliasing(TRUE);
$values = array(1, 7, 3, 2.5, 5, -4.5, -5);
$plot = new LinePlot($values);
$plot->setBackgroundColor(new Color(245, 245, 245));
$plot->hideLine(TRUE);
$plot->setFillColor(new Color(180, 180, 180, 75));
$plot->grid->setBackgroundColor(new Color(235, 235, 180, 60));
$plot->yAxis->setLabelPrecision(2);
$plot->yAxis->setLabelNumber(6);
$days = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche');
$plot->xAxis->setLabelText($days);
$plot->setSpace(6, 6, 10, 10);
$plot->mark->setType(MARK_IMAGE);
$plot->mark->setImage(new FileImage("smiley.png"));
$plot->label->set($values);
$plot->label->move(0, -23);
$plot->label->setBackgroundGradient(new LinearGradient(new Color(250, 250, 250, 10), new Color(255, 200, 200, 30), 0));
$plot->label->border->setColor(new Color(20, 20, 20, 20));
$plot->label->setPadding(3, 1, 1, 0);
$graph->add($plot);
$graph->draw();
Exemplo n.º 5
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 "../LinePlot.class.php";
$graph = new Graph(400, 300);
$graph->setAntiAliasing(TRUE);
$x = array(1, 2, 5, 0.5, 3, 8, 7, 6, 2, -4);
$plot = new LinePlot($x);
// Change component padding
$plot->setPadding(10, NULL, NULL, NULL);
// Change component space
$plot->setSpace(5, 5, 5, 5);
// Set a background color
$plot->setBackgroundColor(new Color(230, 230, 230));
// Change grid background color
$plot->grid->setBackgroundColor(new Color(235, 235, 180, 60));
// Hide grid
$plot->grid->hide(TRUE);
// Hide labels on Y axis
$plot->yAxis->label->hide(TRUE);
$plot->xAxis->label->setInterval(2);
$plot->label->set($x);
$plot->label->setFormat('%.1f');
$plot->label->setBackgroundColor(new Color(240, 240, 240, 15));
$plot->label->border->setColor(new Color(255, 0, 0, 15));
$plot->label->setPadding(5, 3, 1, 1);
$plot->xAxis->label->move(0, 5);
$plot->xAxis->label->setBackgroundColor(new Color(240, 240, 240, 15));
$plot->xAxis->label->border->setColor(new Color(0, 150, 0, 15));