 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
|
 |
|
 |
12-11-2007, 12:05 PM
|
#1 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
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(200, 100)
->setGridLines(20, 20, 1, 5)
->setBackgroundFill(new GoogleChart_Fill_Solid('EFEFEF'))
->setChartFill(new GoogleChart_Fill_LinearGradient(0, '76A4FB', 0, 'ffffff', 1))
->addData(new GoogleChart_Data_Generic(array(0, 10, 40, 10), 'Legend 1', 'FF0000'))
->addData(new GoogleChart_Data_Generic(array(40, 20, 10, 20), 'Legend 2', '00FF00'));
echo '<img src="' . $pChart->render() . '" alt="" />';
__________________
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.
|
|
|
|
|
The Following 8 Users Say Thank You to Karl For This Useful Post:
|
|
12-11-2007, 12:13 PM
|
#2 (permalink)
|
|
The Acquainted
Join Date: Oct 2007
Posts: 172
Thanks: 18
|
Great script Karl! It's just so advanced, I might have a good read-through :).
Thanks for sharing this with us!
|
|
|
|
12-11-2007, 12:32 PM
|
#3 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
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.
|
|
|
|
|
The Following User Says Thank You to Karl For This Useful Post:
|
|
12-11-2007, 01:17 PM
|
#4 (permalink)
|
|
The Addict
Join Date: Nov 2007
Location: UK
Posts: 318
Thanks: 18
|
Nice scripts does, i might have to write a tutorial on writting them advance graphing in GD lol.
|
|
|
12-11-2007, 01:30 PM
|
#5 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Posts: 127
Thanks: 14
|
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.
|
|
|
|
12-11-2007, 02:30 PM
|
#6 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
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.
|
|
|
|
12-11-2007, 02:47 PM
|
#7 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Posts: 127
Thanks: 14
|
Make sense.
I guess you then have the choice to give that image an id or class.
Thanks.
|
|
|
|
12-11-2007, 03:35 PM
|
#8 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,210
Thanks: 90
|
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.
|
|
|
12-11-2007, 03:52 PM
|
#10 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
Quote:
Originally Posted by Wildhoney
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.
|
|
|
|
12-12-2007, 08:01 PM
|
#11 (permalink)
|
|
The Visitor
Join Date: Dec 2007
Posts: 3
Thanks: 0
|
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.
|
|
|
|
12-14-2007, 02:02 PM
|
#12 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,210
Thanks: 90
|
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.
|
|
|
12-14-2007, 03:20 PM
|
#13 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,234
Thanks: 3
|
Quote:
Originally Posted by Wildhoney
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@php.net
|
|
|
|
12-20-2007, 06:51 AM
|
#14 (permalink)
|
|
The Visitor
Join Date: Dec 2007
Posts: 3
Thanks: 0
|
Hello! Any update?!
|
|
|
|
12-20-2007, 12:29 PM
|
#15 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,210
Thanks: 90
|
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.
|
|
|
01-07-2008, 05:00 AM
|
#16 (permalink)
|
|
The Visitor
Join Date: Dec 2007
Posts: 3
Thanks: 0
|
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.
|
|
|
|
01-07-2008, 11:52 AM
|
#17 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
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.
|
|
|
|
02-01-2008, 05:06 AM
|
#18 (permalink)
|
|
The Visitor
Join Date: Feb 2008
Posts: 1
Thanks: 1
|
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;
}
|
|
|
|
02-01-2008, 12:15 PM
|
#19 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
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.
|
|
|
|
02-01-2008, 01:22 PM
|
#20 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
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.
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|