示例#1
0
 public function copyChart($src)
 {
     $chart = new Chart();
     // new id
     $chart->setId($this->getUnusedRandomId());
     // but the rest remains the same
     $chart->setUser($src->getUser());
     $chart->setTitle($src->getTitle() . ' (' . __('Copy') . ')');
     $chart->setMetadata(json_encode($src->getMetadata()));
     $chart->setTheme($src->getTheme());
     $chart->setLocale($src->getLocale());
     $chart->setType($src->getType());
     $chart->setCreatedAt(time());
     $chart->setLastModifiedAt(time());
     $chart->setLastEditStep(3);
     // we need to copy the data, too
     $chart->writeData($src->loadData());
     $chart->save();
     return $chart;
 }
示例#2
0
$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 Chart('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'), Chart::CHART_AREA);
$chart->setTitle('Us versus the others.');
$chart->setTitleColor('999999')->setTitleSize(20);
$line = new ChartData($values[0]);
$line->setLegend('Us');
$chart->addData($line);
$marker = new ChartShapeMarker(ChartShapeMarker::X);
$marker->setData($line);
$marker->setColor('6699cc');
$chart->addMarker($marker);
$marker = new ChartTextMarker(ChartTextMarker::VALUE);
$marker->setData($line);
$chart->addMarker($marker);
$line = new ChartData($values[1]);
$line->setDash(2, 2);
$line->setColor('6699cc');
$chart->addData($line);
<?php

require '../lib/Chart.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 Chart('lc', 500, 200);
$chart->setGridLines(25, 50, 1, 1);
$chart->setMargin(30, 50);
$chart->setLegendSize(100, 10);
$chart->setFill('333333');
$chart->setFill('444444', Chart::CHART_AREA);
$chart->setTitle('Sinus & Cosinus');
$chart->setTitleColor('FFFFFF');
$chart->setTitleSize(18);
$sin = new ChartData($sin);
$sin->setLegend('Sinus');
$sin->setThickness(2);
$sin->setColor('D1F2A5');
$chart->addData($sin);
$cos = new ChartData($cos);
$cos->setLegend('Cosinus');
$cos->setThickness(2);
$cos->setColor('F56991');
$chart->addData($cos);
$y_axis = new ChartAxis('y');
$y_axis->setDrawLine(false);
$y_axis->setRange(-1, 1);