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


PHP Graph::Add方法代码示例

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


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

示例1: LineGraph

function LineGraph($w, $h, $title, $data1, $data2, $datax, $output)
{
    // Create the graph. These two calls are always required
    $graph = new Graph($w, $h, "auto");
    $graph->SetScale("textlin");
    $graph->SetMarginColor('white');
    $graph->SetFrame(true);
    // Adjust the margin
    $graph->img->SetMargin(40, 100, 20, 40);
    $graph->SetShadow(false);
    // Create the linear plot
    $lineplot = new LinePlot($data1);
    $lineplot->SetWeight(2);
    $lineplot->SetColor("blue");
    $lineplot->mark->SetType(MARK_DIAMOND);
    $lineplot->mark->SetWidth(5);
    $lineplot->mark->SetFillColor('blue');
    $lineplot->value->SetMargin(-20);
    $lineplot->value->show();
    $lineplot->value->SetColor('blue');
    $lineplot->value->SetFormat('%0.0f');
    $lineplot->SetLegend($_SESSION[Tahun1]);
    $lineplot2 = new LinePlot($data2);
    $lineplot2->SetColor("green");
    $lineplot2->SetWeight(2);
    $lineplot2->mark->SetType(MARK_FILLEDCIRCLE);
    $lineplot2->mark->SetWidth(3);
    $lineplot2->mark->SetFillColor('green');
    $lineplot2->value->show();
    $lineplot2->value->SetColor('darkgreen');
    $lineplot2->value->SetFormat('%0.0f');
    $lineplot2->SetLegend($_SESSION[Tahun2]);
    // Add the plot to the graph
    $graph->Add($lineplot);
    $graph->xaxis->SetTickLabels($datax);
    $graph->title->Set($title);
    $graph->xaxis->title->Set("");
    $graph->yaxis->title->Set("");
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->Add($lineplot2);
    $graph->legend->SetShadow(false);
    $graph->legend->SetFillColor('white');
    $graph->legend->SetPos(0.01, 0.88, 'right', 'center');
    // Display the graph
    $graph->Stroke($output);
}
开发者ID:anggadjava,项目名称:mitra_siakad,代码行数:48,代码来源:pmblap.aplikan.cetak.php

示例2: renderGraph

 public function renderGraph()
 {
     require_once 'libs/jpgraph/jpgraph.php';
     require_once 'libs/jpgraph/jpgraph_bar.php';
     $graph = new Graph($this->_controllerAction->getRequest()->getParam('type') == 'month' ? 400 : 300, 200, 'auto');
     $graph->SetMarginColor('white');
     $graph->SetFrame(false);
     $graph->SetScale("textlin");
     $graph->img->SetMargin(0, 30, 20, 40);
     $graph->yaxis->scale->SetGrace(20);
     $graph->yaxis->HideLabels();
     $graph->yaxis->HideTicks();
     $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
     $labelsy = array();
     $datay = array();
     switch ($this->_controllerAction->getRequest()->getParam('type')) {
         case 'month':
             $this->_populateMonthData($labelsy, $datay);
             break;
         case 'year':
             $this->_populateYearData($labelsy, $datay);
             break;
         default:
             $this->_populateWeekData($labelsy, $datay);
     }
     $graph->xaxis->SetTickLabels($labelsy);
     $bplot = new BarPlot($datay);
     $bplot->SetFillGradient("navy", "lightsteelblue", GRAD_WIDE_MIDVER);
     $bplot->value->Show();
     $bplot->value->SetFormat('%d');
     $graph->Add($bplot);
     $graph->Stroke();
 }
开发者ID:sdgdsffdsfff,项目名称:auth-center,代码行数:33,代码来源:Registrations.php

