public function testChma()
 {
     $this->assertEquals($this->chart->computeChma(), '');
     $this->assertEquals($this->chart->hasChma(), false);
     $this->chart->setLegendSize(500, 300);
     $this->assertEquals($this->chart->computeChma(), '|500,300');
 }
Example #2
0
$chart = new GoogleChart('lc', 180, 150);
$data = new GoogleChartData(array(10, 15, 25, 30, 45, 55, 58));
$data->setLegend('Foobar');
$chart->addData($data);
// no legend for this data serie
$data = new GoogleChartData(array(5, 12, 28, 26, 30, 34, 32));
$data->setColor('FF0000');
$chart->addData($data);
echo $chart->toHtml();
$chart = new GoogleChart('lc', 180, 150);
$chart->setLegendPosition('b');
$data = new GoogleChartData(array(10, 15, 25, 30, 45, 55, 58));
$data->setLegend('Foo');
$chart->addData($data);
$data = new GoogleChartData(array(5, 12, 28, 26, 30, 34, 32));
$data->setLegend('Bar');
$data->setColor('FF0000');
$chart->addData($data);
echo $chart->toHtml();
$chart = new GoogleChart('lc', 180, 150);
$chart->setLegendPosition('t');
$chart->setLegendSize(18);
$chart->setLegendColor('336699');
$data = new GoogleChartData(array(10, 15, 25, 30, 45, 55, 58));
$data->setLegend('Foo');
$chart->addData($data);
$data = new GoogleChartData(array(5, 12, 28, 26, 30, 34, 32));
$data->setLegend('Bar');
$data->setColor('FF0000');
$chart->addData($data);
echo $chart->toHtml();
require '../lib/GoogleChart.php';
require '../lib/markers/GoogleChartTextMarker.php';
require '../lib/markers/GoogleChartShapeMarker.php';
$values = array(array(), array(), array());
$n = 10;
for ($i = 0; $i <= $n; $i += 1) {
    $v = rand($i, $i * 10);
    $values[0][] = $v;
    $values[1][] = $v - $i;
    $values[2][] = rand(100 - ($i + 10), 100 - 10 * $i);
}
$chart = new GoogleChart('lc', 600, 300);
$chart->setGridLines(10, 10);
$chart->setLegendPosition('r');
//~ $chart->setMargin(50);
$chart->setLegendSize(150, 20);
$chart->setFill('ffffcc');
$chart->setGradientFill(45, array('cccccc', 'ffffff', 'cccccc'), GoogleChart::CHART_AREA);
$chart->setTitle('Us versus the others.');
$chart->setTitleColor('999999')->setTitleSize(20);
$line = new GoogleChartData($values[0]);
$line->setLegend('Us');
$chart->addData($line);
$marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::X);
$marker->setData($line);
$marker->setColor('6699cc');
$chart->addMarker($marker);
$marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
$marker->setData($line);
$chart->addMarker($marker);
$line = new GoogleChartData($values[1]);
<?php

require '../lib/GoogleChart.php';
$sin = array();
$cos = array();
for ($i = 0; $i <= 360; $i += 10) {
    $sin[] = round(sin($i * M_PI / 180), 2);
    $cos[] = round(cos($i * M_PI / 180), 2);
}
$chart = new GoogleChart('lc', 500, 200);
$chart->setGridLines(25, 50, 1, 1);
$chart->setMargin(30, 50);
$chart->setLegendSize(100, 10);
$chart->setFill('333333');
$chart->setFill('444444', GoogleChart::CHART_AREA);
$chart->setTitle('Sinus & Cosinus');
$chart->setTitleColor('FFFFFF');
$chart->setTitleSize(18);
$sin = new GoogleChartData($sin);
$sin->setLegend('Sinus');
$sin->setThickness(2);
$sin->setColor('D1F2A5');
$chart->addData($sin);
$cos = new GoogleChartData($cos);
$cos->setLegend('Cosinus');
$cos->setThickness(2);
$cos->setColor('F56991');
$chart->addData($cos);
$y_axis = new GoogleChartAxis('y');
$y_axis->setDrawLine(false);
$y_axis->setRange(-1, 1);
Example #5
0
function sin_cos()
{
    $sin = array();
    $cos = array();
    for ($i = 0; $i <= 360; $i += 10) {
        $sin[] = round(sin($i * M_PI / 180), 2);
        $cos[] = round(cos($i * M_PI / 180), 2);
    }
    $chart = new GoogleChart('lc', 500, 200);
    $chart->setGridLines(25, 50, 1, 1);
    $chart->setMargin(30, 50);
    $chart->setLegendSize(100, 10);
    $chart->setFill('333333');
    $chart->setFill('444444', GoogleChart::CHART_AREA);
    $chart->setTitle('Sinus & Cosinus');
    $chart->setTitleColor('FFFFFF');
    $chart->setTitleSize(18);
    $sin = new GoogleChartData($sin);
    $sin->setLegend('Sinus');
    $sin->setThickness(2);
    $sin->setColor('D1F2A5');
    $chart->addData($sin);
    $cos = new GoogleChartData($cos);
    $cos->setLegend('Cosinus');
    $cos->setThickness(2);
    $cos->setColor('F56991');
    $chart->addData($cos);
    $y_axis = new GoogleChartAxis('y');
    $y_axis->setDrawLine(false);
    $y_axis->setRange(-1, 1);
    $y_axis->setLabelColor('ffffff');
    $chart->addAxis($y_axis);
    $x_axis = new GoogleChartAxis('x');
    $x_axis->setDrawLine(false);
    $x_axis->setRange(0, 360);
    $x_axis->setLabels(array(0, 90, 180, 270, 360));
    $x_axis->setLabelColor('ffffff');
    $chart->addAxis($x_axis);
    return $chart->getUrl();
}