当前位置: 首页>>代码示例>>PHP>>正文


PHP Graph::Add方法代码示例

本文整理汇总了PHP中Amenadiel\JpGraph\Graph\Graph::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP Graph::Add方法的具体用法?PHP Graph::Add怎么用?PHP Graph::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Amenadiel\JpGraph\Graph\Graph的用法示例。


在下文中一共展示了Graph::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: LinearRegression

$lr = new LinearRegression($datax, $datay);
list($stderr, $corr) = $lr->GetStat();
list($xd, $yd) = $lr->GetY(0, 19);
// Create the graph
$graph = new Graph\Graph(300, 250);
$graph->SetScale('linlin');
// Setup title
$graph->title->Set("Linear regression");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph->subtitle->Set('(stderr=' . sprintf('%.2f', $stderr) . ', corr=' . sprintf('%.2f', $corr) . ')');
$graph->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 12);
// make sure that the X-axis is always at the
// bottom at the plot and not just at Y=0 which is
// the default position
$graph->xaxis->SetPos('min');
// Create the scatter plot with some nice colors
$sp1 = new ScatterPlot($datay, $datax);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
$sp1->mark->SetFillColor("red");
$sp1->SetColor("blue");
$sp1->SetWeight(3);
$sp1->mark->SetWidth(4);
// Create the regression line
$lplot = new Plot\LinePlot($yd);
$lplot->SetWeight(2);
$lplot->SetColor('navy');
// Add the pltos to the line
$graph->Add($sp1);
$graph->Add($lplot);
// ... and stroke
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:example16.6.php

示例2: array

use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
$y2data = array(354, 200, 265, 99, 111, 91, 198, 225, 293, 251);
// Create the graph and specify the scale for both Y-axis
$graph = new Graph\Graph(400, 200);
$graph->SetScale('textlin');
$graph->SetY2Scale('lin');
$graph->SetShadow();
// Adjust the margin
$graph->img->SetMargin(40, 140, 20, 40);
// Create the two linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot2 = new Plot\LinePlot($y2data);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->AddY2($lineplot2);
$lineplot2->SetColor('orange');
$lineplot2->SetWeight(2);
// Adjust the axis color
$graph->y2axis->SetColor('orange');
$graph->yaxis->SetColor('blue');
$graph->title->Set('Example 6');
$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);
// Set the colors for the plots
$lineplot->SetColor('blue');
$lineplot->SetWeight(2);
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:example6.php

示例3: rand

<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some data
for ($i = 0; $i < 12; ++$i) {
    $databary[$i] = rand(1, 20);
}
$months = $gDateLocale->GetShortMonth();
// new Graph\Graph with a drop shadow
$graph = new Graph\Graph(300, 200);
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale('textlin');
// Specify X-labels
$graph->xaxis->SetTickLabels($months);
$graph->xaxis->SetTextTickInterval(2, 0);
// Set title and subtitle
$graph->title->Set('Textscale with tickinterval=2');
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Create the bar plot
$b1 = new Plot\BarPlot($databary);
$b1->SetLegend('Temperature');
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the  image
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:30,代码来源:manual_textscale_ex2.php

示例4: array

<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay1 = array(13, 8, 19, 7, 17, 6);
$datay2 = array(4, 5, 2, 7, 5, 25);
// Create the graph.
$graph = new Graph\Graph(350, 250);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
// Setup title
$graph->title->Set('Acc bar with gradient');
// Create the first bar
$bplot = new Plot\BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2', 'AntiqueWhite4:0.8', GRAD_VERT);
$bplot->SetColor('darkred');
// Create the second bar
$bplot2 = new Plot\BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1', 'olivedrab4', GRAD_VERT);
$bplot2->SetColor('darkgreen');
// And join them in an accumulated bar
$accbplot = new Plot\AccBarPlot(array($bplot, $bplot2));
$graph->Add($accbplot);
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:26,代码来源:accbarframeex01.php

示例5: array

// Create the graph. These two calls are always required
$graph = new Graph\Graph(310, 200, 'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 30, 20, 40);
$graph->SetShadow();
// Create the bar plots
$b1plot = new Plot\BarPlot($data1y);
$b1plot->SetFillColor("orange");
$targ = array("bar_clsmex2.php#1", "bar_clsmex2.php#2", "bar_clsmex2.php#3", "bar_clsmex2.php#4", "bar_clsmex2.php#5", "bar_clsmex2.php#6");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$b1plot->SetCSIMTargets($targ, $alts);
$b2plot = new Plot\BarPlot($data2y);
$b2plot->SetFillColor("blue");
$targ = array("bar_clsmex2.php#7", "bar_clsmex2.php#8", "bar_clsmex2.php#9", "bar_clsmex2.php#10", "bar_clsmex2.php#11", "bar_clsmex2.php#12");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$b2plot->SetCSIMTargets($targ, $alts);
// Create the grouped bar plot
$abplot = new Plot\AccBarPlot(array($b1plot, $b2plot));
$abplot->SetShadow();
$abplot->value->Show();
// ...and add it to the graPH
$graph->Add($abplot);
$graph->title->Set("Image map barex2");
$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);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:bar_csimex2.php