示例3: executeGetFunctionGraph

 public function executeGetFunctionGraph(sfWebRequest $request)
 {
     $this->getUrlParameters($request);
     $this->fct_id = $request->getParameter('function_id');
     $this->fct_ref = $request->getParameter('function_ref');
     //récupération du nom pour les affichages.
     $this->node = Doctrine_Core::getTable('EiTree')->findOneByRefObjAndObjIdAndType($this->fct_ref, $this->fct_id, 'Function');
     //récupération des temps d'execution
     $this->times = Doctrine_Core::getTable('EiFonction')->getTimeStats($this->project_id, $this->project_ref, $this->fct_id, $this->fct_ref);
     // Width and height of the graph
     $width = 700;
     $height = 300;
     // Create a graph instance
     $graph = new Graph($width, $height);
     $graph->SetScale('intint');
     $graph->title->Set($this->node->getName() . " 's execution time evolution.");
     $graph->xaxis->title->Set('Execution');
     $graph->yaxis->title->Set('Time (ms)');
     $exec = array();
     //récupération des durées uniquement
     foreach ($this->times as $t => $time) {
         $exec[] = $time['l_duree'];
     }
     $lineplot = new LinePlot($exec);
     $graph->Add($lineplot);
     $graph->Stroke();
     return sfView::NONE;
 }
开发者ID:lendji4000,项目名称:compose,代码行数:28,代码来源:actions.class.php

示例4: monthchart

 function monthchart($xdata, $ydata, $title = 'Line Chart')
 {
     // Create the graph. These two calls are always required
     $graph = new Graph(600, 250, "auto", 60);
     $graph->img->SetAntiAliasing(false);
     $graph->SetScale("textlin");
     $graph->xaxis->SetTickLabels($xdata);
     $graph->xgrid->SetColor('#E3E3E3');
     $graph->legend->SetFrameWeight(1);
     // Setup title
     $graph->title->Set($title);
     foreach ($ydata as $item) {
         // Create the linear plot
         if (count($item['values']) != count($xdata)) {
             continue;
         }
         $lineplot = new LinePlot($item['values'], $xdata);
         $lineplot->SetColor($item['color']);
         if (count($ydata) == 1) {
             $lineplot->SetFillColor($item['color']);
         }
         // Add the plot to the graph
         $graph->Add($lineplot);
         $lineplot->SetLegend($item['legend']);
     }
     return $graph;
 }
开发者ID:FaddliLWibowo,项目名称:MapIgniter,代码行数:27,代码来源:jpgraph.php

示例5: array

 function conf__grafico(toba_ei_grafico $grafico)
 {
     if (isset($this->datos)) {
         $datos = array();
         $leyendas = array();
         foreach ($this->datos as $value) {
             $datos[] = $value['resultado'];
             $leyendas[] = $value['codc_uacad'];
         }
     }
     require_once toba_dir() . '/php/3ros/jpgraph/jpgraph.php';
     require_once toba_dir() . '/php/3ros/jpgraph/jpgraph_bar.php';
     // Setup a basic graph context with some generous margins to be able
     // to fit the legend
     $canvas = new Graph(900, 300);
     $canvas->SetMargin(100, 140, 60, 40);
     $canvas->title->Set('Cr�dito Disponible');
     //$canvas->title->SetFont(FF_ARIAL,FS_BOLD,14);
     // For contour plots it is custom to use a box style ofr the axis
     $canvas->legend->SetPos(0.05, 0.5, 'right', 'center');
     $canvas->SetScale('intint');
     //$canvas->SetAxisStyle(AXSTYLE_BOXOUT);
     //$canvas->xgrid->Show();
     $canvas->ygrid->Show();
     $canvas->xaxis->SetTickLabels($leyendas);
     // A simple contour plot with default arguments (e.g. 10 isobar lines)
     $cp = new BarPlot($datos);
     $cp->SetColor("#B0C4DE");
     $cp->SetFillColor("#B0C4DE");
     $cp->SetLegend("Resultado");
     $canvas->Add($cp);
     // Con esta llamada informamos al gr�fico cu�l es el gr�fico que se tiene
     // que dibujar
     $grafico->conf()->canvas__set($canvas);
 }
开发者ID:pkogan,项目名称:presupuesto,代码行数:35,代码来源:ci_comparacion_unidad.php

