ecommerce website design Shropshire, Custom & Ecommerce Website Designers, Web Page Design Company Shropshire UK Site Map
Phone:01743 272 609 Fax: 0709 286 1166
Home page, website design service at Shrewsbury, Shropshire. We supply website design service to business in Shropshire and whole UKAbout spark computing, website design service at Shrewsbury, Shropshire. We supply website design service to business in Shropshire and whole UKExpertise and services from spark computing, website design service at Shrewsbury, Shropshire. We supply website design service to business in Shropshire and whole UKOffice automatic solutions, online business solutions supplied by Spark computing, shrewsbury, shropshirecontact spark computing, shrewsbury, shroshire to discuss online business websites, custom software development

Archives for: July 2009, 30

30/07/09

Permalink 11:31:28 pm, Categories: General IT articles  

Create data graph on the fly

Generating graph from data collected on the internet and shows it on the web can be very useful.
I found 2 ways to create data graph/chart on the fly:

1. Use the google api
http://code.google.com/apis/chart/basics.html

To create a simple pie chart, all you need is one line of html

XML:

<img src="http://chart.apis.google.com/chart?chs=350x100&amp;chd=t:60,40&amp;cht=p3&amp;chl=Web_designers|Programmers"  alt="Sample chart" />

And you will have
Sample chart

2. Use php + GD Library
to create the same chart you need the following codes. Codes are based on

http://www.talkphp.com/advanced-php-programming/2508-3d-pie-charts-php-gd.html

with small changes

PHP:

$image imagecreatetruecolor(300300);
// allocate some solors
$white    imagecolorallocate($image0xFF0xFF0xFF);
$gray     imagecolorallocate($image0xC00xC00xC0);
$darkgray imagecolorallocate($image0x900x900x90);
$navy     imagecolorallocate($image0x000x000x80);
$darknavy imagecolorallocate($image0x000x000x50);
$red      imagecolorallocate($image0xFF0x000x00);
$darkred  imagecolorallocate($image0x900x000x00);
 
//the white background will be transparent:
imageFill($image00$white);
imageColorTransparent($image$white);
 
 
for ($i 160$i 150$i--) {
   imagefilledarc($image150$i200100045$darknavyIMG_ARC_PIE);
   imagefilledarc($image150$i2001004575 $darkgrayIMG_ARC_PIE);
   imagefilledarc($image150$i20010075360 $darkredIMG_ARC_PIE);
}
 
imagefilledarc($image150150200100045$navyIMG_ARC_PIE);
imagefilledarc($image1501502001004575 $grayIMG_ARC_PIE);
imagefilledarc($image15015020010075360 $redIMG_ARC_PIE);
 
// flush image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);

If you need to know more about using GD Lib to create graph on the web, please visit a tutorial at

http://php.about.com/od/advancedphp/ss/gd_library_6.htm

You need to be careful when you are using server side script to generate graph as it is CPU intensive.


Tweet this! Facebook Live Yahoo bookmark Digg US google bookmark

July 2009
Mon Tue Wed Thu Fri Sat Sun
 << < Current> >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Spark Website Design, Shropshire

Technical articles on IT solutions.

Free information on office and home IT solutions; How to get a website running for your business; self-help e-commerce; and tips on website design.

Search

Misc

XML Feeds

What is this?