示例6: array

require_once '../../vendor/autoload.php';
require_once 'jpgraph/jpgraph_line.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$ydata = array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
$ydata2 = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$targ = array("#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8", "#9", "#10");
$alt = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
// Create the graph.
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 20, 30, 40);
$graph->title->Set("CSIM example with bar and line");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Setup axis titles
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->SetWidth(5);
$lineplot->mark->SetColor('black');
$lineplot->mark->SetFillColor('red');
$lineplot->SetCSIMTargets($targ, $alt);
// Create line plot
$barplot = new Plot\BarPlot($ydata2);
$barplot->SetCSIMTargets($targ, $alt);
// Add the plots to the graph
$graph->Add($lineplot);
$graph->Add($barplot);
$graph->StrokeCSIM();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:barline_csimex1.php

示例7:

$graph->SetColor(array(250, 250, 250));
$graph->img->SetTransparent("white");
$t1 = new Text\Text("This is a text");
$t1->SetPos(0.5, 0.5);
$t1->SetOrientation("h");
$t1->SetFont(FF_FONT1, FS_BOLD);
$t1->SetBox("white", "black", "gray");
$t1->SetColor("black");
$graph->AddText($t1);
// Create the linear error plot
$l1plot = new Plot\LinePlot($l1datay);
$l1plot->SetColor("blue");
$l1plot->SetWeight(2);
$l1plot->SetLegend("Prediction");
// Create the bar plot
$l2plot = new Plot\BarPlot($l2datay);
$l2plot->SetFillColor("orange");
$l2plot->SetLegend("Result");
// Add the plots to the graph
$graph->Add($l1plot);
$graph->Add($l2plot);
$graph->title->Set("Example 16.3");
$graph->xaxis->title->Set("Month");
$graph->yaxis->title->Set("x10,000 US\$");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetTickLabels($datax);
//$graph->xaxis->SetTextTickInterval(2);
// Display the graph
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:example16.5.php

示例8: array

$data1y = array(47, 80, 40, 116);
$data2y = array(61, 30, 82, 105);
$data3y = array(115, 50, 70, 93);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(350, 200, 'auto');
$graph->SetScale("textlin");
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
$graph->yaxis->SetTickPositions(array(0, 30, 60, 90, 120, 150), array(15, 45, 75, 105, 135));
$graph->SetBox(false);
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
// Create the bar plots
$b1plot = new Plot\BarPlot($data1y);
$b2plot = new Plot\BarPlot($data2y);
$b3plot = new Plot\BarPlot($data3y);
// Create the grouped bar plot
$gbplot = new Plot\GroupBarPlot(array($b1plot, $b2plot, $b3plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$b1plot->SetColor("white");
$b1plot->SetFillColor("#cc1111");
$b2plot->SetColor("white");
$b2plot->SetFillColor("#11cccc");
$b3plot->SetColor("white");
$b3plot->SetFillColor("#1111cc");
$graph->title->Set("Bar Plots");
// Display the graph
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:new_bar1.php

示例9: array

$graph->SetScale("textlin");
if ($theme) {
    $graph->SetTheme(new $theme());
}
$theme_class = new Themes\AquaTheme();
$graph->SetTheme($theme_class);
$plot = array();
// Create the bar plots
for ($i = 0; $i < 4; $i++) {
    $plot[$i] = new Plot\BarPlot($data[$i]);
    $plot[$i]->SetLegend('plot' . ($i + 1));
}
//$acc1 = new Plot\AccBarPlot(array($plot[0], $plot[1]));
//$acc1->value->Show();
Kint::enabled(true);
ddd($plot);
$gbplot = new Plot\GroupBarPlot(array($plot[2], $plot[1]));
for ($i = 4; $i < 8; $i++) {
    $plot[$i] = new Plot\LinePlot($data[$i]);
    $plot[$i]->SetLegend('plot' . $i);
    $plot[$i]->value->Show();
}
$graph->Add($gbplot);
$graph->Add($plot[4]);
$title = "AquaTheme Example";
$title = mb_convert_encoding($title, 'UTF-8');
$graph->title->Set($title);
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
// Display the graph
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:aqua_example.php

示例10: Text

$graph->xaxis->SetLabelMargin(10);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right', 'center');
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
$graph->yaxis->scale->SetGrace(20);
// We don't want to display Y-axis
$graph->yaxis->Hide();
// Now create a bar pot
$bplot = new Plot\BarPlot($datay);
$bplot->SetShadow();
//You can change the width of the bars if you like
//$bplot->SetWidth(0.5);
// Set gradient fill for bars
$bplot->SetFillGradient('darkred', 'yellow', GRAD_HOR);
// We want to display the value of each bar at the top
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL, FS_BOLD, 10);
//$bplot->value->SetAlign('left','center');
$bplot->value->SetColor("white");
$bplot->value->SetFormat('%.1f');
$bplot->SetValuePos('max');
// Add the bar to the graph
$graph->Add($bplot);
// Add some explanation text
$txt = new Text('Note: Higher value is better.');
$txt->SetPos(190, 399, 'center', 'bottom');
$txt->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->Add($txt);
// .. and stroke the graph
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:horizbarex6.php

示例11: array

require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay1 = array(11, 7, 5, 8, 3, 5, 5, 4, 8, 6, 5, 5, 3, 2, 5, 1, 2, 0);
$datay2 = array(4, 5, 4, 5, 6, 5, 7, 4, 7, 4, 4, 3, 2, 4, 1, 2, 2, 1);
$datay3 = array(4, 5, 7, 10, 13, 15, 15, 22, 26, 26, 30, 34, 40, 43, 47, 55, 60, 62);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40, 30, 20, 40);
// Create the linear plots for each category
$dplot[] = new Plot\LinePlot($datay1);
$dplot[] = new Plot\LinePlot($datay2);
$dplot[] = new Plot\LinePlot($datay3);
$dplot[0]->SetFillColor("red");
$dplot[1]->SetFillColor("blue");
$dplot[2]->SetFillColor("green");
// Create the accumulated graph
$accplot = new AccLinePlot($dplot);
// Add the plot to the graph
$graph->Add($accplot);
$graph->xaxis->SetTextTickInterval(2);
$graph->title->Set("Example 17");
$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();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:example17.php

