0% found this document useful (0 votes)
622 views

PHPGraphLib Examples

PHPGraphLib Examples
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
622 views

PHPGraphLib Examples

PHPGraphLib Examples
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

10/ 6/ 12

PH PG r aphLi b Exam pl es

Home PHPGraphLib Graphing Library

PHPGraphLib Examples
Tw eet 12 Like 22

See what PHPGraphLib can do in the below examples! For more details on the functions used below, check the Function Reference section of the documentation.

On the Web
See PHPGraphLib in a commercial use web application that graphs infrared measurements of Soya! In Dutch, credit: Joost Ruis. WMV Video (1.3mb) or AVI Video (3.75mb)

Example 1
Code: 1 2 3 4 5 6 7 8 9 1 0 < ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; $ g r a p h=n e wP H P G r a p h L i b ( 5 0 0 , 3 5 0 ) ; $ d a t a=a r r a y ( 1 2 1 2 4 ,5 5 3 5 ,4 3 3 7 3 ,2 2 2 2 3 ,9 0 4 3 2 ,2 3 3 3 2 ,1 5 5 4 4 ,2 4 5 2 3 , 3 2 7 7 8 ,3 8 8 7 8 ,2 8 7 8 7 ,3 3 2 4 3 ,3 4 8 3 2 ,3 2 3 0 2 ) ; $ g r a p h > a d d D a t a ( $ d a t a ) ; $ g r a p h > s e t T i t l e ( ' W i d g e t sP r o d u c e d ' ) ; $ g r a p h > s e t G r a d i e n t ( ' r e d ' ,' m a r o o n ' ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

Result Graph:

w w w . ebr ueggem an. com / phpgr aphl b/ exam pl i es

1/ 8

10/ 6/ 12

PH PG r aphLi b Exam pl es

Example 2
Code: 1 2 3 4 5 6 7 8 9 1 0 1 1 < ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; $ g r a p h=n e wP H P G r a p h L i b ( 5 0 0 , 4 5 0 ) ; $ d a t a=a r r a y ( " J a n " = > 1 3 2 4 ," F e b " = > 1 2 0 0 ," M a r " = > 1 0 0 ," A p r " = > 1 9 2 5 ," M a y " = > 1 4 4 4 , " J u n " = > 9 5 7 ," J u l " = > 3 6 4 ," A u g " = > 2 2 1 ," S e p " = > 1 3 0 0 ," O c t " = > 8 4 8 ," N o v " = > 7 1 9 ," D e c " = > 1 1 4 ) ; $ g r a p h > a d d D a t a ( $ d a t a ) ; $ g r a p h > s e t B a r C o l o r ( ' 2 5 5 , 2 5 5 , 2 0 4 ' ) ; $ g r a p h > s e t T i t l e ( ' M o n e yM a d ea tX Y ZC o r p ' ) ; $ g r a p h > s e t T e x t C o l o r ( ' g r a y ' ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

Result Graph:

Example 3
Code: 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6
w w w . ebr ueggem an. com / phpgr aphl b/ exam pl i es

< ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; $ g r a p h=n e wP H P G r a p h L i b ( 3 5 0 , 2 8 0 ) ; $ d a t a=a r r a y ( " R o g e r " = > 1 4 5 ," R a l p h " = > 1 0 2 ," R h o n d a " = > 1 2 3 ," R o n a l d o " = > 1 3 7 , " R o s a r i o " = > 1 4 9 ," R o b i n " = > 9 9 ," R o b e r t " = > 8 8 ," R u s t o f " = > 1 1 1 ) ; $ g r a p h > s e t B a c k g r o u n d C o l o r ( " b l a c k " ) ; $ g r a p h > a d d D a t a ( $ d a t a ) ; $ g r a p h > s e t B a r C o l o r ( ' 2 5 5 , 2 5 5 , 2 0 4 ' ) ; $ g r a p h > s e t T i t l e ( ' I QS c o r e s ' ) ; $ g r a p h > s e t T i t l e C o l o r ( ' y e l l o w ' ) ; $ g r a p h > s e t u p Y A x i s ( 1 2 ,' y e l l o w ' ) ; $ g r a p h > s e t u p X A x i s ( 2 0 ,' y e l l o w ' ) ; $ g r a p h > s e t G r i d ( f a l s e ) ; $ g r a p h > s e t G r a d i e n t ( ' s i l v e r ' ,' g r a y ' ) ; $ g r a p h > s e t B a r O u t l i n e C o l o r ( ' w h i t e ' ) ; $ g r a p h > s e t T e x t C o l o r ( ' w h i t e ' ) ;
2/ 8

10/ 6/ 12

PH PG r aphLi b Exam pl es

1 7 1 8 1 9 2 0 2 1 2 2

$ g r a p h > s e t D a t a P o i n t s ( t r u e ) ; $ g r a p h > s e t D a t a P o i n t C o l o r ( ' y e l l o w ' ) ; $ g r a p h > s e t L i n e ( t r u e ) ; $ g r a p h > s e t L i n e C o l o r ( ' y e l l o w ' ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

Result Graph:

Example 4
Code: 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 < ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; $ g r a p h = n e wP H P G r a p h L i b ( 5 2 0 , 2 8 0 ) ; $ d a t a = a r r a y ( " A l p h a "= >1 1 4 5 ," B e t a "= >1 2 0 2 ," C a p p a "= >1 5 2 3 , " D e l t a "= >1 4 3 7 ," E c h o "= >9 4 9 ," F a l c o n "= >9 9 9 ," G a m m a "= >1 1 8 8 ) ; $ d a t a 2 = a r r a y ( " A l p h a "= >8 9 8 ," B e t a "= >1 4 9 8 ," C a p p a "= >1 3 4 3 , " D e l t a "= >1 3 4 5 ," E c h o "= >1 0 4 5 ," F a l c o n "= >1 3 4 3 ," G a m m a "= >9 8 7 ) ; $ g r a p h > a d d D a t a ( $ d a t a ,$ d a t a 2 ) ; $ g r a p h > s e t B a r C o l o r ( ' b l u e ' ,' g r e e n ' ) ; $ g r a p h > s e t T i t l e ( ' C o m p a n yP r o d u c t i o n ' ) ; $ g r a p h > s e t u p Y A x i s ( 1 2 ,' b l u e ' ) ; $ g r a p h > s e t u p X A x i s ( 2 0 ) ; $ g r a p h > s e t G r i d ( f a l s e ) ; $ g r a p h > s e t L e g e n d ( t r u e ) ; $ g r a p h > s e t T i t l e L o c a t i o n ( ' l e f t ' ) ; $ g r a p h > s e t T i t l e C o l o r ( ' b l u e ' ) ; $ g r a p h > s e t L e g e n d O u t l i n e C o l o r ( ' w h i t e ' ) ; $ g r a p h > s e t L e g e n d T i t l e ( ' W e e k 3 7 ' ,' W e e k 3 8 ' ) ; $ g r a p h > s e t X V a l u e s H o r i z o n t a l ( t r u e ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

Result Graph:

w w w . ebr ueggem an. com / phpgr aphl b/ exam pl i es

3/ 8

10/ 6/ 12

PH PG r aphLi b Exam pl es

Example 5
Code: 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 < ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; $ g r a p h = n e wP H P G r a p h L i b ( 5 0 0 , 2 8 0 ) ; $ d a t a=a r r a y ( 2 3 ,4 5 ,2 0 ,4 4 ,4 1 ,1 8 ,4 9 ,1 9 ,4 2 ) ; $ d a t a 2=a r r a y ( 1 5 ,2 3 ,2 3 ,1 1 ,5 4 ,2 1 ,5 6 ,3 4 ,2 3 ) ; $ d a t a 3=a r r a y ( 4 3 ,2 3 ,3 4 ,2 3 ,5 3 ,3 2 ,4 3 ,4 1 ) ; $ g r a p h > a d d D a t a ( $ d a t a ,$ d a t a 2 ,$ d a t a 3 ) ; $ g r a p h > s e t T i t l e ( ' C P UC y c l e sx 1 0 0 0 ' ) ; $ g r a p h > s e t T i t l e L o c a t i o n ( ' l e f t ' ) ; $ g r a p h > s e t L e g e n d ( t r u e ) ; $ g r a p h > s e t L e g e n d T i t l e ( ' M o d u l e 1 ' ,' M o d u l e 2 ' ,' M o d u l e 3 ' ) ; $ g r a p h > s e t G r a d i e n t ( ' g r e e n ' ,' o l i v e ' ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

Result Graph:

Example 6
Code: 1 2 3
w w w . ebr ueggem an. com / phpgr aphl b/ exam pl i es

< ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; $ g r a p h=n e wP H P G r a p h L i b ( 4 5 0 , 3 0 0 ) ;


4/ 8

10/ 6/ 12

PH PG r aphLi b Exam pl es

4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9

$ d a t a=a r r a y ( " J a n "= >1 0 . 1 ," F e b "= >3 . 6 ," M a r "= >1 1 . 0 ," A p r "= >3 0 . 7 , " M a y "= >4 8 . 6 ," J u n "= >5 9 . 8 ," J u l "= >6 2 . 5 ," A u g "= >5 6 . 8 ," S e p "= >4 5 . 5 , " O c t "= >2 5 . 1 ," N o v "= >2 . 7 ," D e c "= >6 . 5 ) ; $ g r a p h > a d d D a t a ( $ d a t a ) ; $ g r a p h > s e t B a r C o l o r ( ' n a v y ' ) ; $ g r a p h > s e t u p X A x i s ( 2 0 ,' b l u e ' ) ; $ g r a p h > s e t T i t l e ( ' A v e r a g eT e m p e r a t u r eb yM o n t h ,i nF a i r b a n k sA l a s k a ' ) ; $ g r a p h > s e t T i t l e C o l o r ( ' b l u e ' ) ; $ g r a p h > s e t G r i d C o l o r ( ' 1 5 3 , 2 0 4 , 2 5 5 ' ) ; $ g r a p h > s e t D a t a V a l u e s ( t r u e ) ; $ g r a p h > s e t D a t a V a l u e C o l o r ( ' n a v y ' ) ; $ g r a p h > s e t D a t a F o r m a t ( ' d e g r e e s ' ) ; $ g r a p h > s e t G o a l L i n e ( ' 3 2 ' ) ; $ g r a p h > s e t G o a l L i n e C o l o r ( ' r e d ' ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

Result Graph:

Example 7
Code: 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 < ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; $ g r a p h=n e wP H P G r a p h L i b ( 6 5 0 , 2 0 0 ) ; $ d a t a=a r r a y ( " 1 "= >. 0 0 3 2 ," 2 "= >. 0 0 2 8 ," 3 "= >. 0 0 2 1 ," 4 "= >. 0 0 3 3 , " 5 "= >. 0 0 3 4 ," 6 "= >. 0 0 3 1 ," 7 "= >. 0 0 3 6 ," 8 "= >. 0 0 2 7 ," 9 "= >. 0 0 2 4 , " 1 0 "= >. 0 0 2 1 ," 1 1 "= >. 0 0 2 6 ," 1 2 "= >. 0 0 2 4 ," 1 3 "= >. 0 0 3 6 , " 1 4 "= >. 0 0 2 8 ," 1 5 "= >. 0 0 2 5 ) ; $ g r a p h > a d d D a t a ( $ d a t a ) ; $ g r a p h > s e t T i t l e ( ' P P MP e rC o n t a i n e r ' ) ; $ g r a p h > s e t B a r s ( f a l s e ) ; $ g r a p h > s e t L i n e ( t r u e ) ; $ g r a p h > s e t D a t a P o i n t s ( t r u e ) ; $ g r a p h > s e t D a t a P o i n t C o l o r ( ' m a r o o n ' ) ; $ g r a p h > s e t D a t a V a l u e s ( t r u e ) ; $ g r a p h > s e t D a t a V a l u e C o l o r ( ' m a r o o n ' ) ; $ g r a p h > s e t G o a l L i n e ( . 0 0 2 5 ) ; $ g r a p h > s e t G o a l L i n e C o l o r ( ' r e d ' ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

Result Graph:

w w w . ebr ueggem an. com / phpgr aphl b/ exam pl i es

5/ 8

10/ 6/ 12

PH PG r aphLi b Exam pl es

Example 8
Code: 1 2 3 4 5 6 7 8 9 1 0 1 1 < ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; i n c l u d e ( ' p h p g r a p h l i b _ p i e . p h p ' ) ; $ g r a p h=n e wP H P G r a p h L i b P i e ( 4 0 0 ,2 0 0 ) ; $ d a t a=a r r a y ( " C B S "= >6 . 3 ," N B C "= >4 . 5 , " F O X "= >2 . 8 ," A B C "= >2 . 7 ," C W "= >1 . 4 ) ; $ g r a p h > a d d D a t a ( $ d a t a ) ; $ g r a p h > s e t T i t l e ( ' 8 / 2 9 / 0 7T o p5T VN e t w o r k sM a r k e tS h a r e ' ) ; $ g r a p h > s e t L a b e l T e x t C o l o r ( ' 5 0 , 5 0 , 5 0 ' ) ; $ g r a p h > s e t L e g e n d T e x t C o l o r ( ' 5 0 , 5 0 , 5 0 ' ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

Result Graph:

Example 9
Code: 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 < ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; $ g r a p h=n e wP H P G r a p h L i b ( 4 9 5 , 2 8 0 ) ; $ d a t a=a r r a y ( ' a l p h a ' = > 2 3 ,' b e t a ' = > 4 5 ,' c a p p a ' = > 2 0 ,' d e l t a ' = > 3 2 ,' e c h o ' = > 1 4 ) ; $ d a t a 2=a r r a y ( ' a l p h a ' = > 1 5 ,' b e t a ' = > 2 3 ,' c a p p a ' = > 2 3 , ' d e l t a ' = > 1 2 ,' e c h o ' = > 1 7 ) ; $ d a t a 3=a r r a y ( ' a l p h a ' = > 4 3 ,' b e t a ' = > 2 3 ,' c a p p a ' = > 3 4 ,' d e l t a ' = > 1 6 ,' e c h o ' = > 2 0 ) ; $ d a t a 4=a r r a y ( ' a l p h a ' = > 2 3 ,' b e t a ' = > 3 4 ,' c a p p a ' = > 2 3 ,' d e l t a ' = > 9 ,' e c h o ' = > 8 ) ; $ g r a p h > a d d D a t a ( $ d a t a ,$ d a t a 2 ,$ d a t a 3 ,$ d a t a 4 ) ; $ g r a p h > s e t u p Y A x i s ( " 1 5 " ) ; $ g r a p h > s e t G r a d i e n t ( ' t e a l ' ,' # 0 0 0 0 F F ' ) ; $ g r a p h > s e t X V a l u e s H o r i z o n t a l ( t r u e ) ; $ g r a p h > s e t X A x i s T e x t C o l o r( ' n a v y ' ) ; $ g r a p h > s e t L e g e n d ( t r u e ) ; $ g r a p h > s e t L e g e n d T i t l e ( ' M 1 ' ,' M 2 ' ,' M 3 ' ,' M 4 ' ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

w w w . ebr ueggem an. com / phpgr aphl b/ exam pl i es

6/ 8

10/ 6/ 12

PH PG r aphLi b Exam pl es

Result Graph:

Example 10
Code: 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 < ? p h p i n c l u d e ( ' p h p g r a p h l i b . p h p ' ) ; i n c l u d e ( ' p h p g r a p h l i b _ s t a c k e d . p h p ' ) ; $ g r a p h=n e wP H P G r a p h L i b S t a c k e d ( 5 0 0 , 3 0 0 ) ; $ p o p u l a r i t y=a r r a y ( ' W i n d o w s7 ' = > 8 0 ,' M a cO S1 0 ' = > 3 5 ,' F e d o r a ' = > 9 ) ; $ c o s t=a r r a y ( ' W i n d o w s7 ' = > 1 0 ,' M a cO S1 0 ' = > 3 0 ,' F e d o r a ' = > 9 0 ) ; $ s p e e d=a r r a y ( ' W i n d o w s7 ' = > 5 0 , ' M a cO S1 0 ' = > 5 0 , ' F e d o r a ' = > 8 0 ) ; $ g r a p h > a d d D a t a ( $ p o p u l a r i t y ,$ c o s t ,$ s p e e d ) ; $ g r a p h > s e t T i t l e ( ' O p e r a t i n gS y s t e mS c o r e s ' ) ; $ g r a p h > s e t T i t l e L o c a t i o n ( ' l e f t ' ) ; $ g r a p h > s e t X V a l u e s H o r i z o n t a l ( T R U E ) ; $ g r a p h > s e t T e x t C o l o r ( ' b l u e ' ) ; $ g r a p h > s e t B a r C o l o r ( ' # 0 0 6 6 C C ' ,' # 6 6 9 9 9 9 ' ,' # 6 6 C C C C ' ) ; $ g r a p h > s e t L e g e n d ( T R U E ) ; $ g r a p h > s e t L e g e n d T i t l e ( ' P o p u l a r i t y ' ,' C o s t ' ,' S p e e d ' ) ; $ g r a p h > c r e a t e G r a p h ( ) ; ? >

Result Graph:

w w w . ebr ueggem an. com / phpgr aphl b/ exam pl i es

7/ 8

10/ 6/ 12

PH PG r aphLi b Exam pl es

Home | PHPGraphLib | SkinnyTip | PHPWeatherLib | Web Development Blog Site content copyright Elliott Brueggeman, 2011.

w w w . ebr ueggem an. com / phpgr aphl b/ exam pl i es

8/ 8

You might also like