TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack (21) Thread Tools Search this Thread Display Modes
Old 12-11-2007, 12:05 PM   21 links from elsewhere to this Post. Click to view. #1 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default GoogleCharts

I've been playing with some Google Chart classes over the weekend and I've decided to give the code an early release to see what people think. It's all very basic still, I've mainly concentrated on implementing a flexible system, which I think I've achieved pretty well. I haven't done any performance tuning or anything (and there are a few places where performance improvements are obvious).

Have a play around, let me know what you think. I know there are a lot of improvements that can be made, and I'm eager to see everyones opinions. I don't mind a bit of criticism

There's an example included, but here's an example for the people who wanna see before downloading:

PHP Code:
$pChart = new GoogleChart(GoogleChart::TYPE_BAR_HSTACKED);

$pChart->setSize(200100)
    ->
setGridLines(202015)
    ->
setBackgroundFill(new GoogleChart_Fill_Solid('EFEFEF'))
    ->
setChartFill(new GoogleChart_Fill_LinearGradient(0'76A4FB'0'ffffff'1))
    ->
addData(new GoogleChart_Data_Generic(array(0104010), 'Legend 1''FF0000'))
    ->
addData(new GoogleChart_Data_Generic(array(40201020), 'Legend 2''00FF00'));

echo 
'<img src="' $pChart->render() . '" alt="" />'
Attached Files
File Type: zip TalkPHP GoogleChart v0.1.zip (129.5 KB, 366 views)
File Type: zip TalkPHP GoogleChart v0.2.zip (16.8 KB, 368 views)
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Last edited by Karl : 02-01-2008 at 01:17 PM.
Karl is offline  
Reply With Quote
The Following 8 Users Say Thank You to Karl For This Useful Post:
adamcharnock (03-28-2008), Alan @ CIT (02-01-2008), bdm (12-11-2007), codefreek (06-26-2008), maZtah (12-11-2007), mortisimus (12-14-2007), sketchMedia (12-12-2007), thrash56 (02-01-2008)
Old 12-11-2007, 12:13 PM   #2 (permalink)
The Acquainted
 
Join Date: Oct 2007
Posts: 170
Thanks: 18
maZtah is an unknown quantity at this point
Default

Great script Karl! It's just so advanced, I might have a good read-through :).

Thanks for sharing this with us!
maZtah is offline  
Reply With Quote
Old 12-11-2007, 12:32 PM   #3 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Yes it does use a lot of advanced theories and practices. Feel free to ask any questions and I'll do my best to answer them.
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
The Following User Says Thank You to Karl For This Useful Post:
Rendair (12-11-2007)
Old 12-11-2007, 01:17 PM   #4 (permalink)
The Addict
Upcoming Programmer Top Contributor 
 
Rendair's Avatar
 
Join Date: Nov 2007
Location: UK
Posts: 319
Thanks: 18
Rendair is on a distinguished road
Default

Nice scripts does, i might have to write a tutorial on writting them advance graphing in GD lol.
__________________
www.jooney.co.uk - the online portfolio
Send a message via MSN to Rendair
Rendair is offline  
Reply With Quote
Old 12-11-2007, 01:30 PM   #5 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

I'm assuming this is for greater flexibility, but why:
PHP Code:
echo '<img src="' $pChart->render() . '" alt="" />'
As opposed to making GoogleChart::render() return it.
bdm is offline  
Reply With Quote
Old 12-11-2007, 02:30 PM   #6 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Basically because I didn't want to mix presentation logic with the core class. Slight inconvenience, but I personally prefer it like this (a lot of other people follow this approach too).
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Old 12-11-2007, 02:47 PM   #7 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

Make sense.

I guess you then have the choice to give that image an id or class.

Thanks.
bdm is offline  
Reply With Quote
Old 12-11-2007, 03:35 PM   #8 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Why have you commented out the following line in your class constants?

php Code:
const TYPE_BAR_HEIGHT   = 'bh';
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-11-2007, 03:52 PM   #9 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Why have you commented out the following line in your class constants?

php Code:
const TYPE_BAR_HEIGHT   = 'bh';
I left it commented because I've not supported it yet. It's also not actually a "type" of chart, so I'm not sure what to do with it yet, need to read over the docs a little more first. I've left it there to remind me to deal with it
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Old 12-11-2007, 03:47 PM   #10 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

Here's a quicky on how to make a transparent backgroun: http://alblue.blogspot.com/2007/12/u...in-google.html
bdm is offline  
Reply With Quote
The Following User Says Thank You to bdm For This Useful Post:
Karl (12-11-2007)
Old 12-12-2007, 08:01 PM   #11 (permalink)
The Visitor
 
Join Date: Dec 2007
Posts: 3
Thanks: 0
jaugusto is on a distinguished road
Default

Great! So it was you who make the first wraper for it!

What I don’t like about Google chart API is the fact axis don’t have nothing to do with values.

Thus, in order for a simple x,y graph to make sense, you have to find the percentage of all your values and then plot them. I mean, if your max value is 150, you must make 150=100% and then calculate all values below it in terms of percentage. Your laber on the x axe will be 150, but your value will be 100%.

