473,404 Members | 2,187 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,404 software developers and data experts.

How to create bar graph dynamically using gd libraries

254 100+
Hi

I have created bar graph using gd libraries and php but i want to create this graph dynamically. How can I do this? based on number of data width and height of the image will be changed.
Feb 7 '08 #1
8 2288
MarkoKlacar
296 Expert 100+
Hi,

Well I don't know what you've got so far, in detail that is, but you need to keep track of how many bars, obeservations etc you are going to work with.

You should either calculate this or provide it in some other way.

Are you reading values from a database or in some other way?
Feb 7 '08 #2
pedalpete
110 100+
not sure exactly what you are looking to do, or have done,
but I've been building bar graphs with css for years, and find it always works well for me.

Just set the div height or width to be dynamically output into your page and voila, instant bar chart.

Hope it helps
Feb 8 '08 #3
mukeshrasm
254 100+
not sure exactly what you are looking to do, or have done,
but I've been building bar graphs with css for years, and find it always works well for me.

Just set the div height or width to be dynamically output into your page and voila, instant bar chart.

Hope it helps

I dont how you are doing it using css so. if you may please give your code so that I can try to do it using css.
Feb 8 '08 #4
mukeshrasm
254 100+
Hi,

Well I don't know what you've got so far, in detail that is, but you need to keep track of how many bars, obeservations etc you are going to work with.

You should either calculate this or provide it in some other way.

Are you reading values from a database or in some other way?
presently I am not taking the data from database but later I will. I have track that how many bar I needed. thing is that when I try to give some negative values for graph it is not showing the bar. so If you need code definetly tell me.

or if you are using some thing like that please help me.
Feb 8 '08 #5
MarkoKlacar
296 Expert 100+
I've made my own charts, I wasn't using php when I did mine but I stil think I can give you some pointers.

Let me know when you get stuck or need advice.
Feb 8 '08 #6
ifedi
60
not sure exactly what you are looking to do, or have done,
but I've been building bar graphs with css for years, and find it always works well for me.

Just set the div height or width to be dynamically output into your page and voila, instant bar chart.

Hope it helps
Yeah, I've done a bar-graph with php and css myself. There were w major disadvantages, however, which I noted:
1. The 'bar divs' had to be absolutely positioned to work well, and there was no easy way of placing the div wrapping the bars on the page, unless the larger container-divs are themselves absolutely positioned.
2. The graphs will need a refresh each time you want the current status displayed.

I reckon that something like ajax would solve the latter problem. Unfortunately, I'm completely green, and painfully slow in ajax.

In conclusion: I still need help here!

Ifedi
Feb 8 '08 #7
pedalpete
110 100+
I can't track down any of my old code right now, but here's the basics,

step 1 - have your php page create the div which will be the bar and the size of the bar is the width field

each bar gets it's own div, the output html looks like this
Expand|Select|Wrap|Line Numbers
  1. <div class="bar"  style=" width: width-variable ">your bar variable</div> 
  2.  
then your css sets the rest of the style for the div

Expand|Select|Wrap|Line Numbers
  1. .bar { 
  2.         height: 14px;
  3.         border: solid black 1px;
  4.         background-color: blue;
  5. }
  6.  
that's it! You can line-up your bars by setting absolute positions if necessary, etc.
Vertical bars are a bit more difficult, but can be done (I did it a LONG time ago and remember positioning it being a pain, but eventually got it working).

If memory serves me correctly, the vertical bars where made by creating a div with a set width, and then having the background image begin partway the div setting the background position in the output.

Hope it helps,
Pete
Feb 8 '08 #8
MarkoKlacar
296 Expert 100+
Aren't we talking php-charts, i.e creating an image useing the gd libraries?
Or am I way off base?
Feb 11 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jon | last post by:
I need to generate an XML File dynamically using ASP and a SQL Database. I don't have time to learn php or any other programing language. I need a ASP page to either append information to an XML...
1
by: Kwan | last post by:
Hi All, In a Unix system (I am using Solaris, but not limited to it), who will dynamically linked libraries been linked to a multithreaded process? Will it have a different instance for every...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
2
by: santoshsri | last post by:
Hello, I will have to add textboxes in a datagrid Dynamically using Add button in C# Can anyone provide me a code snippet for this work. Thanks , San
3
by: itsSase | last post by:
Is there any way to change a Div ID - dynamically using Javascript...?????
0
by: Suresh Sharma | last post by:
i want to know how to create page dynamically like Sulekha.com which show his record per html page through programm. I am working on project such like this and i want to implement like this? ...
3
by: priya1985 | last post by:
i need to create radiobuttons dynamically by reading from the database.... can anybody provide some help????
1
by: ashima515 | last post by:
Hi.. I have made a drop down list...On selecting any of the option i want to display a table. Now the number of rows in the table depends on the selection. I am able to create a table with fixed...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.