示例6: graficofecha

 public function graficofecha($gestion)
 {
     if (Conectar::con()) {
         //$gestion='2013';
         $objetoanalisis = new classAnalisis();
         $anio = $gestion;
         for ($i = 0; $i < 12; $i++) {
             $dat[] = $objetoanalisis->ventamensual($anio, $i);
         }
         $datos = $dat;
         //$datos =array('1','4','3','3','5');
         $grafico = new Graph(400, 300, "auto");
         $grafico->SetScale("textlin");
         $grafico->title->Set("Resumen de ventas por gestion");
         $grafico->xaxis->title->Set("");
         $grafico->yaxis->title->Set("");
         // Un gradiente Horizontal de rojo a azul
         // 25 pixeles de ancho para cada barra
         $lineplot = new LinePlot($datos);
         $lineplot->SetColor("green");
         $lineplot->SetWeight(2);
         $grafico->Add($lineplot);
         return $grafico->Stroke();
     }
 }
开发者ID:jaironman3008,项目名称:mercadomundial,代码行数:25,代码来源:classgrafico.php

示例7: showimg

function showimg($value, $clock, $key)
{
    $datay1 = $value;
    $graph = new Graph(1000, 400);
    $graph->SetScale("textlin");
    //设置图片外边距(左,右,上,下)
    $graph->img->SetMargin(100, 20, 20, 60);
    $graph->title->Set($key);
    $graph->yaxis->HideZeroLabel();
    $graph->yaxis->HideLine(false);
    $graph->yaxis->HideTicks(false, false);
    $graph->xgrid->Show();
    $graph->xgrid->SetLineStyle("solid");
    //x轴文字
    $graph->xaxis->SetTickLabels($clock);
    $graph->xaxis->SetLabelAngle(90);
    //x轴颜色
    $graph->xgrid->SetColor('#E3E3E3');
    // Create the first line
    $p1 = new LinePlot($datay1);
    $graph->Add($p1);
    $p1->SetColor("#6495ED");
    $graph->legend->SetFrameWeight(1);
    // Output line
    $graph->Stroke();
}
开发者ID:youli023023,项目名称:zabbix_api,代码行数:26,代码来源:showimg.php

示例8: graphs

 static function graphs($name, $close)
 {
     // Setup the graph
     $graph = new Graph(1000, 653, 'auto');
     $graph->SetScale("textlin");
     $theme_class = new UniversalTheme();
     $graph->SetTheme($theme_class);
     $graph->img->SetAntiAliasing(false);
     $graph->title->SetFont(FF_FONT2, FS_BOLD, 20);
     $graph->title->Set("Stock Performance History for " . $name);
     $graph->SetBox(false);
     $graph->yaxis->HideZeroLabel();
     $graph->yaxis->HideLine(false);
     $graph->yaxis->HideTicks(false, false);
     $graph->yaxis->title->SetFont(FF_FONT2, FS_BOLD, 20);
     $graph->yaxis->title->Set('Close Price');
     $graph->xgrid->Show();
     $graph->xgrid->SetLineStyle("solid");
     $graph->xaxis->SetTickPositions(array(0, 20, 40, 61, 82, 103, 124, 143));
     $graph->xaxis->SetTickLabels(array('Nov 2014', 'Dec 2014', 'Jan 2015', 'Feb 2015', 'March 2015', 'April 2015', 'May 2015', 'June 2015'));
     $graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD, 20);
     $graph->xaxis->title->Set('Dates');
     $graph->xgrid->SetColor('#E3E3E3');
     // Create the first line
     $p1 = new LinePlot($close);
     $graph->Add($p1);
     $p1->SetColor("#6495ED");
     $graph->legend->SetFrameWeight(2);
     // Output line
     $graph->Stroke();
 }
开发者ID:ckc6cz,项目名称:ManhattanProject,代码行数:31,代码来源:graphs.php