Also: it does not work on forums with the [IMG] tag…

It would be usefull for the PHP class to load the url as binary and outputs it as .png, so that it can be recognized everywhere.
jaugusto is offline  
Reply With Quote
Old 12-14-2007, 02:02 PM   #12 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Aye, we made the first wrapper and the BEST wrapper! Although I'd stick around as we'll be adding onto it constantly for the next few weeks.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-14-2007, 03:20 PM   #13 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Aye, we made the first wrapper and the BEST wrapper! Although I'd stick around as we'll be adding onto it constantly for the next few weeks.
I beat you to it by days and days, but I'm too scrooge-like to release it into the wild. Good job Karl
Salathe is offline  
Reply With Quote
Old 12-20-2007, 06:51 AM   #14 (permalink)
The Visitor
 
Join Date: Dec 2007
Posts: 3
Thanks: 0
jaugusto is on a distinguished road
Default

Hello! Any update?!
jaugusto is offline  
Reply With Quote
Old 12-20-2007, 12:29 PM   #15 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

No update yet You're going to have to wait a couple of weeks until Christmas period is over! Although Karl's done the extended stuff - not sure if he's released it yet.

What are you waiting on exactly, jaugusto?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 01-07-2008, 05:00 AM   #16 (permalink)
The Visitor
 
Join Date: Dec 2007
Posts: 3
Thanks: 0
jaugusto is on a distinguished road
Default

Thanks for the reply. Waiting on what I posted above ;)

The image generation(to use on forums) and the max value setting.

Merry Cristmas and a Happy New Year, BTW.
jaugusto is offline  
Reply With Quote
Old 01-07-2008, 11:52 AM   #17 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

I'll get round to releasing an update sometime this week, thanks for checking it out.
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Old 02-01-2008, 05:06 AM   #18 (permalink)
The Visitor
 
thrash56's Avatar
 
Join Date: Feb 2008
Posts: 1
Thanks: 1
thrash56 is on a distinguished road
Default

Excellent script, thank you so much for creating it. It is extremely simple to understand and very expandable.

If anyone is having trouble trying to switch encoding on the chart data, there is a small bug that needs correction in the ./GoogleChart.php file. Function setDataEncoding is missing a "m_" before "szDataEnocding." An example of the fix is below.

Code:
	public function setDataEncoding($szEncoding = self::SIMPLE_ENCODING)
	{
		$this->m_szDataEncoding = $szEncoding;
		return $this;
	}
thrash56 is offline  
Reply With Quote
Old 02-01-2008, 12:15 PM   #19 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Thanks for reporting that. I really should do some more work on this script, I promised jugusto I would release an update weeks ago.
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Old 02-01-2008, 01:22 PM   #20 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

I've just released v0.2. I would have liked to have spent more time on it but I', unfortunately extremely busy at the moment. Maybe some of our fellow coders can contribute? Failing that, you'll just have to bear with me and I'll try to get another release out within a month.
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.talkphp.com/script-giveaway/1704-googlecharts.html
Posted By For Type Date
Advanced PHP Wrapper Class for Google Charts This thread Refback 01-11-2008 03:55 PM
Untitled document This thread Refback 01-10-2008 02:57 PM
Google Charts and Graphs | MindTouch Blog This thread Refback 01-08-2008 02:54 PM
Untitled document This thread Refback 01-08-2008 02:11 PM
Advanced PHP Wrapper Class for Google Charts This thread Refback 01-08-2008 04:08 AM
NamePros.Com - Advanced PHP Wrapper Class for Google Charts This thread Refback 01-08-2008 03:40 AM
g :: Google Chart API Revisited This thread Refback 01-06-2008 11:03 PM
Untitled document This thread Refback 01-05-2008 06:06 PM
Creating Charts - SitePoint Forums This thread Refback 01-03-2008 11:36 PM
Untitled document This thread Refback 01-03-2008 09:52 AM
Untitled document This thread Refback 12-30-2007 08:11 AM
PHP / Javascript Wrappers for Google | David Bisset: Web Designer, Coder, Wordpress Guru This thread Refback 12-28-2007 06:15 PM
Dynamic Google Charting API - Google Blogoscoped Forum This thread Refback 12-26-2007 08:56 PM
Create Charts Online with Google Chart API This thread Refback 12-26-2007 08:28 PM
Untitled document This thread Refback 12-26-2007 05:00 PM
Untitled document This thread Refback 12-26-2007 11:23 AM
Javascript | David Bisset: Web Designer, Coder, Wordpress Guru This thread Refback 12-26-2007 03:31 AM
Phil Windley's Technometria | Google Chart API This thread Refback 12-25-2007 02:29 AM
24 ways: Tracking Christmas Cheer with Google Charts This thread Refback 12-22-2007 11:10 PM
Google Chart API released - Download Squad This thread Refback 12-22-2007 04:07 PM
Untitled document This thread Refback 12-21-2007 10:51 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:34 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design