/**
  * Labels are in sync
  */
 public function testChl()
 {
     $values = array('Success' => 20, 'Failure' => 75, 'Unknow' => 5);
     $chart = new GooglePieChart('pc', 500, 200);
     $chart->addData(new GoogleChartData(array(10, 20, 30)));
     $data = new GoogleChartData(array(50, 50));
     $chart->addData($data);
     $q = $chart->getQuery();
     $this->assertFalse(isset($q['chl']));
     $data->setLabels(array('Foo', 'Bar'));
     $q = $chart->getQuery();
     $this->assertTrue(isset($q['chl']));
     $this->assertEquals($q['chl'], '|||Foo|Bar');
     $chart->addData(new GoogleChartData(array(10, 20, 30)));
     $q = $chart->getQuery();
     $this->assertTrue(isset($q['chl']));
     $this->assertEquals($q['chl'], '|||Foo|Bar');
 }
Esempio n. 2
0
<?php

require '../lib/GooglePieChart.php';
$chart = new GooglePieChart('p', 130, 100);
$chart->setDataFormat(GoogleChart::SIMPLE_ENCODING);
$data = new GoogleChartData(array(80, -20));
$data->setColor('f9f900');
$chart->addData($data);
// I pass null to enable the "legend" trick
$data = new GoogleChartData(null);
$data->setColor('ffffff');
$data->setLegend('O O O');
$chart->addData($data);
$chart->setLegendPosition('r');
$chart->setRotation(0.628);
if (isset($_GET['debug'])) {
    var_dump($chart->getQuery());
    echo $chart->validate();
    echo $chart->toHtml();
} else {
    header('Content-Type: image/png');
    echo $chart;
}
Esempio n. 3
0
<?php

require '../lib/GooglePieChart.php';
$values = array('Success' => 20, 'Failure' => 75, 'Unknow' => 5);
//~ $chart = new GooglePieChart('pc', 500, 200);
//~ $data = new GoogleChartData($values);
//~ $data->setLabelsAuto();
//~ $data->setLegend('Foo');
//~ $chart->addData($data);
//~ $data = new GoogleChartData(array(50,50));
//~ $data->setLabels(array('Foo','Bar'));
//~ $data->setLegend('Foo');
//~ $chart->addData($data);
$chart = new GooglePieChart('pc', 500, 200);
$chart->addData(new GoogleChartData(array(10, 20, 30)));
$data = new GoogleChartData(array(50, 50));
$chart->addData($data);
$chart->setQueryMethod(GoogleChartApi::GET);
$data->setLabels(array('Foo', 'Bar'));
if (isset($_GET['debug'])) {
    var_dump($chart->getQuery());
    echo $chart->validate();
    echo $chart->toHtml();
} else {
    header('Content-Type: image/png');
    echo $chart;
}
 public function testPieChart()
 {
     $chart = GooglePieChart::create()->setSize(GoogleChartSize::create()->setWidth(500)->setHeight(300))->addPiece(GoogleChartPiece::create()->setTitle('Nokia')->setColor(Color::create('ff0000'))->setValue(40))->addPiece(GoogleChartPiece::create()->setTitle('Samsung')->setColor(Color::create('336677'))->setValue(35))->addPiece(GoogleChartPiece::create()->setTitle('Opera')->setColor(Color::create('112200'))->setValue(25));
     $this->assertEquals($chart->toString(), 'http://chart.apis.google.com/chart?cht=p&chs=500x300&chco=FF0000,336677,112200&chd=t:40,35,25&chl=Nokia|Samsung|Opera');
 }
Esempio n. 5
0
function pacman()
{
    $chart = new GooglePieChart('p', 130, 100);
    $data = new GoogleChartData(array(80, -20));
    $data->setColor('f9f900');
    $chart->addData($data);
    $chart->setFill('73A2BD');
    // I pass null to enable the "legend" trick
    $data = new GoogleChartData(null);
    $data->setColor('73A2BD');
    $data->setLegend('O O O');
    $chart->addData($data);
    $chart->setLegendPosition('r');
    $chart->setRotation(0.628);
    return $chart->getUrl();
}