示例12: array

<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$errdatay = array(11, 9, 2, 4, 19, 26, 13, 19, 7, 12);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 30, 20, 40);
$graph->SetShadow();
// Create the linear plot
$errplot = new Plot\ErrorLinePlot($errdatay);
$errplot->SetColor("red");
$errplot->SetWeight(2);
$errplot->SetCenter();
$errplot->line->SetWeight(2);
$errplot->line->SetColor("blue");
// Add the plot to the graph
$graph->Add($errplot);
$graph->title->Set("Linear error plot");
$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);
$datax = $gDateLocale->GetShortMonth();
$graph->xaxis->SetTickLabels($datax);
// Display the graph
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:example15.php

示例13:

$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetColor('white');
$graph->yaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->SetColor('white');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using alpha blending with a background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
// Create the three var series we will combine
$bplot1 = new Plot\BarPlot($datay1);
$bplot2 = new Plot\BarPlot($datay2);
$bplot3 = new Plot\BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('orange@0.4');
$bplot2->SetFillColor('brown@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new Plot\GroupBarPlot(array($bplot1, $bplot2, $bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:31,代码来源:alphabarex1.php

示例14: array

<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$ydata = array(12, 19, 3, 9, 15, 10);
// The code to setup a very basic graph
$graph = new Graph\Graph(200, 150);
$graph->SetScale('intlin');
$graph->SetMargin(30, 15, 40, 30);
$graph->SetMarginColor('white');
$graph->SetFrame(true, 'blue', 3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_YAXIS"');
$graph->SetAxisLabelBackground(LABELBKG_YAXIS, 'orange', 'red', 'lightblue', 'red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new Plot\LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:28,代码来源:axislabelbkgex03.php

示例15: array

<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay = array(62, 105, 85, 50);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(350, 220, 'auto');
$graph->SetScale("textlin");
//$theme_class="DefaultTheme";
//$graph->SetTheme(new $theme_class());
// set major and minor tick positions manually
$graph->yaxis->SetTickPositions(array(0, 30, 60, 90, 120, 150), array(15, 45, 75, 105, 135));
$graph->SetBox(false);
//$graph->ygrid->SetColor('gray');
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
// Create the bar plots
$b1plot = new Plot\BarPlot($datay);
// ...and add it to the graPH
$graph->Add($b1plot);
$b1plot->SetColor("white");
$b1plot->SetFillGradient("#4B0082", "white", GRAD_LEFT_REFLECTION);
$b1plot->SetWidth(45);
$graph->title->Set("Bar Gradient(Left reflection)");
// Display the graph
$graph->Stroke();
开发者ID:amenadiel,项目名称:jpgraph,代码行数:30,代码来源:new_bar3.php


注:本文中的Amenadiel\JpGraph\Graph\Graph::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。