本文整理汇总了PHP中GroupBarPlot::SetWidth方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupBarPlot::SetWidth方法的具体用法?PHP GroupBarPlot::SetWidth怎么用?PHP GroupBarPlot::SetWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupBarPlot
的用法示例。
在下文中一共展示了GroupBarPlot::SetWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BarPlot
$graph->xaxis->SetTickLabels($_SESSION[rekmed][statistik_kunjungan_rajal][label_tick]);
$graph->xaxis->SetLabelAngle(50);
$graph->xaxis->title->Set($_SESSION[rekmed][statistik_kunjungan_rajal][label_x]);
$graph->yaxis->title->Set("Jumlah");
//$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,8);
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,8);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$bplot[0] = new BarPlot($_SESSION[rekmed][statistik_kunjungan_rajal][jml_lama]);
$bplot[0]->SetLegend("Lama");
$bplot[0]->SetFillColor("red");
$bplot[0]->value->Show();
$bplot[1] = new BarPlot($_SESSION[rekmed][statistik_kunjungan_rajal][jml_baru]);
$bplot[1]->SetLegend("Baru");
$bplot[1]->SetFillColor("green");
$bplot[1]->value->Show();
$graph->legend->Pos(0.02,0.5,"right","center");
$gbarplot = new GroupBarPlot($bplot);
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>
示例2: run
/**
* Runs the phpOpenTracker API call.
*
* @param array $parameters
* @return mixed
* @access public
*/
function run($parameters)
{
global $lang, $c;
$parameters['result_format'] = 'separate_result_arrays';
// hour or weeday analysis
$apc = "weekdays";
if ($parameters['api_call'] == "nxhours") {
$apc = "hours";
}
$apicall = array('api_call' => $apc, 'what' => $parameters["what"], 'start' => $parameters["start"], 'end' => $parameters["end"]);
$queryValues = phpOpenTracker::get($apicall);
for ($i = 0; $i < count($queryValues); $i++) {
$y[$i] = $queryValues[$i]["value"];
}
$title = 'Analyse ';
switch ($parameters['what']) {
case 'visits':
$title .= 'Visits';
break;
case 'pi':
$title .= 'Page Impressions';
break;
case 'avg_clickstream':
$title .= 'Average Clickstream';
break;
case 'avg_time':
$title .= 'Average Online Time';
break;
}
if ($apc == "hours") {
for ($i = 0; $i < 24; $i++) {
$x_label[$i] = sprintf("%02d", $i);
}
$angle = 50;
} else {
$x_label = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
$angle = 30;
}
$graph = new Graph($parameters['width'], $parameters['height'], 'auto');
$graph->img->SetMargin(40, 10, 20, 50);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
$graph->SetFrame(0);
$graph->xgrid->Show();
$plot[0] = new BarPlot($y);
$plot[0]->SetFillColor(__RED);
$plot[0]->SetShadow();
$plot[0]->SetWeight(0);
$gbarplot = new GroupBarPlot($plot);
$gbarplot->SetWidth(0.6);
$graph->add($gbarplot);
$graph->xaxis->SetTickLabels($x_label);
if ($c["usettf"]) {
$graph->xaxis->SetLabelAngle($angle);
}
if ($c["usettf"]) {
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
if ($c["usettf"]) {
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
$graph->yaxis->SetColor('black');
if ($c["usettf"]) {
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
if ($c["usettf"]) {
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
$graph->title->Set($title);
if ($c["usettf"]) {
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
$graph->img->SetAntiAliasing("white");
$graph->Stroke();
}
示例3: displayGraph
//.........这里部分代码省略.........
imagealphablending($source2, true);
imagecopyresampled($thumb, $source2, 0, 0, 0, 0, 290 * $escala, 294 * $escala, 290, 294);
header("Content-Type: image/png");
imagepng($thumb);
}
}
displayGraph_draw_pie3d($G_SIZE[0], $G_YDATAS[0], $G_ARR_COLOR);
} else {
if ($G_TYPE == 'barplot') {
$graph = new Graph($G_SIZE[0], $G_SIZE[1], "auto");
if ($G_SHADOW) {
$graph->SetShadow();
}
$graph->SetScale($G_SCALE);
$graph->SetMarginColor($G_COLOR);
$graph->img->SetMargin($G_MARGIN[0], $G_MARGIN[1], $G_MARGIN[2], $G_MARGIN[3]);
$graph->title->Set($G_TITLE);
$graph->xaxis->title->Set($G_LABEL[0]);
$graph->xaxis->SetLabelFormatCallback("CallBack");
$graph->xaxis->SetLabelAngle(90);
//$graph->xaxis->SetTickLabels($xData);
$graph->yaxis->title->Set($G_LABEL[1]);
$graph->legend->SetFillColor("#fafafa");
$graph->legend->Pos($G_LEYEND_POS[0], $G_LEYEND_POS[1], "right", "center");
$graph->legend->SetColumns($G_LEYEND_NUM_COLUMN);
$arr_barplot = array();
foreach ($G_YDATAS as $num => $yDatas) {
$barplot = new BarPlot($yDatas);
$barplot->SetFillColor($G_ARR_COLOR[$num]);
$barplot->SetLegend($G_ARR_LEYEND[$num]);
$arr_barplot[] = $barplot;
}
$gbarplot = new GroupBarPlot($arr_barplot);
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
} else {
if ($G_TYPE == 'lineplot_multiaxis') {
$graph = new Graph($G_SIZE[0], $G_SIZE[1], "auto");
if ($G_SHADOW) {
$graph->SetShadow();
}
$inc = sizeof($G_YDATAS);
$graph->SetScale($G_SCALE);
$graph->SetFrame(true, '#999999');
$graph->title->Set($G_TITLE);
$graph->img->SetAntiAliasing();
$graph->xaxis->SetLabelFormatCallback("CallBack");
$graph->img->SetMargin($G_MARGIN[0], $G_MARGIN[1], $G_MARGIN[2], $G_MARGIN[3]);
$graph->SetMarginColor($G_COLOR);
$graph->legend->SetFillColor("#fafafa");
$graph->legend->Pos($G_LEYEND_POS[0], $G_LEYEND_POS[1], "right", "center");
$graph->xaxis->SetLabelAngle(90);
$graph->legend->SetColor("#444444", "#999999");
$graph->legend->SetShadow('gray@0.6', 4);
$graph->legend->SetColumns($G_LEYEND_NUM_COLUMN);
foreach ($G_YDATAS as $num => $yData) {
$lineplot = new LinePlot($yData);
$lineplot->SetWeight($G_WEIGHT);
$lineplot->SetLegend($G_ARR_LEYEND[$num]);
if ($G_ARR_STEP[$num] == true) {
$lineplot->SetStepStyle();
}
if ($G_ARR_FILL_COLOR[$num] == true) {
$lineplot->SetFillColor($G_ARR_COLOR[$num]);
}
示例4: GroupBarPlot
$bplot4->SetLegend('Low');
$bplot5->SetLegend('None');
$bplot6->SetLegend('Duplicate');
$bplot1->value->Show();
$bplot2->value->Show();
$bplot3->value->Show();
$bplot4->value->Show();
$bplot5->value->Show();
$bplot6->value->Show();
$bplot1->value->SetFont(FF_FONT1);
$bplot2->value->SetFont(FF_FONT1);
$bplot3->value->SetFont(FF_FONT1);
$bplot4->value->SetFont(FF_FONT1);
$bplot5->value->SetFont(FF_FONT1);
$bplot6->value->SetFont(FF_FONT1);
$bplot1->value->SetColor("black", "darkred");
$bplot2->value->SetColor("black", "darkred");
$bplot3->value->SetColor("black", "darkred");
$bplot4->value->SetColor("black", "darkred");
$bplot5->value->SetColor("black", "darkred");
$bplot6->value->SetColor("black", "darkred");
$bplot1->value->SetFormat('%d');
$bplot2->value->SetFormat('%d');
$bplot3->value->SetFormat('%d');
$bplot4->value->SetFormat('%d');
$bplot5->value->SetFormat('%d');
$bplot6->value->SetFormat('%d');
$gbarplot = new GroupBarPlot(array($bplot1, $bplot2, $bplot3, $bplot4, $bplot5, $bplot6));
$gbarplot->SetWidth(0.9);
$graph->Add($gbarplot);
$graph->Stroke();
示例5: buildGraphic
function buildGraphic($stats)
{
$stat = $stats->getRequests();
foreach ($stat as $s) {
$mes = intval($s->getMonth());
$ano = intval($s->getYear());
$values[$ano][$mes] = $s->getNumberOfRequests();
}
/*
"gabarito" da linha dos graficos com 12 posicoes, uma para cada mes
os valores "-" sao considerados NULLs pelo jpgraph
*/
$data = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
/*
"gabarito" para as cores das linhas do gráfico
*/
$cores = array("blue", "yellow", "purple", "cyan", "pink", "red", "orange", "green", "black", "sienna", "darkred", "darkgreen");
// Create the graph. These two calls are always required
// $graph = new Graph(700,400,"auto");
$graph = new Graph(900, 300, "auto");
$graph->SetScale("textlin");
/*
cira um array bi-dimencional contendo array(ano{array com a quantidade de acessos por mes})
*/
$colorIndex = 0;
$bars = array();
foreach ($values as $ano => $meses) {
/*
valores será a variavel que servirá de "datasource" para a barra do grafico
inicialmente ele eh inicializada com o gabarito, e serao preenchidos os valores
dos meses no laço for logo abaixo
*/
$valores = $data;
for ($k = 0; $k <= count($valores); $k++) {
if ($meses[$k]) {
$valores[$k] = $meses[$k];
}
}
if (count($valores) > 12) {
unset($valores[0]);
}
$valores = array_values($valores);
/*
aqui eu uso "Variáveis Variáveis" do PHP para poder
inserir vária linhas no gráfico
*/
$nome = "barplot" . $ano;
${$nome} = new BarPlot($valores);
$cor = $cores[$colorIndex];
${$nome}->SetFillColor($cor);
${$nome}->SetColor($cor);
/*configs para os valores do ponto*/
${$nome}->value->SetColor("darkred");
${$nome}->value->SetFont(FF_FONT1, FS_BOLD);
${$nome}->value->SetFormat("%0.1d");
// $$nome->SetWeight(20);
// $$nome->SetWidth(20);
${$nome}->value->Show();
${$nome}->value->iHideZero = true;
${$nome}->setLegend($ano);
/*adicionando a linha ao grafico*/
$colorIndex++;
array_push($bars, ${$nome});
}
$gbplot = new GroupBarPlot($bars);
$gbplot->SetWidth(0.9);
$graph->Add($gbplot);
$graph->yaxis->scale->SetGrace(20);
$graph->img->SetMargin(40, 20, 20, 40);
$graph->title->Set(ARTICLE_ACCESS);
$graph->xaxis->title->Set(MONTHS);
$graph->yaxis->title->Set(ACCESSES);
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->SetShadow();
$graph->xaxis->SetTickLabels(explode(",", MONTH_LIST));
// Adjust the legend position
// $graph->legend->SetLayout(LEGEND_VER);
$graph->legend->Pos(0.04, 0.092, "", "center");
$graph->legend->SetLayout(LEGEND_HOR);
// Display the graph
$graph->Stroke();
}
示例6: Graph
$titulo = 'Algo va';
$m = genMonth_Text($_GET['mes']) . ' de 2014';
if (!empty($datay)) {
require_once '/usr/share/jpgraph/jpgraph.php';
require_once '/usr/share/jpgraph/jpgraph_bar.php';
$graph = new Graph(500, 600, 'auto');
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40, 30, 40, 260);
$graph->yaxis->title->Set($m);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->Set('Horas destinadas a clientes abonados');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetTickLabels($name);
$graph->xaxis->SetTextLabelInterval(1);
$graph->xaxis->SetLabelAngle(90);
$bplot1 = new BarPlot($datay);
$bplot1->SetFillColor("orange");
$bplot1->SetLegend("Realizadas");
$bplot2 = new BarPlot($datax);
$bplot2->SetFillColor("brown");
$bplot2->SetLegend("Asignadas");
$graph->legend->SetShadow('gray@0.4', 5);
$graph->legend->SetPos(0.1, 0.1, 'right', 'top');
$graph->legend->SetColumns(1);
$graph->legend->SetVColMargin(1);
$gbarplot = new GroupBarPlot(array($bplot2, $bplot1));
$gbarplot->SetWidth(0.7);
$graph->Add($gbarplot);
$graph->Stroke();
}
示例7: run
//.........这里部分代码省略.........
$endtitle .= $endyear;
}
$title = $starttitle . ' - ' . $endtitle . ' in ' . $parameters['interval'] . "s.";
$disp = true;
$correct = 0;
if ($parameters['interval'] == 'week') {
$correct = 86400;
}
for ($start = $parameters['start']; $start < $parameters['end']; $start += $steps[$parameters['interval']]) {
if ($parameters['interval'] == 'month') {
$steps['month'] = $steps['day'] * date('t', $_start);
}
$end = $start + $steps[$parameters['interval']] - 1;
if ($start <= $timestamp) {
$apiCallParameters = array('client_id' => $parameters['client_id'], 'start' => $start + $correct, 'end' => $end + $correct, 'constraints' => $parameters['constraints'], 'interval' => '');
for ($j = 0; $j < count($parameters["what"]); $j++) {
$y[$j][] = phpOpenTracker::get(array_merge(array('api_call' => $parameters["what"][$j]), $apiCallParameters));
}
} else {
for ($j = 0; $j < count($parameters["what"]); $j++) {
$y[$j][] = 0;
}
}
switch ($parameters['interval']) {
case 'hour':
$x_label[] = date('H', mktime($hour, 0, 0, $startmonth, $startday, $startyear)) . ':00';
$disp = !$disp;
$hour++;
break;
case 'week':
$x_label[] = date('W', mktime(0, 0, 0, 1, ($week - 2) * 7, $startyear));
$week++;
break;
case 'day':
$x_label[] = date('d', mktime(0, 0, 0, $startmonth, $day, $startyear));
$day++;
break;
case 'month':
$x_label[] = date('m', mktime(0, 0, 0, $month, 1, $startyear));
$month++;
break;
case 'year':
$x_label[] = date('Y', mktime(0, 0, 0, 1, 1, $year));
$year++;
break;
}
}
if ($y == null) {
$apiCallParameters = array('client_id' => $parameters['client_id'], 'start' => $start, 'end' => $end, 'constraints' => $parameters['constraints']);
for ($j = 0; $j < count($parameters["what"]); $j++) {
$y[$j][] = phpOpenTracker::get(array_merge(array('api_call' => $parameters["what"][$j]), $apiCallParameters));
}
$x_label[] = '';
$title = "Total";
}
if ($parameters['interval'] == 'hour') {
$angle = 50;
} else {
$angle = 0;
}
$x_label = $this->clearLabels($x_label, $parameters);
$graph = new Graph($parameters['width'], $parameters['height'], 'auto');
$graph->img->SetMargin(40, 10, 20, 10);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
$graph->SetFrame(0);
$graph->xgrid->Show();
for ($j = 0; $j < count($parameters["what"]); $j++) {
$plot[$j] = new BarPlot($y[$j]);
$plot[$j]->SetFillColor($parameters["whatcolors"][$j]);
$plot[$j]->SetShadow();
$plot[$j]->SetWeight(0);
}
$gbarplot = new GroupBarPlot($plot);
$gbarplot->SetWidth(0.6);
$graph->add($gbarplot);
$graph->xaxis->SetTickLabels($x_label);
if ($c["usettf"]) {
$graph->xaxis->SetLabelAngle($angle);
}
if ($c["usettf"]) {
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
if ($c["usettf"]) {
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
$graph->yaxis->SetColor('black');
if ($c["usettf"]) {
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
if ($c["usettf"]) {
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
$graph->title->Set($title);
if ($c["usettf"]) {
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
$graph->img->SetAntiAliasing("white");
$graph->Stroke();
}
示例8: BarPlot
// Create a bar plot for each day
$plot = new BarPlot(array_values($stats));
$plot->SetFillColor($barColors);
$plots[] = $plot;
$barColorIndex++;
}
// Some graph variables
$datax = array_keys($stats);
$title = sprintf(_("Total page trend over last %s weeks"), $weeks);
//$graph->SetScale("textint");
$graph->SetScale("textlin", 0, max($stats) * 1.05);
$graph->graph_theme = null;
// Set background to white
$graph->SetMarginColor('white');
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
// left, right, top, bottom
$graph->img->SetMargin(50, 20, 30, 30);
// Set title
$graph->title->Set($title);
$graph->title->SetFont($jpgraph_FF, FS_BOLD, 10);
// Set X axis
$graph->xaxis->SetTickLabels($datax);
// Create a bar plot
$plot = new GroupBarPlot($plots);
$plot->SetWidth(0.8);
$graph->Add($plot);
// Display the graph
$graph->Stroke();
// vim: sw=4 ts=4 expandtab
示例9: array
<?php
include "../jpgraph.php";
include "../jpgraph_bar.php";
$data1y = array(12, 8, 19, 3, 10, 5);
$data2y = array(8, 2, 11, 7, 14, 4);
// Create the graph. These two calls are always required
$graph = new Graph(310, 200, "auto");
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40, 30, 20, 40);
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillColor("orange");
$b2plot = new BarPlot($data2y);
$b2plot->SetFillColor("blue");
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot, $b2plot));
$gbplot->SetWidth(0.9);
// ...and add it to the graPH
$graph->Add($gbplot);
$graph->title->Set("Adjusting the width");
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
// Display the graph
$graph->Stroke();
示例10: GroupBarPlot
$bplot2->value->Show();
$bplot3->value->Show();
$bplot4->value->Show();
$bplot5->value->Show();
$bplot6->value->Show();
$bplot7->value->Show();*/
$bplot1->value->SetFont(FF_FONT0);
$bplot2->value->SetFont(FF_FONT0);
$bplot3->value->SetFont(FF_FONT0);
$bplot4->value->SetFont(FF_FONT0);
$bplot5->value->SetFont(FF_FONT0);
$bplot6->value->SetFont(FF_FONT0);
$bplot7->value->SetFont(FF_FONT0);
$bplot1->value->SetColor('black', 'darkred');
$bplot2->value->SetColor('black', 'darkred');
$bplot3->value->SetColor('black', 'darkred');
$bplot4->value->SetColor('black', 'darkred');
$bplot5->value->SetColor('black', 'darkred');
$bplot6->value->SetColor('black', 'darkred');
$bplot7->value->SetColor('black', 'darkred');
$bplot1->value->SetFormat('%d');
$bplot2->value->SetFormat('%d');
$bplot3->value->SetFormat('%d');
$bplot4->value->SetFormat('%d');
$bplot5->value->SetFormat('%d');
$bplot6->value->SetFormat('%d');
$bplot7->value->SetFormat('%d');
$gbarplot = new GroupBarPlot(array($bplot1, $bplot2, $bplot3, $bplot4, $bplot5, $bplot6, $bplot7));
$gbarplot->SetWidth(1.0);
$graph->Add($gbarplot);
$graph->Stroke();
示例11: sprintf
$graph->title->Set("Monthly Rainfall Climatology for " . $cities[strtoupper($station)]['name']);
$subt = sprintf("Annual precip of %.2f inches over %.0f days", array_sum($climate), array_sum($days));
$graph->subtitle->Set($subt);
$graph->title->SetFont(FF_FONT1, FS_BOLD, 16);
$graph->yaxis->SetTitle("Precipitation [inches]");
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->yaxis->SetTitleMargin(35);
$graph->yaxis->title->SetColor("blue");
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->xaxis->SetPos("min");
$graph->xaxis->SetTitleMargin(15);
$graph->legend->Pos(0.2, 0.09);
$graph->legend->SetLayout(LEGEND_HOR);
// Create the linear plot
$bp0 = new BarPlot($climate);
$bp0->SetFillColor("blue");
$bp1 = new BarPlot($days);
$bp1->SetFillColor("red");
$z = new BarPlot($zeros);
$z->SetFillColor("red");
$gbplot = new GroupBarPlot(array($bp0, $z));
$gbplot->SetWidth(0.6);
$graph->Add($gbplot);
$gbplot2 = new GroupBarPlot(array($z, $bp1));
$gbplot2->SetWidth(0.6);
$graph->AddY2($gbplot2);
// Display the graph
$graph->Stroke();
?>
示例12: array
// print_r($_REQUEST['legend']);
$graph->legend->SetPos(0.5, 0.97, 'center', 'bottom');
$graph->legend->SetLayout(10);
$graph->legend->SetFillColor('white');
$graph->legend->SetFont(FF_DV_SANSSERIF, FS_NORMAL, 10);
}
$bars = array();
for ($i = 0; $i < count($data); ++$i) {
$bar = new BarPlot(explode(',', $data[$i]));
$bar->SetFillColor($colors[$i]);
if (isset($_REQUEST['legend'])) {
$bar->SetLegend(explode('|', $_REQUEST['legend'])[$i]);
}
$bars[] = $bar;
}
// Create the grouped bar plot
$gbplot = new GroupBarPlot($bars);
//if (isset($_REQUEST['legend'])) {
// $gbplot->SetLegends(explode('|', $_REQUEST['legend']));
//};
// ...and add it to the graPH
$gbplot->SetWidth(0.6);
$graph->Add($gbplot);
$graph->title->Set($_REQUEST['title']);
$graph->xaxis->title->Set($_REQUEST['x']);
$graph->yaxis->title->Set($_REQUEST['y']);
$graph->title->SetFont(FF_DV_SANSSERIF, FS_BOLD);
$graph->yaxis->title->SetFont(FF_DV_SANSSERIF, FS_BOLD);
$graph->xaxis->title->SetFont(FF_DV_SANSSERIF, FS_BOLD);
// Display the graph
$graph->Stroke();
示例13: buildGraphicByYear
/** Constroi o gráfico entre periodos de anos
retorna true se o grafico foi montado e false se não foi
**/
function buildGraphicByYear($stats, $startYear, $lastYear)
{
$graficoStatus = false;
// Para descobrir se entrou no for e vai construir um gráfico
$stat = $stats->getRequests();
// Pega todos os anos entre o Ano Inicial e o Ano Final
$anos = array();
for ($j = 0, $year = $startYear; $year <= $lastYear; $year++, $j++) {
$anos[$j] = $year;
}
foreach ($stat as $s) {
$mes = intval($s->getMonth());
$ano = intval($s->getYear());
$values[$ano][$mes] = $s->getNumberOfRequests();
}
/*
"gabarito" da linha dos graficos com 12 posicoes, uma para cada mes
os valores "-" sao considerados NULLs pelo jpgraph
*/
$data = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
/*
"gabarito" para as cores das linhas do gráfico
*/
$cores = array("blue", "yellow", "purple", "cyan", "pink", "red", "orange", "green", "black", "sienna", "darkred", "darkgreen");
// Create the graph. These two calls are always required
// $graph = new Graph(700,400,"auto");
$graph = new Graph(900, 300, "auto");
$graph->SetScale("textlin");
/*
cria um array bi-dimencional contendo array(ano{array com a quantidade de acessos por mes})
*/
$colorIndex = 0;
$bars = array();
foreach ($values as $ano => $meses) {
/*
valores será a variavel que servirá de "datasource" para a barra do grafico
inicialmente ele eh inicializada com o gabarito, e serao preenchidos os valores
dos meses no laço for logo abaixo
*/
$valores = $data;
for ($k = 0; $k <= count($valores); $k++) {
if ($meses[$k]) {
$valores[$k] = $meses[$k];
}
}
if (count($valores) > 12) {
unset($valores[0]);
}
$valores = array_values($valores);
/*
aqui eu uso "Variáveis Variáveis" do PHP para poder
inserir vária linhas no gráfico
*/
$nome = "barplot" . $ano;
${$nome} = new BarPlot($valores);
$cor = $cores[$colorIndex];
${$nome}->SetFillColor($cor);
${$nome}->SetColor($cor);
/*configs para os valores do ponto*/
${$nome}->value->SetColor("darkred");
${$nome}->value->SetFont(FF_FONT1, FS_BOLD);
${$nome}->value->SetFormat("%0.1d");
// $$nome->SetWeight(20);
// Arrumando para um tamanho mais amigavel
if (count($anos) < 3) {
${$nome}->SetWidth(20);
} else {
if (count($anos) < 4) {
${$nome}->SetWidth(15);
} else {
if (count($anos) < 6) {
${$nome}->SetWidth(10);
} else {
if (count($anos) < 8) {
${$nome}->SetWidth(5);
} else {
if (count($anos) < 11) {
${$nome}->SetWidth(3);
}
}
}
}
}
${$nome}->value->Show();
${$nome}->value->iHideZero = true;
${$nome}->setLegend($ano);
/*adicionando a linha ao grafico*/
$colorIndex++;
// Somente monta o gráfico dos anos exigidos pelo usuário
for ($i = 0; $i < count($anos); $i++) {
if ($ano == $startYear + $i) {
$graficoStatus = true;
// entrou no for significa que o gráfico vai ser construido
array_push($bars, ${$nome});
}
}
}
//.........这里部分代码省略.........
示例14: array
$datamean = array(32, 132, 80, 9, 70, 330, 60);
} else {
$datamean = array(28, 135, 82, 12, 115, 380, 30);
}
}
//Create the graph. These two calls are always required
$graph = new Graph(500, 400);
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40, 30, 20, 40);
// Create the bar plots
$b1plot = new BarPlot($datamem);
$b1plot->SetFillColor("orange");
$b2plot = new BarPlot($datamean);
$b2plot->SetFillColor("blue");
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot, $b2plot));
$gbplot->SetWidth(0.7);
// ...and add it to the graPH
$graph->Add($gbplot);
$graph->title->Set("Physical State Graph");
$graph->xaxis->title->Set("Item");
$graph->yaxis->title->Set("Data");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
// Display the graph
$graph->Stroke();
?>
示例15: array
$graph->yaxis->title->Set('(%)');
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->ygrid->SetColor('black');
$graph->yaxis->SetTitleMargin(45);
$graph->yaxis->scale->SetGrace(30);
// TITRE: texte
$graph->title->Set("Pass and Fail rate");
// TITRE: marge et apparence
$graph->title->SetFont(FF_FONT1, FS_BOLD, 10);
// Couleurs et transparence par histogramme
$aColors = array('pink', 'teal', 'navy', 'lightblue', 'red', 'green');
$i = 0;
$aGroupBarPlot = array();
foreach ($data1 as $key => $value) {
$bplot = new BarPlot($data1[$key]);
$bplot->SetFillColor($aColors[$i++]);
$bplot->value->Show();
$bplot->value->SetFormat('%01.2f');
$bplot->value->SetColor("black", "darkred");
$bplot->SetLegend($key);
$bplot->SetShadow('black');
$bplot->SetWidth(0.2);
$aGroupBarPlot[] = $bplot;
}
// Création de l'objet qui regroupe nos histogrammes
$gbarplot = new GroupBarPlot($aGroupBarPlot);
$gbarplot->SetWidth(0.5);
// Ajouter au graphique
$graph->Add($gbarplot);
// Afficher
$graph->Stroke();