Namespace SamChristy
76 | 77 || SamChristy\PieChart | 81 |
├── src └── SamChristy │ └── PieChart │ ├── example │ ├── example.png │ └── example.php │ ├── fonts │ ├── Oswald │ │ ├── Oswald-Bold.ttf │ │ ├── Oswald-Light.ttf │ │ ├── Oswald-Regular.ttf │ │ └── OFL.txt │ └── Open_Sans │ │ ├── OpenSans-Bold.ttf │ │ ├── OpenSans-Regular.ttf │ │ ├── OpenSans-Semibold.ttf │ │ ├── OpenSans-ExtraBold.ttf │ │ └── LICENSE.txt │ ├── documentation │ ├── resources │ │ ├── sort.png │ │ ├── footer.png │ │ ├── inherit.png │ │ ├── resize.png │ │ ├── collapsed.png │ │ ├── tree-last.png │ │ ├── tree-cleaner.png │ │ ├── tree-hasnext.png │ │ ├── tree-vertical.png │ │ └── style.css │ ├── elementlist.js │ ├── namespace-SamChristy.html │ ├── package-None.html │ ├── index.html │ ├── 404.html │ ├── tree.html │ ├── package-PieChart.html │ ├── namespace-SamChristy.PieChart.html │ ├── function-imageSmoothArc.html │ ├── function-imageSmoothArcDrawSegment.html │ ├── class-PieChartColor.html │ ├── class-SamChristy.PieChart.PieChartColor.html │ ├── class-PieChartImagick.html │ ├── class-PieChartGD.html │ ├── class-SamChristy.PieChart.PieChartImagick.html │ ├── class-SamChristy.PieChart.PieChartGD.html │ └── class-PieChart.html │ ├── PieChartImagick.php │ ├── PieChart.php │ └── PieChartGD.php ├── .gitignore ├── composer.json └── README.md /src/SamChristy/PieChart/example/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/example/example.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/fonts/Oswald/Oswald-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/fonts/Oswald/Oswald-Bold.ttf -------------------------------------------------------------------------------- /src/SamChristy/PieChart/fonts/Oswald/Oswald-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/fonts/Oswald/Oswald-Light.ttf -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/resources/sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/documentation/resources/sort.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/fonts/Oswald/Oswald-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/fonts/Oswald/Oswald-Regular.ttf -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/resources/footer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/documentation/resources/footer.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/resources/inherit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/documentation/resources/inherit.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/resources/resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/documentation/resources/resize.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/fonts/Open_Sans/OpenSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/fonts/Open_Sans/OpenSans-Bold.ttf -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/resources/collapsed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/documentation/resources/collapsed.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/resources/tree-last.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/documentation/resources/tree-last.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/fonts/Open_Sans/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/fonts/Open_Sans/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /src/SamChristy/PieChart/fonts/Open_Sans/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/fonts/Open_Sans/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/resources/tree-cleaner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/documentation/resources/tree-cleaner.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/resources/tree-hasnext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/documentation/resources/tree-hasnext.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/fonts/Open_Sans/OpenSans-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/fonts/Open_Sans/OpenSans-ExtraBold.ttf -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/resources/tree-vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SamChristy/PieChart/HEAD/src/SamChristy/PieChart/documentation/resources/tree-vertical.png -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/elementlist.js: -------------------------------------------------------------------------------- 1 | 2 | var ApiGen = ApiGen || {}; 3 | ApiGen.elements = [["c","SamChristy\\PieChart\\PieChart"],["c","SamChristy\\PieChart\\PieChartColor"],["c","SamChristy\\PieChart\\PieChartGD"],["c","SamChristy\\PieChart\\PieChartImagick"]]; 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS generated files # 2 | ###################### 3 | .DS_Store 4 | .DS_Store? 5 | ._* 6 | .Spotlight-V100 7 | .Trashes 8 | Icon? 9 | ehthumbs.db 10 | Thumbs.db 11 | 12 | # Project & temporary files # 13 | ############################# 14 | *~ 15 | *.swp 16 | /tags 17 | /TAGS 18 | /cscope.* 19 | /.patches/ 20 | /.idea/ 21 | /nbproject/ 22 | CVS 23 | .DS_Store 24 | /.settings/ 25 | /.project 26 | /.buildpath 27 | /.cache -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "samchristy/piechart", 3 | "type": "library", 4 | "description": "A simple class for drawing pie charts with ImageMagick or GD in PHP.", 5 | "keywords": ["graphics", "pie", "chart"], 6 | "homepage": "https://github.com/SamChristy/PieChart", 7 | "license": "GPL-2.0+", 8 | "authors": [ 9 | { 10 | "name": "Sam Christy", 11 | "email": "sam_christy@hotmail.co.uk", 12 | "homepage": "https://github.com/SamChristy" 13 | } 14 | ], 15 | "require": { 16 | "php": ">=5.3.0" 17 | }, 18 | "autoload": { 19 | "psr-0": { "SamChristy\\PieChart\\": "src/" } 20 | } 21 | } -------------------------------------------------------------------------------- /src/SamChristy/PieChart/example/example.php: -------------------------------------------------------------------------------- 1 | setTitle($title, '../fonts/Oswald/Oswald-Regular.ttf'); 20 | 21 | $chart->addSlice('Google Chrome', 27, '#4A7EBB'); 22 | $chart->addSlice('Mozilla Firefox', 23, '#DA8137'); 23 | $chart->addSlice('Apple Safari', 11, '#9BBB59'); 24 | $chart->addSlice('Opera', 3, '#BE4B48'); 25 | $chart->addSlice('Other', 5, '#7D60A0'); 26 | 27 | $chart->draw(); 28 | $chart->outputPNG(); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PieChart 2 | ======== 3 | [](https://packagist.org/packages/samchristy/piechart) [](https://packagist.org/packages/samchristy/piechart) [](https://packagist.org/packages/samchristy/piechart) [](https://packagist.org/packages/samchristy/piechart) 4 | 5 | A reasonably efficient* class for drawing pie charts with ImageMagick or GD in PHP. Intended as a 6 | learning exercise for using the NetBeans IDE and the Xdebug profiler and debugger. The code is 7 | available under the [GNU GPL v3.0](http://www.gnu.org/licenses/gpl-3.0.html), so feel free to use it 8 | with attribution. I recommend using the Imagick version, `PieChartImagick` over the GD version, 9 | `PieChartGD`. 10 | 11 | ### Demonstration ### 12 | Below is the code required to generate a pie chart and echo it to the client's browser. The example 13 | uses the method `outputPNG()` to tell the browser to render the image. Alternatively, the function 14 | `forceDownloadPNG()` can be used to instruct the browser to bring up the save dialog. 15 | 16 | ### Documentation ### 17 | [View the documentation](http://samchristy.github.com/PieChart/documentation/index.html) 18 | (generated with [ApiGen](http://apigen.org/)). 19 | 20 | #### Installation #### 21 | [Use Composer](https://packagist.org/packages/samchristy/piechart)! 22 | 23 | #### Example Usage #### 24 | ````php 25 | setTitle('Browser Usage Statistics (January - April)'); 32 | // Method chaining coming soon! 33 | $chart->addSlice('Google Chrome', 27, '#4A7EBB'); 34 | $chart->addSlice('Mozilla Firefox', 23, '#DA8137'); 35 | $chart->addSlice('Apple Safari', 11, '#9BBB59'); 36 | $chart->addSlice('Opera', 3, '#BE4B48'); 37 | $chart->addSlice('Other', 5, '#7D60A0'); 38 | 39 | $chart->draw(); 40 | $chart->outputPNG(); 41 | ```` 42 | #### Output #### 43 |  44 | 45 | *This example took 150ms to execute on my laptop (i3-350M @ 2.27 GHz). 46 | 47 | © Sam Christy 2013 48 | -------------------------------------------------------------------------------- /src/SamChristy/PieChart/documentation/namespace-SamChristy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 || SamChristy\PieChart | 81 |
| imageSmoothArc | 93 |94 | | 95 |
| imageSmoothArcDrawSegment | 98 |99 | |
| SamChristy | 88 |
| SamChristy\PieChart | 91 |
The requested page could not be found.
86 |You have probably clicked on a link that is outdated and points to a page that does not exist any more or you have made an typing error in the address.
87 |To continue please try to find requested page in the menu, take a look at the tree view of the whole project or use search field on the top.
88 || PieChart | 90 |Abstract class that is designed to be extended for drawing pie charts with 91 | different graphics libraries. Use PieChartGD or PieChartImagick to actually draw 92 | your charts. | 93 |
| PieChartColor | 96 |Utility class for storing colours in a library-agnostic format. | 97 |
| PieChartGD | 100 |A lightweight class for drawing pie charts, using the GD library. | 101 |
| PieChartImagick | 104 |A lightweight class for drawing pie charts, using the ImageMagick library. | 105 |
| PieChart | 91 |Abstract class that is designed to be extended for drawing pie charts with 92 | different graphics libraries. Use PieChartGD or PieChartImagick to actually draw 93 | your charts. 94 | | 95 |
| PieChartColor | 98 |Utility class for storing colours in a library-agnostic format. | 99 |
| PieChartGD | 102 |A lightweight class for drawing pie charts, using the GD library. | 103 |
| PieChartImagick | 106 |A lightweight class for drawing pie charts, using the ImageMagick library. | 107 |
mixed |
96 | & $img |
97 | 98 | 99 | | 100 |
mixed |
103 | $cx |
104 | 105 | 106 | | 107 |
mixed |
110 | $cy |
111 | 112 | 113 | | 114 |
mixed |
117 | $w |
118 | 119 | 120 | | 121 |
mixed |
124 | $h |
125 | 126 | 127 | | 128 |
mixed |
131 | $color |
132 | 133 | 134 | | 135 |
mixed |
138 | $start |
139 | 140 | 141 | | 142 |
mixed |
145 | $stop |
146 | 147 | 148 | | 149 |
mixed |
96 | & $img |
97 | 98 | 99 | | 100 |
mixed |
103 | $cx |
104 | 105 | 106 | | 107 |
mixed |
110 | $cy |
111 | 112 | 113 | | 114 |
mixed |
117 | $a |
118 | 119 | 120 | | 121 |
mixed |
124 | $b |
125 | 126 | 127 | | 128 |
mixed |
131 | $aaAngleX |
132 | 133 | 134 | | 135 |
mixed |
138 | $aaAngleY |
139 | 140 | 141 | | 142 |
mixed |
145 | $color |
146 | 147 | 148 | | 149 |
mixed |
152 | $start |
153 | 154 | 155 | | 156 |
mixed |
159 | $stop |
160 | 161 | 162 | | 163 |
mixed |
166 | $seg |
167 | 168 | 169 | | 170 |
Utility class for storing colours in a library-agnostic format.
89 | 90 |
116 | public
117 |
118 |
119 |
120 | |
121 |
122 |
123 | #
124 | __construct( array|integer|string $color = NULL )
125 |
126 |
127 |
128 |
131 |
132 |
149 | Sets the colour using |
150 |
154 | public
155 |
156 |
157 |
158 | |
159 |
160 |
161 | #
162 | setColor( array|integer|string $color )
163 |
164 |
165 |
166 |
170 |
171 |
189 | Sets the colour, using one of the following formats: '#FFFFFF', '#fff', 167 | 'rgb(255, 255, 255)', [$r, $g, $b] or ARGB (http://en.wikipedia.org/wiki/ARGB#ARGB). 168 | 169 | |
190 |
194 | public
195 | integer
196 |
197 |
198 | |
199 |
200 |
201 | #
202 | toInt( )
203 |
204 |
205 |
206 |
209 |
210 |
226 | Returns the colour as an integer, in the ARGB format (http://en.wikipedia.org/wiki/ARGB#ARGB). 207 | 208 | |
227 |
231 | public
232 | string
233 |
234 |
235 | |
236 |
237 | 264 | |
268 | public
269 | string
270 |
271 |
272 | |
273 |
274 | 301 | |
319 | public
320 | mixed
321 | |
322 |
323 | 324 | $r 325 | | 326 | |
327 |
328 | #
329 |
330 |
331 |
332 |
333 |
334 |
338 | |
339 |
342 | public
343 | mixed
344 | |
345 |
346 | 347 | $g 348 | | 349 | |
350 |
351 | #
352 |
353 |
354 |
355 |
356 |
357 |
361 | |
362 |
365 | public
366 | mixed
367 | |
368 |
369 | 370 | $b 371 | | 372 | |
373 |
374 | #
375 |
376 |
377 |
378 |
379 |
380 |
384 | |
385 |
Utility class for storing colours in a library-agnostic format.
90 | 91 |
117 | public
118 |
119 |
120 |
121 | |
122 |
123 |
124 | #
125 | __construct( array|integer|string $color = NULL )
126 |
127 |
128 |
129 |
132 |
133 |
150 | Sets the colour using |
151 |
155 | public
156 |
157 |
158 |
159 | |
160 |
161 |
162 | #
163 | setColor( array|integer|string $color )
164 |
165 |
166 |
167 |
171 |
172 |
190 | Sets the colour, using one of the following formats: '#FFFFFF', '#fff', 168 | 'rgb(255, 255, 255)', [$r, $g, $b] or ARGB (http://en.wikipedia.org/wiki/ARGB#ARGB). 169 | 170 | |
191 |
195 | public
196 | integer
197 |
198 |
199 | |
200 |
201 |
202 | #
203 | toInt( )
204 |
205 |
206 |
207 |
210 |
211 |
227 | Returns the colour as an integer, in the ARGB format (http://en.wikipedia.org/wiki/ARGB#ARGB). 208 | 209 | |
228 |
232 | public
233 | string
234 |
235 |
236 | |
237 |
238 | 265 | |
269 | public
270 | string
271 |
272 |
273 | |
274 |
275 | 302 | |
320 | public
321 | mixed
322 | |
323 |
324 | 325 | $r 326 | | 327 | |
328 |
329 | #
330 |
331 |
332 |
333 |
334 |
335 |
339 | |
340 |
343 | public
344 | mixed
345 | |
346 |
347 | 348 | $g 349 | | 350 | |
351 |
352 | #
353 |
354 |
355 |
356 |
357 |
358 |
362 | |
363 |
366 | public
367 | mixed
368 | |
369 |
370 | 371 | $b 372 | | 373 | |
374 |
375 | #
376 |
377 |
378 |
379 |
380 |
381 |
385 | |
386 |
A lightweight class for drawing pie charts, using the ImageMagick 89 | library.
90 | 91 |
102 | PieChartImagick
103 |
104 |
105 |
141 | public
142 |
143 |
144 |
145 | |
146 |
147 | 174 | |
178 | public
179 |
180 |
181 |
182 | |
183 |
184 | 209 | |
213 | protected
214 |
215 |
216 |
217 | |
218 |
219 | 253 | |
257 | protected
258 | integer
259 |
260 |
261 | |
262 |
263 |
264 | #
265 | _drawLegend( integer $legendOffset )
266 |
267 |
268 |
269 |
272 |
273 |
294 | Draws the legend for the pieChart, if $this->hasLegend is true. 270 | 271 | |
295 |
299 | protected
300 |
301 |
302 |
303 | |
304 |
305 |
306 | #
307 | _drawSlice( mixed $center, mixed $radius, mixed $start, mixed $end, mixed $color )
308 |
309 |
310 |
311 |
312 |
313 |
323 | |
324 |
328 | protected
329 | integer
330 |
331 |
332 | |
333 |
334 |
335 | #
336 | _maxLabelWidth( mixed $fontSize )
337 |
338 |
339 |
340 |
343 |
344 |
360 | Returns the width, in pixels, of the chart's widest label. 341 | 342 | |
361 |
365 | protected
366 | integer
367 |
368 |
369 | |
370 |
371 |
372 | #
373 | _drawTitle( )
374 |
375 |
376 |
377 |
381 |
382 |
399 | Draws and returns the height of the title and its padding (in pixels). If no 378 | title is specified, then nothing is drawn and 0 is returned. 379 | 380 | |
400 |
407 | __construct(),
408 | addSlice(),
409 | forceDownloadGIF(),
410 | forceDownloadJPEG(),
411 | forceDownloadPNG(),
412 | outputGIF(),
413 | outputJPEG(),
414 | outputPNG(),
415 | removeSlice(),
416 | saveGIF(),
417 | saveJPEG(),
418 | savePNG(),
419 | setLegend(),
420 | setOutputQuality(),
421 | setTitle()
422 | |
423 |
437 | FORMAT_GIF,
438 | FORMAT_JPEG,
439 | FORMAT_PNG,
440 | OUTPUT_DOWNLOAD,
441 | OUTPUT_INLINE,
442 | OUTPUT_SAVE
443 | |
444 |
454 | $backgroundColor,
455 | $canvas,
456 | $hasLegend,
457 | $height,
458 | $legendFont,
459 | $quality,
460 | $slices,
461 | $textColor,
462 | $title,
463 | $titleFont,
464 | $width
465 | |
466 |
A lightweight class for drawing pie charts, using the GD library.
89 | 90 |
101 | PieChartGD
102 |
103 |
104 |
140 | public
141 |
142 |
143 |
144 | |
145 |
146 | 173 | |
177 | public
178 |
179 |
180 |
181 | |
182 |
183 | 208 | |
212 | protected
213 |
214 |
215 |
216 | |
217 |
218 | 252 | |
256 | protected
257 | integer
258 |
259 |
260 | |
261 |
262 |
263 | #
264 | _drawLegend( integer $legendOffset )
265 |
266 |
267 |
268 |
271 |
272 |
293 | Draws the legend for the pieChart, if $this->hasLegend is true. 269 | 270 | |
294 |
298 | protected
299 |
300 |
301 |
302 | |
303 |
304 |
305 | #
306 | _drawLegendKey( integer $x, integer $y, object $color, string $label, integer $squareSize, integer $labelPadding, integer $fontSize )
307 |
308 |
309 |
310 |
313 |
314 |
343 | Draws the legend key at the specific location. 311 | 312 | |
344 |
348 | protected
349 | integer
350 |
351 |
352 | |
353 |
354 |
355 | #
356 | _maxLabelWidth( mixed $fontSize )
357 |
358 |
359 |
360 |
363 |
364 |
380 | Returns the width, in pixels, of the chart's widest label. 361 | 362 | |
381 |
385 | protected
386 | integer
387 |
388 |
389 | |
390 |
391 |
392 | #
393 | _drawTitle( mixed $x = 0, mixed $y = 0 )
394 |
395 |
396 |
397 |
401 |
402 |
424 | Draws and returns the height of the title and its padding (in pixels). If no 398 | title is specified, then nothing is drawn and 0 is returned. 399 | 400 | |
425 |
432 | __construct(),
433 | addSlice(),
434 | forceDownloadGIF(),
435 | forceDownloadJPEG(),
436 | forceDownloadPNG(),
437 | outputGIF(),
438 | outputJPEG(),
439 | outputPNG(),
440 | removeSlice(),
441 | saveGIF(),
442 | saveJPEG(),
443 | savePNG(),
444 | setLegend(),
445 | setOutputQuality(),
446 | setTitle()
447 | |
448 |
462 | FORMAT_GIF,
463 | FORMAT_JPEG,
464 | FORMAT_PNG,
465 | OUTPUT_DOWNLOAD,
466 | OUTPUT_INLINE,
467 | OUTPUT_SAVE
468 | |
469 |
479 | $backgroundColor,
480 | $canvas,
481 | $hasLegend,
482 | $height,
483 | $legendFont,
484 | $quality,
485 | $slices,
486 | $textColor,
487 | $title,
488 | $titleFont,
489 | $width
490 | |
491 |
A lightweight class for drawing pie charts, using the ImageMagick 90 | library.
91 | 92 |
103 | SamChristy\PieChart\PieChartImagick
104 |
105 |
106 |
142 | public
143 |
144 |
145 |
146 | |
147 |
148 | 175 | |
179 | public
180 |
181 |
182 |
183 | |
184 |
185 | 210 | |
214 | protected
215 |
216 |
217 |
218 | |
219 |
220 | 254 | |
258 | protected
259 | integer
260 |
261 |
262 | |
263 |
264 |
265 | #
266 | _drawLegend( integer $legendOffset )
267 |
268 |
269 |
270 |
273 |
274 |
295 | Draws the legend for the pieChart, if $this->hasLegend is true. 271 | 272 | |
296 |
300 | protected
301 |
302 |
303 |
304 | |
305 |
306 |
307 | #
308 | _drawSlice( mixed $center, mixed $radius, mixed $start, mixed $end, mixed $color )
309 |
310 |
311 |
312 |
313 |
314 |
324 | |
325 |
329 | protected
330 | integer
331 |
332 |
333 | |
334 |
335 |
336 | #
337 | _maxLabelWidth( mixed $fontSize )
338 |
339 |
340 |
341 |
344 |
345 |
361 | Returns the width, in pixels, of the chart's widest label. 342 | 343 | |
362 |
366 | protected
367 | integer
368 |
369 |
370 | |
371 |
372 |
373 | #
374 | _drawTitle( )
375 |
376 |
377 |
378 |
382 |
383 |
400 | Draws and returns the height of the title and its padding (in pixels). If no 379 | title is specified, then nothing is drawn and 0 is returned. 380 | 381 | |
401 |
408 | __construct(),
409 | addSlice(),
410 | forceDownloadGIF(),
411 | forceDownloadJPEG(),
412 | forceDownloadPNG(),
413 | outputGIF(),
414 | outputJPEG(),
415 | outputPNG(),
416 | removeSlice(),
417 | saveGIF(),
418 | saveJPEG(),
419 | savePNG(),
420 | setLegend(),
421 | setOutputQuality(),
422 | setTitle()
423 | |
424 |
438 | FORMAT_GIF,
439 | FORMAT_JPEG,
440 | FORMAT_PNG,
441 | OUTPUT_DOWNLOAD,
442 | OUTPUT_INLINE,
443 | OUTPUT_SAVE
444 | |
445 |
455 | $backgroundColor,
456 | $canvas,
457 | $hasLegend,
458 | $height,
459 | $legendFont,
460 | $quality,
461 | $slices,
462 | $textColor,
463 | $title,
464 | $titleFont,
465 | $width
466 | |
467 |
A lightweight class for drawing pie charts, using the GD library.
90 | 91 |
102 | SamChristy\PieChart\PieChartGD
103 |
104 |
105 |
141 | public
142 |
143 |
144 |
145 | |
146 |
147 | 174 | |
178 | public
179 |
180 |
181 |
182 | |
183 |
184 | 214 | |
218 | protected
219 |
220 |
221 |
222 | |
223 |
224 | 258 | |
262 | protected
263 | integer
264 |
265 |
266 | |
267 |
268 |
269 | #
270 | _drawLegend( integer $legendOffset )
271 |
272 |
273 |
274 |
277 |
278 |
299 | Draws the legend for the pieChart, if $this->hasLegend is true. 275 | 276 | |
300 |
304 | protected
305 |
306 |
307 |
308 | |
309 |
310 |
311 | #
312 | _drawLegendKey( integer $x, integer $y, object $color, string $label, integer $squareSize, integer $labelPadding, integer $fontSize )
313 |
314 |
315 |
316 |
319 |
320 |
349 | Draws the legend key at the specific location. 317 | 318 | |
350 |
354 | protected
355 | integer
356 |
357 |
358 | |
359 |
360 |
361 | #
362 | _maxLabelWidth( mixed $fontSize )
363 |
364 |
365 |
366 |
369 |
370 |
386 | Returns the width, in pixels, of the chart's widest label. 367 | 368 | |
387 |
391 | protected
392 | integer
393 |
394 |
395 | |
396 |
397 |
398 | #
399 | _drawTitle( mixed $x = 0, mixed $y = 0 )
400 |
401 |
402 |
403 |
407 |
408 |
430 | Draws and returns the height of the title and its padding (in pixels). If no 404 | title is specified, then nothing is drawn and 0 is returned. 405 | 406 | |
431 |
438 | __construct(),
439 | addSlice(),
440 | forceDownloadGIF(),
441 | forceDownloadJPEG(),
442 | forceDownloadPNG(),
443 | outputGIF(),
444 | outputJPEG(),
445 | outputPNG(),
446 | removeSlice(),
447 | saveGIF(),
448 | saveJPEG(),
449 | savePNG(),
450 | setLegend(),
451 | setOutputQuality(),
452 | setTitle()
453 | |
454 |
468 | FORMAT_GIF,
469 | FORMAT_JPEG,
470 | FORMAT_PNG,
471 | OUTPUT_DOWNLOAD,
472 | OUTPUT_INLINE,
473 | OUTPUT_SAVE
474 | |
475 |
485 | $backgroundColor,
486 | $canvas,
487 | $hasLegend,
488 | $height,
489 | $legendFont,
490 | $quality,
491 | $slices,
492 | $textColor,
493 | $title,
494 | $titleFont,
495 | $width
496 | |
497 |
Abstract class that is designed to be extended for drawing pie charts with 89 | different graphics libraries. Use PieChartGD or PieChartImagick to actually draw 90 | your charts.
91 | 92 |
133 | public
134 |
135 |
136 |
137 | |
138 |
139 |
140 | #
141 | __construct( integer $width = 0, integer $height = 0, string $title = '', string|integer|array $textColor = 0x222222, string|integer|array $backgroundColor = 0xffffff )
142 |
143 |
144 |
145 |
148 |
149 |
174 | Constructs the PieChart. 146 | 147 | |
175 |
179 | public
180 |
181 |
182 |
183 | |
184 |
185 | 210 | |
214 | public
215 |
216 |
217 |
218 | |
219 |
220 | 250 | |
254 | public
255 |
256 |
257 |
258 | |
259 |
260 | 290 | |
294 | public
295 |
296 |
297 |
298 | |
299 |
300 |
301 | #
302 | setOutputQuality( integer $quality )
303 |
304 |
305 |
306 |
309 |
310 |
327 | Set the quality for generating output in lossy formats. 307 | 308 | |
328 |
332 | public
333 |
334 |
335 |
336 | |
337 |
338 | 370 | |
374 | public
375 |
376 |
377 |
378 | |
379 |
380 |
381 | #
382 | removeSlice( string $name )
383 |
384 |
385 |
386 |
389 |
390 |
407 | Removes the specified slice. 387 | 388 | |
408 |
412 | public
413 |
414 |
415 |
416 | |
417 |
418 | 441 | |
445 | protected
446 |
447 |
448 |
449 | |
450 |
451 | 483 | |
487 | public
488 | boolean
489 |
490 |
491 | |
492 |
493 | 525 | |
529 | public
530 | boolean
531 |
532 |
533 | |
534 |
535 |
536 | #
537 | outputJPEG( string $filename = 'pie-chart.jpg' )
538 |
539 |
540 |
541 |
544 |
545 |
566 | Echos the chart as a JPEG and instructs the browser to display it inline. 542 | 543 | |
567 |
571 | public
572 | boolean
573 |
574 |
575 | |
576 |
577 | 609 | |
613 | public
614 | boolean
615 |
616 |
617 | |
618 |
619 |
620 | #
621 | forceDownloadGIF( string $filename = 'pie-chart.gif' )
622 |
623 |
624 |
625 |
629 |
630 |
652 | Echos the chart as a GIF and instructs the browser to force the user to save 626 | it. 627 | 628 | |
653 |
657 | public
658 | boolean
659 |
660 |
661 | |
662 |
663 |
664 | #
665 | forceDownloadJPEG( string $filename = 'pie-chart.jpg' )
666 |
667 |
668 |
669 |
673 |
674 |
696 | Echos the chart as a JPEG and instructs the browser to force the user to save 670 | it. 671 | 672 | |
697 |
701 | public
702 | boolean
703 |
704 |
705 | |
706 |
707 |
708 | #
709 | forceDownloadPNG( string $filename = 'pie-chart.png' )
710 |
711 |
712 |
713 |
717 |
718 |
740 | Echos the chart as a PNG and instructs the browser to force the user to save 714 | it. 715 | 716 | |
741 |
745 | public
746 | integer
747 |
748 |
749 | |
750 |
751 | 783 | |
787 | public
788 | integer
789 |
790 |
791 | |
792 |
793 | 825 | |
829 | public
830 | integer
831 |
832 |
833 | |
834 |
835 | 867 | |
integer |
882 |
883 | FORMAT_GIF
884 | |
885 | 1 |
886 |
887 | #
888 |
889 |
890 |
891 |
892 |
893 |
897 | |
898 |
integer |
902 |
903 | FORMAT_JPEG
904 | |
905 | 2 |
906 |
907 | #
908 |
909 |
910 |
911 |
912 |
913 |
917 | |
918 |
integer |
922 |
923 | FORMAT_PNG
924 | |
925 | 3 |
926 |
927 | #
928 |
929 |
930 |
931 |
932 |
933 |
937 | |
938 |
integer |
942 |
943 | OUTPUT_DOWNLOAD
944 | |
945 | 1 |
946 |
947 | #
948 |
949 |
950 |
951 |
952 |
953 |
957 | |
958 |
integer |
962 |
963 | OUTPUT_INLINE
964 | |
965 | 2 |
966 |
967 | #
968 |
969 |
970 |
971 |
972 |
973 |
977 | |
978 |
integer |
982 |
983 | OUTPUT_SAVE
984 | |
985 | 3 |
986 |
987 | #
988 |
989 |
990 |
991 |
992 |
993 |
997 | |
998 |
1008 | protected
1009 | mixed
1010 | |
1011 |
1012 | 1013 | $slices 1014 | | 1015 | |
1016 |
1017 | #
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1027 | |
1028 |
1031 | protected
1032 | mixed
1033 | |
1034 |
1035 | 1036 | $width 1037 | | 1038 | |
1039 |
1040 | #
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1050 | |
1051 |
1054 | protected
1055 | mixed
1056 | |
1057 |
1058 | 1059 | $height 1060 | | 1061 | |
1062 |
1063 | #
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1073 | |
1074 |
1077 | protected
1078 | mixed
1079 | |
1080 |
1081 | 1082 | $title 1083 | | 1084 | |
1085 |
1086 | #
1087 |
1088 |
1089 |
1090 |
1091 |
1092 |
1096 | |
1097 |
1100 | protected
1101 | mixed
1102 | |
1103 |
1104 | 1105 | $hasLegend 1106 | | 1107 | |
1108 |
1109 | #
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1119 | |
1120 |
1123 | protected
1124 | mixed
1125 | |
1126 |
1127 | 1128 | $titleFont 1129 | | 1130 | |
1131 |
1132 | #
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
1142 | |
1143 |
1146 | protected
1147 | mixed
1148 | |
1149 |
1150 | 1151 | $legendFont 1152 | | 1153 | |
1154 |
1155 | #
1156 |
1157 |
1158 |
1159 |
1160 |
1161 |
1165 | |
1166 |
1169 | protected
1170 | mixed
1171 | |
1172 |
1173 | 1174 | $textColor 1175 | | 1176 | |
1177 |
1178 | #
1179 |
1180 |
1181 |
1182 |
1183 |
1184 |
1188 | |
1189 |
1192 | protected
1193 | mixed
1194 | |
1195 |
1196 | 1197 | $backgroundColor 1198 | | 1199 | |
1200 |
1201 | #
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1211 | |
1212 |
1215 | protected
1216 | mixed
1217 | |
1218 |
1219 | 1220 | $canvas 1221 | | 1222 | |
1223 |
1224 | #
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1234 | |
1235 |
1238 | protected
1239 | mixed
1240 | |
1241 |
1242 | 1243 | $quality 1244 | | 1245 | |
1246 |
1247 | #
1248 |
1249 |
1250 |
1251 |
1252 |
1253 |
1257 | |
1258 |