473,383 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

easiest way to create a graph?

I'm looking at adding some basic line graphs to a page. Enabled gd, and
started in on pear::image_graph. Just wanting to start simple, I created a
new graph, set the background color, and displayed it. I also added the
header call to set the content for jpeg, but all I get is a bunch of
characters on my screen.

Here's the (excerpted) simple code:

Header ("Content-type: image/jpeg");

$defwidth = 300;
$defheight = 200;
$mychart = new Image_Graph($defwidth, $defheight);
$mychart->setBackgroundColor("white");
// build the chart

imagejpeg($mychart->getGDImage());

I also couldn't figure out what setBackgroundColor expected, Are there any
samples about for this?

Thanks,
Greg
Jul 17 '05 #1
3 1561
Greg Bryant <br**********@yahoo.com> wrote in
news:Xn**********************************@199.45.4 9.11:
I'm looking at adding some basic line graphs to a page. Enabled gd,
and started in on pear::image_graph. Just wanting to start simple, I
created a new graph, set the background color, and displayed it. I
also added the header call to set the content for jpeg, but all I get
is a bunch of characters on my screen.


I get it. You need to have the <img...> tag to get an image in the first
place, and can only get the image from the gd library indirectly. I think
the design is a bit off. If I'm forced to put the img source in different
script, it makes my database access more complex than necessary, or I can
drop it in a file, which just slows down the script. Yuck. I would much
prefer to directly use the imagepng call as the img source (i.e. <img
src=imagepng(resource)> ).

Oh well. At least I have a nice white box now!

Greg

Jul 17 '05 #2
Greg Bryant wrote:
Greg Bryant <br**********@yahoo.com> wrote in
news:Xn**********************************@199.45.4 9.11:
I'm looking at adding some basic line graphs to a page. Enabled gd,
and started in on pear::image_graph. Just wanting to start simple, I
created a new graph, set the background color, and displayed it. I
also added the header call to set the content for jpeg, but all I get
is a bunch of characters on my screen.


I get it. You need to have the <img...> tag to get an image in the first
place, and can only get the image from the gd library indirectly. I think
the design is a bit off. If I'm forced to put the img source in different
script, it makes my database access more complex than necessary, or I can
drop it in a file, which just slows down the script. Yuck. I would much
prefer to directly use the imagepng call as the img source (i.e. <img
src=imagepng(resource)> ).

Oh well. At least I have a nice white box now!

Greg


Hee Greg: 1 tip:

If you think your imagescript is producing errors, change the header to
text/html, and call the image directly.
In that way you often get a lot of notices/erros that you would otherwise
have to extract from some logfile.

It helped me a lot to debug quicker.

Regards,
Erwin
Jul 17 '05 #3
Erwin Moller
<si******************************************@spam yourself.com> wrote in
news:41***********************@news.xs4all.nl:

Hee Greg: 1 tip:

If you think your imagescript is producing errors, change the header
to text/html, and call the image directly.
In that way you often get a lot of notices/erros that you would
otherwise have to extract from some logfile.

It helped me a lot to debug quicker.

Regards,
Erwin


That's a good idea - thanks.

If anyone knows of any examples of the pear::image_graph stuff out there,
I'm still looking for some. Even the blog comments like the main php
site's docs have are handy, but either aren't done for pear or no one uses
it.

Greg
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Lilith | last post by:
Is there a python module somewhere (been searching today, no luck) which has efficiently coded various graph-handling routines, such as finding the shortest path through a graph, or the set of all...
7
by: Wolfgang Kreuzer | last post by:
Hello all, I have two tables - Projects and ProjectStruct Table Projects contains master records of the projects, ProjectStruct allows to define a project herarchie and contains the fields...
1
by: mahnovetsky | last post by:
Does anybody know of a way to set the format property for a date field in VBA?? I need to set the property to medium so I can display display aussie dates on a graph.. Here is what Im doing: ...
1
by: entropy123 | last post by:
Hey all, In an effort to solve a sticky - for me - problem I've picked up Sedgewick's 'Algorithm's in C'. I've tried working through the first few problems but am a little stumped when he refers...
5
by: mebrabham | last post by:
Hello, I am trying to create a running subtotal in a query and then graph the running subtotal for each city group. The data looks like this in the table (for illustration): My City My...
2
by: sriniwas | last post by:
Hi Frnd's, m using prefuse visulation,it's have one display class and this class have one saveImage(outPutStream, String jpg,double size);. now graph is converting ia jpg image properly.now my...
4
by: Man4ish | last post by:
namespace ve/////////////////ve.h { struct VertexProperties { std::size_t index; boost::default_color_type color; }; }...
2
by: Man4ish | last post by:
I have created Graph object without vertex and edge property.It is working fine. #include <boost/config.hpp> #include <iostream> #include <vector> #include <string> #include...
8
by: petesquawk | last post by:
What is the fastest and easiest way to graph data in VB.net? How do I export 2 columns of data in Vb.net, to either an excel file or to a notepad file?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.