Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPlot doesn't show an image

I just downloaded PHPlot and included it into a php file. I tried to get an example work, but there are only some signs not a graph.

I'm Using XAMPP and Joomla.

This shows me:

enter image description here

I need GD enabled, just a screenshot of my GD settings:

http://s1.directupload.net/file/d/3382/jv3omrny_jpg.htm

Did I do anything wrong?


I tried to place the file outside of joomla and placed it to xampp - it works. But I need that graph inside my joomla installation.

Code:

<?php
header('Content-Type: image/png');
require '/libraries/phplot-6.1.0/phplot.php';
$data = array(
        array('', 1800,   5), array('', 1810,   7), array('', 1820,  10),
        array('', 1830,  13), array('', 1840,  17), array('', 1850,  23),
        array('', 1860,  31), array('', 1870,  39), array('', 1880,  50),
        array('', 1890,  63), array('', 1900,  76), array('', 1910,  92),
        array('', 1920, 106), array('', 1930, 123), array('', 1940, 132),
        array('', 1950, 151), array('', 1960, 179), array('', 1970, 203),
        array('', 1980, 227), array('', 1990, 249), array('', 2000, 281),
);

$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');

$plot->SetPlotType('lines');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);

# Main plot title:
$plot->SetTitle('US Population, in millions');

# Make sure Y axis starts at 0:
$plot->SetPlotAreaWorld(NULL, 0, NULL, NULL);
$plot->DrawGraph();
// phpinfo();
?>
like image 564
monti Avatar asked Dec 03 '25 04:12

monti


1 Answers

I had the same problem when using PHPlot with AJAX. The solution is to create a new file with only the graph code, eg createGraph.php. So I call this file in my img tag like this: echo '<img src = "createGraph.php" />';

I can also pass via GET parameters to customize the chart, as follows: echo '<img src = "createGraph.php?title=My_Graph&val1=1&val2=2" />'; and createGraph.php, get through GET the dynamic information of the chart.

like image 112
Diogo Juliao Avatar answered Dec 04 '25 17:12

Diogo Juliao