示例9: plot

 function plot($pid)
 {
     $this->_setValues($pid);
     $graph = new Graph(600, 400);
     $graph->img->SetMargin(60, 95, 40, 40);
     $graph->SetShadow();
     $graph->SetScale("textlog");
     $colors = array("hotpink", "green", "blue", "gold", "blueviolet", "deepskyblue", "brown", "cadetblue", "darksalmon", "cornflowerblue", "darkslateblue", "limegreen", "yellow", "navy", "slategray");
     srand(1);
     for ($i = 0; $i < sizeof($this->_data); $i++) {
         $bplot[$i] = new BarPlot($this->_data[$i]);
         if ($i < sizeof($colors)) {
             $color = $colors[$i];
         } else {
             $r = rand(0, 255);
             $g = rand(0, 255);
             $b = rand(0, 255);
             $color = array($r, $g, $b);
         }
         $bplot[$i]->SetFillColor($color);
         $bplot[$i]->SetLegend($this->_legend[$i]);
     }
     $gbplot = new GroupBarPlot($bplot);
     $graph->Add($gbplot);
     $graph->title->Set("# of Visited Articles per Month (log scale)");
     $graph->title->SetFont(FONT2_BOLD);
     $graph->xaxis->SetTickLabels($this->_months);
     $graph->ygrid->Show(true, true);
     $graph->xaxis->SetFont(FONT1_BOLD);
     $graph->yaxis->SetFont(FONT1_BOLD);
     $graph->Stroke();
 }
开发者ID:Ethennoob,项目名称:Web,代码行数:32,代码来源:GraphVisitsMonthAllYears.php

示例10: barcart

function barcart($datay)
{
    require_once "jpgraph/jpgraph.php";
    require_once "jpgraph/jpgraph_bar.php";
    // Setup the graph.
    $graph = new Graph(660, 250);
    $graph->SetScale("textlin");
    // Add a drop shadow
    $graph->SetShadow();
    // Adjust the margin a bit to make more room for titles
    $graph->SetMargin(40, 30, 20, 40);
    // Setup the titles
    $graph->title->Set('NHR Registry');
    $graph->xaxis->title->Set('X-title');
    $graph->yaxis->title->Set('Y-title');
    // Create the bar pot
    $bplot = new BarPlot($datay);
    // Adjust fill color
    $bplot->SetFillColor('orange');
    $graph->Add($bplot);
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
    return $graph;
}
开发者ID:JosephMokano,项目名称:somu-nhr,代码行数:25,代码来源:jpgraph_pi.php

示例11: build

 public function build()
 {
     $path = APPPATH;
     require_once $path . 'libraries/jpgraph/src/jpgraph.php';
     require_once $path . 'libraries/jpgraph/src/jpgraph_bar.php';
     //        $datay = array(62, 105, 85, 50);
     $datay = $this->parameters;
     // Create the graph. These two calls are always required
     //        $graph = new Graph(350, 220, 'auto');
     $graph = new 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 BarPlot($datay);
     $b1plot = new 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
     $d['grafica'] = $graph->Stroke("jacobo.png");
     $d['path'] = $path;
     return $d;
 }
开发者ID:jvasquez8704,项目名称:sistema-administracion-contratos,代码行数:35,代码来源:graphics.php

示例12: graficarBarras

function graficarBarras()
{
    require_once "jpgraph/src/jpgraph.php";
    require_once "jpgraph/src/jpgraph_bar.php";
    $datos = array($_GET['pos'], $_GET['neg']);
    //Instancia del objeto del tipo Graph en donde como parametro
    // se le pasan los valore de ancho y altura
    $grafica = new Graph(400, 300);
    $grafica->SetScale("textlin");
    $grafica->SetBox(false);
    //Nombre de las columnas
    $columnas = array($_GET['lab1'], $_GET['lab2']);
    $grafica->xaxis->SetTickLabels($columnas);
    //Objeto del tipo BarPlot que se le enviara a la grafica y el cual
    //recibe como parametros los datos a graficar
    $barras = new BarPlot($datos);
    $grafica->Add($barras);
    //Color de los bordes
    //Color de borde de las barras
    $barras->SetColor("white");
    //Color de relleno de las barras
    $barras->SetFillColor("#4B0082");
    //Ancho de las barras
    $barras->SetWidth(45);
    // $grafica->title->Set("Gráfica de Barras");
    $grafica->title->SetFont(FF_TIMES, FS_ITALIC, 18);
    $grafica->Stroke();
}
开发者ID:emacer,项目名称:Gereho,代码行数:28,代码来源:torta3D.php

