Note that there are some explanatory texts on larger screens.

plurals
  1. POOutput JPGraph in Symfony 2
    primarykey
    data
    text
    <p>I'm attempting to have a Symfony 2 Controller generate a graph from JPGraph. The issue that I'm having is getting Symfony and JPGraph to work together reliably.</p> <p>I made my controller, and I have made sure that I'm getting inside the function, but I'm unable to have the graph output to the browser. I've tried $graph->Stroke() while using the image/jpeg header, but it results in a blank page. I've also tried to use Twig and pass my graph object to the template, and call graph.Stroke, but it appears Twig doesn't parse this properly as the image doesn't appear (I used the base 64 encoding on my img src, and it still resulted in no image.)</p> <p>Lastly, I've tried </p> <pre><code>return $graph-&gt;Stroke() </code></pre> <p>and</p> <pre><code>return new Response($graph-&gt;Stroke()); </code></pre> <p>But both also just resulted in a blank page as well. I'll provide whatever source anyone deems required in the morning when I'm back at work, I simply was hoping that without the source, someone may be able to direct me to how to have Symfony and JPGraph both interact in the way I desire.</p> <p>Update:</p> <p>Here is the source that I'm attempting to get running as a demo/learning exercise to get the two working together.</p> <pre><code>&lt;?php // namespace Bundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; $JPGraphSrc = 'JPGraph/src'; require_once ($JPGraphSrc.'/jpgraph.php'); require_once ($JPGraphSrc.'/jpgraph_line.php'); require_once ($JPGraphSrc.'/jpgraph_bar.php'); require_once ($JPGraphSrc.'/jpgraph_date.php'); class GraphingController extends Controller { public function createGraphAction(Request $request) { $this-&gt;getResponse()-&gt;setContent('image/jpeg'); // Some data $ydata = array(11,3,8,12,5,1,9,13,5,7); // Create the graph. These two calls are always required $graph = new Graph(350,250); $graph-&gt;SetScale('textlin'); // Create the linear plot $lineplot=new LinePlot($ydata); $lineplot-&gt;SetColor('blue'); // Add the plot to the graph $graph-&gt;Add($lineplot); // Display the graph $graph-&gt;Stroke(); return sfView::NONE; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload