473,412 Members | 4,519 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,412 software developers and data experts.

How to draw barchart in php

Hello everybody,

I am trying to create barchart in php,but i am little bit confused about how does

imagefilledrectangle() works actually.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Create a 55x30 image
  3. $im = imagecreatetruecolor(55, 30);
  4. $white = imagecolorallocate($im, 255, 255, 255);
  5.  
  6. // Draw a white rectangle
  7. imagefilledrectangle($im, 4, 4, 50, 25, $white);
  8.  
  9. // Save the image
  10. imagepng($im, './imagefilledrectangle.png');
  11. imagedestroy($im);
  12. ?>
  13.  
in this code I saw that the second co-ordinates(x2,y2) always would be (imagewidth-(x1 co-ordinates+1)) ,(imageheight-(x1 co-ordinates+1))

could anyone explain the logic behind this please.

Thank you
May 14 '10 #1
3 1656
zorgi
431 Expert 256MB
I am not looking at your code but reading that you want to create bar chart. Instead of doing it from scratch you might want to look at ready made pChart. Easy to use and fairly well documented:

http://pchart.sourceforge.net/

Hope this helps :)
May 14 '10 #2
yobtar
1
While talking about graphing libraries, I personally use jpgraph myself.
May 15 '10 #3
@zorgi
Thank you yobtar and zorg you too.

But as I am newbie,so i guess it would be better to understand the logic behind bar chart,because once I got the logic behind its working I can draw any chart by myself.

So if you have any link from where I could understand the same in better way ,please let me know.I myself search it out on net ,I got almost every thing from there but just stuck behind why the second co-coordinates in

imagefilledrectangle($im,x1,y1, x2-1, y2-1, $white),
always would be (imagewidth-(x1 co-ordinates+1)) ,(imageheight-(x1 co-ordinates+1))

Thank you
May 16 '10 #4

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

Similar topics

1
by: dimitri pater | last post by:
Hello, I am looking for a Python tool to create graphs and charts on a webpage. Chartdirector is too expensive for me. A simple script for creating a barchart should be sufficient as a starting...
0
by: Tomi Holger Engdahl | last post by:
I am looking for a solution to add on-line drawing tool to a phpBB discussion board. The idea would be that the users can draw their own simple drawings with the tool and attach them easily as...
2
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and...
1
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To...
7
by: Marc Pelletier | last post by:
Hello all, I have a class which includes a method to create a chart. I want to be able to call this method from asp.net code as well as windows application code, so I have sketched it out as...
5
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
1
by: YouPoP | last post by:
I am doing an app (C# 2.0) where you can draw in a panel with your mouse in "real time". I actually have 2 problems; 1- it does not really is "real time", if your mouse move fast or very fast the...
2
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
0
by: sandeepsangshetty | last post by:
hi friends In my application i want to draw one barchart ,but while running the page i am getting an error "An exception of type 'System.Runtime.InteropServices.ExternalException' occurred in...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.