Function of the column graph
Source of: white Popularity: 3905
# For convenience, I have made a function to make column map / * Parameter description: $ graphdata: percentage data (Y-axis) $ label: x-axis title $ data: actual data (Y axis) $ graphwidth: Image width $ graphHeight: Image height $ graphscale: Height factor ($ graphHeight / 100) $ graphfont: Font number $ bg; background color value $ grid: Word color value $ bar: Column color value $ BZ: Remarks (not supported Chinese) * / Function TIMAGE ($ Graphdata, $ Label, $ DATA, $ GRAPHSCALE, $ GRAPHFONT, $ BG, $ TEXT, $ GRID, $ BAR, $ BZ) {Header ("Content-Type: Image / GIF"); $ image = imagecreate ($ GraphWidth 50, $ GRAPHHEIGHT 50); $ bgcolor = imagecoloralloccate ($ image, $ bg [0], $ bg [1], $ bg [2]); $ TEXTCOLOR = ImageColoralLocate ($ text [0], $ text [1], $ text [2]); $ GridColor = ImageColoralLocate ($ image, $ grid [0], $ grid [1 ], $ Grid [2]); $ Barcolor = ImageColorAllocate ($ BAR [0], $ BAR [1], $ BAR [2]); $ Gridabelwidth = ImageFontWidth ($ graphfont) * 3 1; $ gridableheight = imagefontheight ($ graphfont); imageline ($ image, $ gridlabelwidth, 0, $ gridlabelwidth, $ graphheight-1, $ gridcolor); imageline ($ image, 0, $ graphheight-1, $ graphwidth-1, $ graphheight- 1, $ GridColor; for ($ I = 0; $ I <$ graphHeight; $ i = $ graphheight / 10) {image, 0, $ i, $ graphwidt H-1, $ I, $ GridColor; ImageString ($ IMAGE, $ GRAPHFONT, 0, $ I, ROUND ($ GRAPHHEIGHT- $ I) / $ GRAPHSCALE), $ TEXTCOLOR);} $ barwidth = (($ graphwidth $ Gridlabelwidth / Count ($ graphdata)) - 30; # ¿ ØöööμÄ × ü¿ í¶èfor ($ i = 0; $ i {$ Bartopx = $ Gridlabelwidth ($ I 1) * 20) ($ I * $ barwidth); # ¿Øööö¿¿ × ó ó¾¾¾ àà $ barbottomx = $ Bartopx $ Barwidth ; $ barbottomy = $ graphheight-1; # ¿ØÖÆÖùμÄÏ ± ß½ç $ bartopy = $ barbottomy - ($ graphdata [$ i] * $ graphscale); imagefilledrectangle ($ image, $ bartopx, $ bartopy, $ barbottomx, $ barbottomy, $ Barcolor); $ labelx1 = $ bartopx; $ labely1 = $ bartopy-15; $ labelx2 = $ bartopx; $ labely2 = $ graphheight; imageString ($ image, $ graphfont, $ labelx1, $ labely1, "