Ejemplo n.º 1
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$datay1 = array(20, 7, 16, 46);
$datay2 = array(6, 20, 10, 22);
// Setup the graph
$graph = new Graph\Graph(350, 230);
$graph->SetScale("textlin");
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
$graph->title->Set('Background Image');
$graph->SetBox(false);
$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D'));
$graph->ygrid->SetFill(false);
$graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME);
$p1 = new Plot\LinePlot($datay1);
$graph->Add($p1);
$p2 = new Plot\LinePlot($datay2);
$graph->Add($p2);
$p1->SetColor("#55bbdd");
$p1->SetLegend('Line 1');
$p1->mark->SetType(MARK_FILLEDCIRCLE, '', 1.0);
$p1->mark->SetColor('#55bbdd');
$p1->mark->SetFillColor('#55bbdd');
$p1->SetCenter();
$p2->SetColor("#aaaaaa");
Ejemplo n.º 2
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
require_once 'jpgraph/jpgraph_line.php';
$theme = isset($_GET['theme']) ? $_GET['theme'] : null;
$data = array(0 => array(0 => 79, 1 => -25, 2 => -7, 3 => 85, 4 => -26, 5 => -32), 1 => array(0 => 76, 1 => 51, 2 => 86, 3 => 12, 4 => -7, 5 => 94), 2 => array(0 => 49, 1 => 38, 2 => 7, 3 => -40, 4 => 9, 5 => -7), 3 => array(0 => 69, 1 => 96, 2 => 49, 3 => 7, 4 => 92, 5 => -38), 4 => array(0 => 68, 1 => 16, 2 => 82, 3 => -49, 4 => 50, 5 => 7), 5 => array(0 => -37, 1 => 28, 2 => 32, 3 => 6, 4 => 13, 5 => 57), 6 => array(0 => 24, 1 => -11, 2 => 7, 3 => 10, 4 => 51, 5 => 51), 7 => array(0 => 3, 1 => -1, 2 => -12, 3 => 61, 4 => 10, 5 => 47), 8 => array(0 => -47, 1 => -21, 2 => 43, 3 => 53, 4 => 36, 5 => 34));
// Create the graph. These two calls are always required
$graph = new Graph\Graph(400, 300);
$graph->SetScale("textlin");
if ($theme) {
    $graph->SetTheme(new $theme());
}
$theme_class = new VividTheme();
$graph->SetTheme($theme_class);
$plot = array();
// Create the bar plots
for ($i = 0; $i < 4; $i++) {
    $plot[$i] = new Plot\BarPlot($data[$i]);
    $plot[$i]->SetLegend('plot' . ($i + 1));
}
//$acc1 = new Plot\AccBarPlot(array($plot[0], $plot[1]));
//$acc1->value->Show();
$gbplot = new Plot\GroupBarPlot(array($plot[2], $plot[1]));
for ($i = 4; $i < 8; $i++) {
    $plot[$i] = new Plot\LinePlot($data[$i]);
    $plot[$i]->SetLegend('plot' . $i);
    $plot[$i]->value->Show();
}
$graph->Add($gbplot);
$graph->Add($plot[4]);