PHP头条
热点:

使用PHP绘制统计图


使用PHP画统计图的方法

第一种方法 

= 300 = 300 = 0; = 10; = 0; =0; =0; =(); =(); =(255,255,255); =(192,192,192); =(0,0,255); =(255,0,0); =(0,0,255); =(200,200,255); = (138,138,120); = (30,30,30); = ("ee00ff","dd8800","00ff00","104E8B" ; ; = ''; = '' add_data(, = 0(!( = (!() or (->array_error['add_data']="没有可供分析的数据" ( == 0 || (, -> = (->->array_data[] = set_img(,->graphwidth = ->graphheight = set_height_num(->height_num= get_RGB(){ =(>>16) & 0xff=(>>8) & 0xff=() & 0xff ((,, set_color_bg(,,->colorBg=(,, set_color_Grey(,,->colorGrey=(,, set_color_Blue(,,->colorBlue=(,, set_color_Red(,,->colorRed=(,, set_color_DarkBlue(,,->colorDarkBlue=(,, set_color_LightBlue(,,->colorLightBlue=(,, setLineStrinType((!(, ('day', 'hour' ->lineType = = (->array_data => [] = (->width_num = ( = (->array_data []= ((([0 = [0->height_max = () + -> ( = -> = (/-> = (,0,1((,1,1((,1,1)>=5 += 1( = 1; < (); ++ .= "0" (int) get_var_wh(){ -> ->height_var = ->->width_var = (->graphwidth/->width_num, 3 set_colors( ->array_color = (",", set_begin_day((!( ->beginDay = build_line((!()){ [0] = ->array_data[-1->array_data = (=0;<(->array_data);++(,,)=->get_RGB((->array_color[=imagecolorallocate(->image,,,( = 0; < ->width_num - 1;++ = ((->array_data[][]/->height_max)*-> = (->array_data[][ + 1]/->height_max*->->image,->width_var*( + 1),->graphheight-,->width_var*( + 2),->graphheight-, = imagecolorallocate(->image, ->colorBlue[0], ->colorBlue[1], ->colorBlue[2( = 0; < (->array_data); ++(,,) = ->get_RGB((->array_color[ = imagecolorallocate(->image,,,( = 0; < ->width_num; ++((->array_data[][ = ((->array_data[][]/->height_max)*-> = imagearc(->image,->width_var*( + 1),->graphheight-,6,5,0,360, = imagefilltoborder(->image,->width_var*( + 1),->graphheight-,,(! || !( = 0; < (->array_data); ++(,,) = ->get_RGB((->array_color[ = imagecolorallocate(->image,,,( = 0; < ->width_num; ++ = ((->array_data[][]/->height_max) * -> = imagearc(->image,->width_var*( + 1),->graphheight-,6,5,0,360, = imagefilltoborder(->image,->width_var*( + 1),->graphheight-,,(! || ! build_rectangle((!()){ -=1 =imagecolorallocate(->image, ->colorDarkBlue[0], ->colorDarkBlue[1], ->colorDarkBlue[2=imagecolorallocate(->image, ->colorLightBlue[0], ->colorLightBlue[1], ->colorLightBlue[2((=0(=0; <->width_num; ++=((->array_data[][]/->height_max)*->->image,->width_var*,->graphheight-,->width_var*(+1),->graphheight, ->image,(*->width_var)+1,(->graphheight-)+1,->width_var*(+1)-5,->graphheight-2, ->image = imagecreate(->graphwidth+20,->graphheight+20 -> =imagecolorallocate(->image, ->colorBg[0], ->colorBg[1], ->colorBg[2=imagecolorallocate(->image, ->colorGrey[0], ->colorGrey[1], ->colorGrey[2 imageline(->image, 0, 0, 0, ->graphheight,->image, 0, 0, ->graphwidth, 0, imageline(->image, 0,(->graphheight-1),(->graphwidth-1),(->graphheight-1), -> = imagecolorallocate(->image, ->colorBg[0], ->colorBg[1], ->colorBg[2 = imagecolorallocate(->image, ->colorGrey[0], ->colorGrey[1], ->colorGrey[2 = imagecolorallocate(->image, ->colorRed[0], ->colorRed[1], ->colorRed[2 = imagecolorallocate(->image, ->colorLightBlack[0], ->colorLightBlack[1], ->colorLightBlack[2 = imagecolorallocate(->image, ->colorBlack[0], ->colorBlack[1], ->colorBlack[2( = 1 ; <= ->height_num + 5; ++ imageline(->image,0,->graphheight-(->height_var/->height_max*->graphheight)*,->graphwidth,->graphheight-(->height_var/->height_max*->graphheight)*, imagestring(->image,2,0,->graphheight-(->height_var/->height_max*->graphheight)*,->height_var*, = ->( == "day"(-> = -> = 1( == "hour" = 0( = 1; <= ->width_num; ++ imageline(->image,->width_var*,0,->width_var*,->graphwidth, ( == 'day'( == 1->image,2,->width_var*,->graphheight-15,,->image,2,->width_var*( + 1),->graphheight-15, + 1,( == 'hour'( == 1->image,2,->width_var*,->graphheight-15,,->image,2,->width_var*( + 1),->graphheight-15, + 1,->image,2,->width_var*( + 1),->graphheight-15,,++( == "day" && == 31 = 1( == "hour" && == 23 = -1 build(,, = "" ((("Content-type: image/jpeg"->create_cloths(); ( "line": ->create_frame(); ->create_line(); ->build_line(); "rectangle": ->create_frame(); ->build_rectangle(); ->create_line(); (!(->image, ->-> View Code

 

 

第二种是用开源工具jpgraph,参见 http://jpgraph.net/features

 

Chart Gallery

Line / Area

Line / Area
  • Line Plots
  • Filled Line Plots
  • Step Line Plots
  • Line Plots With Markers
  • Line Plots With Inverted Y-axis
  • Line Plots With Values

Bar

Bar
  • Standard Bar plots
  • Horizontal Bar plots
  • Adding backgrounds and patterns to bar plots
  • Combined Line and Bar plots

Pie

Pie
  • Pie Plots
  • 3D Pie plots
  • Exploding Pie plots

Scatter

Scatter

Impluse

Impluse

Field

Field

Splines

Splines

Geo Maps

Geo Maps

Stock

Stock

Polar

Polar

Error

Error

Balloon

Balloon

Radar

Radar

Contour

Contour

Others(Pro ver.)

Others(Pro ver.)

 

General features

Below is a number of "one-liners" that describe some of the general features available in JpGraph.

  • Anti-aliasing for Pie charts.
  • More advanced formatting of graph titles including 3D Bevel effects.
  • Additional 3D Bevel formatting feature for the entire Graph
  • Gradient fills for bars are now also displayed in the legend
  • Improvements on legend formatting. It is now possible to have several columns in the legend
  • Improved callback capability for Plot marks. The new callbacks will provide both X and Y coordinates.
  • Footer text can now be used on all graph types
  • dded possibility to use the Freely available Vera TTF fonts. These fonts are available from http://www.gnome.org/fonts/
  • Built in rotation of graphs
  • Fine tuning of legend layout, size and positioning of individual legends and markers.
  • Added possibility to use object methods as callbacks and not only static global functions
  • Full support for color alpha blending
  • Automatic generation of client side image maps to make it possible to generate drill-down graphs.
  • Advanced interpolation with cubic splines to get smooth curves from just a few data points.
  • Several different fill styles for line plots
  • Advanced image 3D effects built-in without external image manipulation programs
  • Supports unlimited number of plots in each graph, makes it easy to compose complex graph which consists of several plot types
  • Additional built-in images for plot marks including 3D rendered markers like diamonds, squares, bevels, balls, pins etc
  • Text strings can now be added to the plot using scale coordinates
  • Support for all primitive URL parameter types with CSIM graphs.
  • Autoscaling will now also consider added lines and texts.
  • Hare/Niemeyer Integer compensation for Pie Plots
  • Added the possibility to use Vertical Gradient fill for line plots.
  • Improved error handling. The visual appearance of the error handling now tries to mimic any windows system window (in graphic)
  • Builtin support to display over 200 country flag and the possibility to use them as icons or markers in the graphs. All the flag images are builtin with JpGraph in an efficient pre-compiled data format.
  • Supports caching (with timeout) of generated graphs to lessen burden of a HTTP server.
  • Intelligent autoscaling which gravitates towards aesthetical values.
  • Fully supports manual scaling, with fine grain control of position of ticks
  • Supports color-gradient fill for bar graphs
  • Supports both vertical and horizontal grids (with image depth specification)
  • Supports both on-the fly image generation and batch processing.
  • Extensive documentation
  • Advanced text formatting using TTF fonts
  • Support for both Chinese and Japanes character sets 

非常多的例子,很好的。

 

第三种用 open flash chart,参见

http://teethgrinder.co.uk/open-flash-chart/gallery-data.php
http://www.helloweba.com/view-blog-41.html
http://www.phphi.cn/post/98/
http://blogold.chinaunix.net/u3/105169/showart_2322209.html
http://hi.baidu.com/duwuzhe722/blog/item/e11b2d2662b512038b82a175.html

 

第四种使用amcharts,参见http://www.amcharts.com

www.phpzy.comtrue/php/1985.htmlTechArticle使用PHP绘制统计图 使用PHP画统计图的方法 第一种方法 = 300 = 300 = 0; = 10; = 0; =0; =0; = (); = (); = (255,255,255); = (192,192,192); = (0,0,255); = (255,0,0); = (0,0,255); = (200,200,255); = (138,138,120); = (30,30,30);...

相关文章

相关频道:

PHP之友评论

今天推荐