Graphs
Permalink 1 user found helpful
Hi all, Im fairly new to C5 but I want to use the GD library to generate some graphs, I have some code which follows but the main problem seems to be this line: header("Content-Type: image/png");
It says header information has already been sent
in the block controls, again I am a newbee, so sorry if im wasting your time but can anyone help?
I am using the php block to write this in, eventually I will use my database connection for the data but for now i just want to create a simple bar chart.
Thank yiu in advance
Gary
It says header information has already been sent
in the block controls, again I am a newbee, so sorry if im wasting your time but can anyone help?
I am using the php block to write this in, eventually I will use my database connection for the data but for now i just want to create a simple bar chart.
Thank yiu in advance
Gary
// This array of values is just here for the example. $values = array("23","32","35","57","12", "3","36","54","32","15", "43","24","30"); // Get the total number of columns we are going to plot $columns = count($values); // Get the height and width of the final image $width = 300; $height = 200; // Set the amount of space between each column $padding = 5; // Get the width of 1 column $column_width = $width / $columns ; // Generate the image variables $im = imagecreate($width,$height);
Viewing 15 lines of 41 lines. View entire code block.
where are you putting this code?
im putting the code in a php block, I could put it in a html block by adding the <php> </php> tags
yea, thats not going to work (btw the php tags are <?php and ?>)
you should make a tool with the above content with the header, then in a php block, make an image tag and echo the path to the tools file, thats the simplest way
you should make a tool with the above content with the header, then in a php block, make an image tag and echo the path to the tools file, thats the simplest way
sorry muddling my php and html tags - its been a long day!
As i said im a newbee to C5, tools file? There are lots of tools folders mainly in the blocks folder.
but ok i get the image tag
<img src='path to tools file' />
As i said im a newbee to C5, tools file? There are lots of tools folders mainly in the blocks folder.
but ok i get the image tag
<img src='path to tools file' />
make a file in /tools and call it graph.php (or w/e you want) and paste the code that you wrote
oops hit reply, in a php block do this:
$urls = Loader::helper('concrete/urls');
then do
$graph = $urls->getToolsURL('graph');
then echo $graph in the image tag,
$urls = Loader::helper('concrete/urls');
then do
$graph = $urls->getToolsURL('graph');
then echo $graph in the image tag,
so far so good :-) thank you for your time and help... um it displays a image holder... so its wanting to display an image but not getting it...
phpinfo() says I have GD installed, maybe its the graph.php code... I will look for some other code. Thank you for your help, if you have any other thoughts please let me know.
Gary
$urls = Loader::helper('concrete/urls'); $graph = $urls->getToolsURL('graph.php'); echo "<img src='$graph' />";
phpinfo() says I have GD installed, maybe its the graph.php code... I will look for some other code. Thank you for your help, if you have any other thoughts please let me know.
Gary
what is the path outputted? and what is displayed when you go to
site.com/index.php/tools/graph?
site.com/index.php/tools/graph?
oh, remove the .php from the ('graph.php')
its ok solved it... I didnt put in the <php ?> tags in the graph.php as I thought as I was using it in a php block it wouldnt work... now it works :-) thank you so much for your patience and help
Cool, NP :)