本文整理汇总了PHP中Chart::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP Chart::Add方法的具体用法?PHP Chart::Add怎么用?PHP Chart::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart::Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildGraph
/**
* @return Chart
*/
public function buildGraph()
{
$graph = new Chart($this->width, $this->height);
$graph->SetScale("datlin");
$graph->title->Set($this->title);
$graph->subtitle->Set($this->description);
$colors = $graph->getThemedColors();
$graph->xaxis->SetTickLabels($this->burndown_data->getHumanReadableDates());
$remaining_effort = new LinePlot($this->burndown_data->getRemainingEffort());
$remaining_effort->SetColor($colors[1] . ':0.7');
$remaining_effort->SetWeight(2);
$remaining_effort->SetLegend('Remaining effort');
$remaining_effort->mark->SetType(MARK_FILLEDCIRCLE);
$remaining_effort->mark->SetColor($colors[1] . ':0.7');
$remaining_effort->mark->SetFillColor($colors[1]);
$remaining_effort->mark->SetSize(3);
$graph->Add($remaining_effort);
$ideal_burndown = new LinePlot($this->burndown_data->getIdealEffort());
$ideal_burndown->SetColor($colors[0] . ':1.25');
$ideal_burndown->SetLegend('Ideal Burndown');
$graph->Add($ideal_burndown);
return $graph;
}
示例2: displayAccumulatedGraph
/**
* Create a JpGraph accumulated barPlot chart
*
* @param Array $bplot Array of JpGraph barPlot objects
* @param Chart $graph The output graph that will contains accumulated barPlots
*
* @return Void
*/
private function displayAccumulatedGraph($bplot, $graph)
{
$abplot = new AccBarPlot($bplot);
$abplot->SetAbsWidth(10);
$graph->Add($abplot);
$graph->Stroke();
}
示例3: displayProjectTotalSizeGraph
/**
*
* @param Integer $groupId
* @param String $groupBy
* @param Date $startDate
* @param Date $endDate
* @param Boolean $absolute Is y-axis relative to data set or absolute (starting from 0)
*/
function displayProjectTotalSizeGraph($groupId, $groupBy, $startDate, $endDate, $absolute = true)
{
$graph = new Chart(420, 340, "auto");
$graph->img->SetMargin(70, 50, 30, 70);
$graph->SetScale("textlin");
$graph->title->Set("Total project size growth over the time");
$graph->yaxis->title->Set("Size");
$graph->yaxis->SetTitleMargin(60);
$graph->yaxis->setLabelFormatCallback(array($this, 'sizeReadable'));
if ($absolute) {
$graph->yaxis->scale->SetAutoMin(0);
}
$data = $this->_dum->getWeeklyEvolutionProjectTotalSize($groupId, $groupBy, $startDate, $endDate);
if (is_array($data) && count($data) > 1) {
$dates = array();
$ydata = array();
foreach ($data as $xdate => $values) {
$dates[] = $xdate;
$ydata[] = (double) $values;
}
$lineplot = new LinePlot($ydata);
$color = '#6BA132';
$lineplot->SetColor($color);
$lineplot->SetFillColor($color . ':1.5');
$lineplot->value->SetFont($graph->getFont(), FS_NORMAL, 8);
$lineplot->value->setFormatCallback(array($this, 'sizeReadable'));
$graph->Add($lineplot);
$graph->xaxis->title->Set("Weeks");
$graph->xaxis->SetTitleMargin(35);
$graph->xaxis->SetTickLabels($dates);
$graph->Stroke();
} else {
$this->displayError($GLOBALS['Language']->getText('plugin_statistics', 'no_data_error'));
}
}
示例4: process
function process($owner_type, $owner_id)
{
$dao = new SvnCommitsDao(CodendiDataAccess::instance());
//The default duration is 3 months back
$nb_weeks = 4 * 3;
$duration = 7 * $nb_weeks;
$day = 24 * 3600;
$week = 7 * $day;
//compute the stats
$stats = array();
$nb_of_commits = array();
foreach ($dao->statsByGroupId($owner_id, $duration) as $row) {
$stats[$row['whoid']]['by_day'][$row['day'] * $day] = $row['nb_commits'];
$stats[$row['whoid']]['by_week'][$row['week']] = $row['nb_commits'];
$this->tmp_nb_of_commit[$row['whoid']] = (isset($this->tmp_nb_of_commit[$row['whoid']]) ? $this->tmp_nb_of_commit[$row['whoid']] : 0) + $row['nb_commits'];
}
if (count($stats)) {
//sort the results
uksort($stats, array($this, 'sortByTop'));
$today = $_SERVER['REQUEST_TIME'];
$start_of_period = strtotime("-{$nb_weeks} weeks");
//fill-in the holes
$tmp_stats = array();
foreach ($stats as $whoid => $stat) {
$tmp_stats = array();
for ($i = $start_of_period; $i <= $today; $i += $week) {
$w = (int) date('W', $i);
$tmp_stats[$w] = isset($stat['by_week'][$w]) ? $stat['by_week'][$w] : '0';
}
$stats[$whoid]['by_week'] = $tmp_stats;
}
//fill-in the labels
$dates = array();
for ($i = $start_of_period; $i <= $today; $i += $week) {
$dates[] = date('M d', $i);
}
$nb_commiters = count($stats);
$widgetFormatter = new Widget_ProjectSvnStats_Layout($nb_commiters);
$legendRatio = $widgetFormatter->legend_ratio;
$chartWidth = $widgetFormatter->getChartWidth();
$chartHeigh = $widgetFormatter->getChartHeigh();
$legend_x_position = $widgetFormatter->getLegendXPosition();
$legend_y_position = $widgetFormatter->getLegendYPosition();
$imgBottomMargin = $widgetFormatter->getImageBottomMargin();
$legendAlign = $widgetFormatter->getLegendAlign();
// @TODO: Centralize stuff at Chart class level to properly render a Jpgraph chart with a large number of legend items
//Build the chart
$c = new Chart($chartWidth, $chartHeigh);
$c->SetScale('textlin');
$c->img->SetMargin(40, 20, 20, $imgBottomMargin);
$c->xaxis->SetTickLabels($dates);
$c->legend->Pos($legend_x_position, $legend_y_position, 'left', $legendAlign);
if ($legendRatio >= 1) {
$c->legend->setColumns(2);
}
$colors = array_reverse(array_slice($GLOBALS['HTML']->getChartColors(), 0, $nb_commiters));
$nb_colors = count($colors);
$bars = array();
$i = 0;
foreach ($stats as $whoid => $stat) {
$l = new BarPlot(array_values($stat['by_week']));
$color = $colors[$i++ % $nb_colors];
$l->SetColor($color . ':0.7');
$l->setFillColor($color);
if ($user = UserManager::instance()->getUserById($whoid)) {
$l->SetLegend(UserHelper::instance()->getDisplayNameFromUser($user));
} else {
$l->SetLegend('Unknown user (' . (int) $whoid . ')');
}
$bars[] = $l;
}
$gbplot = new AccBarPlot($bars);
$c->Add($gbplot);
} else {
$error = "No commits in the last {$duration} days";
$c = new ErrorChart("No logged commits", $error, 400, 300);
}
echo $c->stroke();
}