示例13: array

 /**
  * Para el tipo de gráfico 'otro' hay que especificar todo lo referente a
  * jpgraph. Desde la inclusión de los archivos necesarios hasta la instanciación
  * de todas las componentes que esta necesita para generar un gráfico.
  * Lo único que hay que hacer es 'avisarle' al gráfico de toba cuál es el
  * canvas que se tiene que dibujar. Todo el resto es legal y bonito
  *
  * @param toba_ei_grafico $grafico
  */
 function conf__grafico(toba_ei_grafico $grafico)
 {
     require_once toba_dir() . '/php/3ros/jpgraph/jpgraph.php';
     require_once toba_dir() . '/php/3ros/jpgraph/jpgraph_contour.php';
     $data = array(array(0.5, 1.1, 1.5, 1, 2.0, 3, 3, 2, 1, 0.1), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 1, 4), array(0.9, 2.0, 2.1, 3, 6.0, 7, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1.5, 1, 2), array(0.8, 2.0, 3.0, 3, 4.0, 4, 3, 2.4, 2, 3), array(0.6, 1.1, 1.5, 1, 4.0, 3.5, 3, 2, 3, 4), array(9.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 2.7, 4), array(9.800000000000001, 9.0, 3.0, 3, 5.5, 6, 3, 2, 1, 1.4), array(9.0, 1.5, 3.0, 4, 6.0, 5, 2, 1, 0.5, 0.2));
     // Setup a basic graph context with some generous margins to be able
     // to fit the legend
     $canvas = new Graph(650, 300);
     $canvas->SetMargin(40, 140, 60, 40);
     $canvas->title->Set('Uso avanzado de la librería');
     $canvas->title->SetFont(FF_ARIAL, FS_BOLD, 14);
     // For contour plots it is custom to use a box style ofr the axis
     $canvas->legend->SetPos(0.05, 0.5, 'right', 'center');
     $canvas->SetScale('intint');
     $canvas->SetAxisStyle(AXSTYLE_BOXOUT);
     $canvas->xgrid->Show();
     $canvas->ygrid->Show();
     // A simple contour plot with default arguments (e.g. 10 isobar lines)
     $cp = new ContourPlot($data);
     // Display the legend
     $cp->ShowLegend();
     // Make the isobar lines slightly thicker
     $cp->SetLineWeight(2);
     $canvas->Add($cp);
     // Con esta llamada informamos al gráfico cuál es el gráfico que se tiene
     // que dibujar
     $grafico->conf()->canvas__set($canvas);
 }
开发者ID:emma5021,项目名称:toba,代码行数:37,代码来源:ci_ejemplo_4.php

示例14: plot

 function plot($pid)
 {
     $this->_setValues($pid);
     $graph = new Graph(600, 400);
     $graph->img->SetMargin(60, 95, 40, 40);
     $graph->SetShadow();
     $graph->SetScale("textlog");
     $colors = array("yellow", "green", "blue", "red");
     srand(1);
     for ($i = 0; $i < sizeof($this->_data); $i++) {
         $bplot[$i] = new BarPlot($this->_data[$i]);
         $color = $colors[$i];
         $bplot[$i]->SetFillColor($color);
         $bplot[$i]->SetLegend($this->_legend[$i]);
     }
     $gbplot = new GroupBarPlot($bplot);
     $graph->Add($gbplot);
     $graph->title->Set("# of Visited Articles per Language (log scale)");
     $graph->title->SetFont(FONT2_BOLD);
     $graph->xaxis->SetTickLabels($this->_years);
     $graph->ygrid->Show(true, true);
     $graph->xaxis->SetFont(FONT1_BOLD);
     $graph->yaxis->SetFont(FONT1_BOLD);
     $graph->Stroke();
 }
开发者ID:Ethennoob,项目名称:Web,代码行数:25,代码来源:GraphLanguageYear.php

