homisinho 0 Denunciar post Postado Novembro 30, 2011 public function graf1Action() { require_once ('jpgraph/jpgraph.php'); require_once ('jpgraph/jpgraph_line.php'); $datay1 = array(20, 15, 23, 15); $datay2 = array(12, 9, 42, 8); $datay3 = array(5, 17, 32, 24); // Setup the graph $graph = new Graph(300, 250); $graph->SetScale("textlin"); $theme_class = new UniversalTheme; $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); $graph->title->Set('Filled Y-grid'); $graph->SetBox(false); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); $graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D')); $graph->xgrid->SetColor('#E3E3E3'); // Create the first line $p1 = new LinePlot($datay1); $graph->Add($p1); $p1->SetColor("#6495ED"); $p1->SetLegend('Line 1'); // Create the second line $p2 = new LinePlot($datay2); $graph->Add($p2); $p2->SetColor("#B22222"); $p2->SetLegend('Line 2'); // Create the third line $p3 = new LinePlot($datay3); $graph->Add($p3); $p3->SetColor("#FF1493"); $p3->SetLegend('Line 3'); $graph->legend->SetFrameWeight(1); // Output line $graph->Stroke(); //disabilita o layout $this->_helper->layout->disableLayout(); ///desabilita a view $this->_helper->viewRenderer->setNoRender(); } mas assim n posso colocar meu layout!!! Como eu poderia colocar meu layout e colocar o gráfico??? Compartilhar este post Link para o post Compartilhar em outros sites
Tiare Balbi Bonamini 2 Denunciar post Postado Dezembro 6, 2011 Crie um View Helper que isso lhe ajudará você exportar os dados para a sua View! Compartilhar este post Link para o post Compartilhar em outros sites
homisinho 0 Denunciar post Postado Dezembro 14, 2011 Desculpa a demora, mas estava resolvendo outros probleminhas.... fiz o q você falow criei a seguinte classe \application\views\helpers\Graf1.php <?php class Zend_View_Helper_Graf1 { public function graf1(){ require_once ('jpgraph/jpgraph.php'); require_once ('jpgraph/jpgraph_bar.php'); require_once ('jpgraph/jpgraph_line.php'); try{ //bar1 $data1y = array(115, 130, 135, 130, 110, 130, 130, 150, 130, 130, 150, 120); //bar2 $data2y = array(180, 200, 220, 190, 170, 195, 190, 210, 200, 205, 195, 150); //bar3 $data3y = array(220, 230, 210, 175, 185, 195, 200, 230, 200, 195, 180, 130); $data4y = array(40, 45, 70, 80, 50, 75, 70, 70, 80, 75, 80, 50); $data5y = array(20, 20, 25, 22, 30, 25, 35, 30, 27, 25, 25, 45); //line1 $data6y = array(50, 58, 60, 58, 53, 58, 57, 60, 58, 58, 57, 50); foreach ($data6y as &$y) { $y -=10; } // Create the graph. These two calls are always required $graph = new Graph(750, 320, 'auto'); $graph->SetScale("textlin"); $graph->SetY2Scale("lin", 0, 90); $graph->SetY2OrderBack(false); $graph->SetMargin(35, 50, 20, 5); $theme_class = new UniversalTheme; $graph->SetTheme($theme_class); $graph->yaxis->SetTickPositions(array(0, 50, 100, 150, 200, 250, 300, 350), array(25, 75, 125, 175, 275, 325)); $graph->y2axis->SetTickPositions(array(30, 40, 50, 60, 70, 80, 90)); $months = $gDateLocale->GetShortMonth(); $months = array_merge(array_slice($months, 3, 9), array_slice($months, 0, 3)); $graph->SetBox(false); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D')); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // Setup month as labels on the X-axis $graph->xaxis->SetTickLabels($months); // Create the bar plots $b1plot = new BarPlot($data1y); $b2plot = new BarPlot($data2y); $b3plot = new BarPlot($data3y); $b4plot = new BarPlot($data4y); $b5plot = new BarPlot($data5y); $lplot = new LinePlot($data6y); // Create the grouped bar plot $gbbplot = new AccBarPlot(array($b3plot, $b4plot, $b5plot)); $gbplot = new GroupBarPlot(array($b1plot, $b2plot, $gbbplot)); // ...and add it to the graPH $graph->Add($gbplot); $graph->AddY2($lplot); $b1plot->SetColor("#0000CD"); $b1plot->SetFillColor("#0000CD"); $b1plot->SetLegend("Cliants"); $b2plot->SetColor("#B0C4DE"); $b2plot->SetFillColor("#B0C4DE"); $b2plot->SetLegend("Machines"); $b3plot->SetColor("#8B008B"); $b3plot->SetFillColor("#8B008B"); $b3plot->SetLegend("First Track"); $b4plot->SetColor("#DA70D6"); $b4plot->SetFillColor("#DA70D6"); $b4plot->SetLegend("All"); $b5plot->SetColor("#9370DB"); $b5plot->SetFillColor("#9370DB"); $b5plot->SetLegend("Single Only"); $lplot->SetBarCenter(); $lplot->SetColor("yellow"); $lplot->SetLegend("Houses"); $lplot->mark->SetType(MARK_X, '', 1.0); $lplot->mark->SetWeight(2); $lplot->mark->SetWidth(8); $lplot->mark->setColor("yellow"); $lplot->mark->setFillColor("yellow"); $graph->legend->SetFrameWeight(1); $graph->legend->SetColumns(6); $graph->legend->SetColor('#4E4E4E', '#00A78A'); $band = new PlotBand(VERTICAL, BAND_RDIAG, 11, "max", 'khaki4'); $band->ShowFrame(true); $band->SetOrder(DEPTH_BACK); $graph->Add($band); $graph->title->Set("Combineed Line and Bar plots"); // Display the graph $graph->Stroke(); } catch (JpGraphException $e) { // .. do necessary cleanup // Send back error message $e->Stroke(); } } } ?> e na minha view coloquei a seguinte linha: <img src="<?php echo $this->graf1(); ?>" alt="Gráfico helper" /> E não carrega nada!!! Não encontrei ainda o que estou fazendo de errado, alguem pode dar uma mão? Compartilhar este post Link para o post Compartilhar em outros sites
Tiare Balbi Bonamini 2 Denunciar post Postado Dezembro 14, 2011 Eu não conheço esse plugin de grafico, mas uma coisa que você pode estar fazendo para testar e ver qual o retorno do método dentro da view, por que o que pode estar ocorrendo é a classe do gráfico não estar retornando a informação. Zend_Debug::dump($this->graf1()); Posta o retorno do Debug depois. Compartilhar este post Link para o post Compartilhar em outros sites
homisinho 0 Denunciar post Postado Dezembro 22, 2011 Desculpa ai pessoal, resolvido o problema!!! simplesmente antes de plotar o gráfico deve ser setado o header!!!! Parte do codigo q importa!!! header ("Content-type: image/png" ); $graph->Stroke(); //disabilita o layout $this->_helper->layout->disableLayout(); ///desabilita a view $this->_helper->viewRenderer->setNoRender(); Compartilhar este post Link para o post Compartilhar em outros sites