示例15: index

 public function index()
 {
     // We want a bar graph, so use JpGraph's bar chart library
     require_once APPPATH . '/libraries/JpGraph/jpgraph_bar.php';
     // Example data (04/2015)
     $json = '[{"Hogwarts Academy":{"Yield":"19021 kWh","Yield specific":"127.01 kWh\\/kWp","Target yield":"16069.23 kWh","Current-target yield %":"<span style=\\"color: #3ab121\\">118.37 %<span>"}},{"cols": [{"id":"","label":"Time","pattern":"","type":"string"},{"id":"","label":"Hogwarts Academy (AC)","pattern":"","type":"number"},{"id":"","label":"Target values","pattern":"","type":"number"}], "rows": [{"c":[{"v":"01/04","f":null}, {"v":615.8,"f":"615,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"02/04","f":null}, {"v":712.5,"f":"712,50 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"03/04","f":null}, {"v":171,"f":"171,00 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"04/04","f":null}, {"v":382.3,"f":"382,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"05/04","f":null}, {"v":606.3,"f":"606,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"06/04","f":null}, {"v":774.5,"f":"774,50 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"07/04","f":null}, {"v":570.6,"f":"570,60 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"08/04","f":null}, {"v":726.8,"f":"726,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"09/04","f":null}, {"v":789.2,"f":"789,20 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"10/04","f":null}, {"v":592.9,"f":"592,90 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"11/04","f":null}, {"v":677.1,"f":"677,10 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"12/04","f":null}, {"v":244.5,"f":"244,50 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"13/04","f":null}, {"v":457.4,"f":"457,40 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"14/04","f":null}, {"v":340.8,"f":"340,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"15/04","f":null}, {"v":425.3,"f":"425,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"16/04","f":null}, {"v":828.8,"f":"828,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"17/04","f":null}, {"v":616.8,"f":"616,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"18/04","f":null}, {"v":660.3,"f":"660,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"19/04","f":null}, {"v":453.2,"f":"453,20 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"20/04","f":null}, {"v":691.9,"f":"691,90 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"21/04","f":null}, {"v":904.4,"f":"904,40 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"22/04","f":null}, {"v":879.1,"f":"879,10 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"23/04","f":null}, {"v":824.8,"f":"824,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"24/04","f":null}, {"v":777.9,"f":"777,90 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"25/04","f":null}, {"v":413.8,"f":"413,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"26/04","f":null}, {"v":834.8,"f":"834,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"27/04","f":null}, {"v":920.8,"f":"920,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"28/04","f":null}, {"v":751,"f":"751,00 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"29/04","f":null}, {"v":737.7,"f":"737,70 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"30/04","f":null}, {"v":638.7,"f":"638,70 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]}]}]';
     // Turn string into object
     $obj = json_decode($json);
     // Stores for graph data
     $xdata = array();
     $ydata = array();
     // Get coords data from object
     $obj_data = $obj[1]->rows;
     $counter = 1;
     // Add it to each of our storage arrays
     foreach ($obj_data as $data) {
         // only plot when there is a kW value
         if (isset($data->c[1]->v)) {
             $xdata[] = $data->c[0]->v;
             // date
             $ydata[] = $data->c[1]->v;
             // kw
         }
     }
     // Create the graph.
     // One minute timeout for the cached image
     // INLINE_NO means don't stream it back to the browser.
     $graph = new Graph(600, 350, 'auto');
     $graph->SetScale("textlin");
     $graph->img->SetMargin(60, 30, 20, 40);
     $graph->yaxis->SetTitleMargin(45);
     $graph->yaxis->scale->SetGrace(30);
     $graph->SetShadow();
     // Turn the tickmarks
     $graph->xaxis->SetTickSide(SIDE_DOWN);
     $graph->yaxis->SetTickSide(SIDE_LEFT);
     // Create a bar pot
     $bplot = new BarPlot($ydata);
     $bplot->SetFillColor("orange");
     // Use a shadow on the bar graphs (just use the default settings)
     $bplot->SetShadow();
     $bplot->value->SetFormat(" %2.1f kW", 70);
     $bplot->value->SetFont(FF_VERDANA, FS_NORMAL, 8);
     $bplot->value->SetColor("blue");
     $bplot->value->Show();
     $graph->Add($bplot);
     $graph->title->Set("Hogwarts Academy");
     $graph->xaxis->title->Set("Day");
     $graph->yaxis->title->Set("Yield in kilowatt hours");
     $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:alexismansilla,项目名称:codeigniter-jpgraph,代码行数:56,代码来源:grapher.php


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