index : flyspray | |
Archlinux32 customized Flyspray installation | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | vendor/jamiebicknell/Sparkline/LICENSE.md | 21 | ||||
-rw-r--r-- | vendor/jamiebicknell/Sparkline/README.md | 101 | ||||
-rw-r--r-- | vendor/jamiebicknell/Sparkline/composer.json | 21 | ||||
-rw-r--r-- | vendor/jamiebicknell/Sparkline/sparkline.php | 114 |
diff --git a/vendor/jamiebicknell/Sparkline/LICENSE.md b/vendor/jamiebicknell/Sparkline/LICENSE.md new file mode 100644 index 0000000..fa81603 --- /dev/null +++ b/vendor/jamiebicknell/Sparkline/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Jamie Bicknell - @jamiebicknell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.
\ No newline at end of file diff --git a/vendor/jamiebicknell/Sparkline/README.md b/vendor/jamiebicknell/Sparkline/README.md new file mode 100644 index 0000000..0309b38 --- /dev/null +++ b/vendor/jamiebicknell/Sparkline/README.md @@ -0,0 +1,101 @@ +# Sparkline + +PHP script to generate sparklines, with browser cachine with ETag. + +## Usage + +```html +<img src='sparkline.php?size=80x20&data=2,4,5,6,10,7,8,5,7,7,11,8,6,9,11,9,13,14,12,16&back=fff&line=5bb763&fill=d5f7d8' /> +``` + +## Examples + +<img src='http://jamiebicknell.github.io/Sparkline/sparkline_1403094493691.png' alt='EG1' /><br /> +`sparkline.php` + +<img src='http://jamiebicknell.github.io/Sparkline/sparkline_1403094493692.png' alt='EG2' /><br /> +`sparkline.php?data=5` + +<img src='http://jamiebicknell.github.io/Sparkline/sparkline_1403094493693.png' alt='EG3' /><br /> +`sparkline.php?data=2,4,5,6,10,7,8,5,7,7,11,8,6,9,11,9,13,14,12,16` + +<img src='http://jamiebicknell.github.io/Sparkline/sparkline_1403094493694.png' alt='EG4' /><br /> +`sparkline.php?data=2,4,5,6,10,7,8,5,7,7,11,8,6,9,11,9,13,14,12,16&line=5bb763&fill=d5f7d8` + +<img src='http://jamiebicknell.github.io/Sparkline/sparkline_1403094493695.png' alt='EG5' /><br /> +`sparkline.php?data=2,4,5,6,10,7,8,5,7,7,11,8,6,9,11,9,13,14,12,16&line=fd8626&fill=ffedde` + +<img src='http://jamiebicknell.github.io/Sparkline/sparkline_1403094493696.png' alt='EG6' /><br /> +`sparkline.php?data=2,4,5,6,10,7,8,5,7,7,11,8,6,9,11,9,13,14,12,16&line=ed5565&fill=ffe2e2` + +<img src='http://jamiebicknell.github.io/Sparkline/sparkline_1403094493697.png' alt='EG7' /><br /> +`sparkline.php?data=2,4,5,6,10,7,8,5,7,7,11,8,6,9,11,9,13,14,12,16&line=444&fill=eee` + +<img src='http://jamiebicknell.github.io/Sparkline/sparkline_1403094493698.png' alt='EG8' /><br /> +`sparkline.php?data=2,4,5,6,10,7,8,5,7,7,11,8,6,9,11,9,13,14,12,16&line=31475c&fill=fff` + +<img src='http://jamiebicknell.github.io/Sparkline/sparkline_1403094493699.png' alt='EG9' /><br /> +`sparkline.php?size=185x40&data=2,4,5,6,10,7,8,5,7,7,11,8,6,9,11,9,13,14,12,16` + + +## Query Parameters + +<table> + <tr> + <th>Key</th> + <th>Example Value</th> + <th>Default</th> + <th>Description</th> + </tr> + <tr> + <td>size</td> + <td>100x25, 100</td> + <td>80x20</td> + <td>Width must be between 50 and 80<br />Height must be between 20 and 800</td> + </tr> + <tr> + <td>data</td> + <td>10,20,50,20,30,40,50,120,90</td> + <td></td> + <td>Comma separated list of values to plot</td> + </tr> + <tr> + <td>back</td> + <td>eeeeee, ddd</td> + <td>ffffff</td> + <td>Hexadecimal code for background colour</td> + </tr> + <tr> + <td>line</td> + <td>555555, 222</td> + <td>1388db</td> + <td>Hexadecimal code for line colour</td> + </tr> + <tr> + <td>fill</td> + <td>cccccc, bbb</td> + <td>e6f2fa</td> + <td>Hexadecimal code for fill colour</td> + </tr> +</table> + +## Size Parameter + +<table> + <tr> + <th>Value</th> + <th>Description</th> + </tr> + <tr> + <td>100</td> + <td>Creates a square image 100px in width and 100px in height</td> + </tr> + <tr> + <td>80x20</td> + <td>Creates an image 80px in width and 20px in height</td> + </tr> +</table> + +## License + +Sparkline is licensed under the [MIT license](http://opensource.org/licenses/MIT), see [LICENSE.md](https://github.com/jamiebicknell/Sparkline/blob/master/LICENSE.md) for details.
\ No newline at end of file diff --git a/vendor/jamiebicknell/Sparkline/composer.json b/vendor/jamiebicknell/Sparkline/composer.json new file mode 100644 index 0000000..061d792 --- /dev/null +++ b/vendor/jamiebicknell/Sparkline/composer.json @@ -0,0 +1,21 @@ +{ + "name": "jamiebicknell/Sparkline", + "description": "PHP script to generate sparklines", + "keywords": [ + "sparkline", + "sparklines", + "php", + "gd" + ], + "homepage": "http://github.com/jamiebicknell/Sparkline", + "license": "MIT", + "authors": [ + { + "name": "Jamie Bicknell", + "homepage": "http://www.jamiebicknell.com" + } + ], + "require": { + "php": ">=5.2.0" + } +}
\ No newline at end of file diff --git a/vendor/jamiebicknell/Sparkline/sparkline.php b/vendor/jamiebicknell/Sparkline/sparkline.php new file mode 100644 index 0000000..adfb9e1 --- /dev/null +++ b/vendor/jamiebicknell/Sparkline/sparkline.php @@ -0,0 +1,114 @@ +<?php + +/* +Title: Sparkline +URL: http://github.com/jamiebicknell/Sparkline +Author: Jamie Bicknell +Twitter: @jamiebicknell +*/ + +function isHex($string) +{ + return preg_match('/^#?+[0-9a-f]{3}(?:[0-9a-f]{3})?$/i', $string); +} + +function hexToRgb($hex) +{ + $hex = ltrim(strtolower($hex), '#'); + $hex = isset($hex[3]) ? $hex : $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; + $dec = hexdec($hex); + return array(0xFF & ($dec >> 0x10), 0xFF & ($dec >> 0x8), 0xFF & $dec); +} + +$size = isset($_GET['size']) ? str_replace('x', '', $_GET['size']) != '' ? $_GET['size'] : '80x20' : '80x20'; +$back = isset($_GET['back']) ? isHex($_GET['back']) ? $_GET['back'] : 'ffffff' : 'ffffff'; +$line = isset($_GET['line']) ? isHex($_GET['line']) ? $_GET['line'] : '1388db' : '1388db'; +$fill = isset($_GET['fill']) ? isHex($_GET['fill']) ? $_GET['fill'] : 'e6f2fa' : 'e6f2fa'; +$data = isset($_GET['data']) ? explode(',', $_GET['data']) : array(); + +list($w, $h) = explode('x', $size); +$w = floor(max(50, min(800, $w))); +$h = !strstr($size, 'x') ? $w : floor(max(20, min(800, $h))); +$t = 1.75; +$s = 4; + +$w *= $s; +$h *= $s; +$t *= $s; + +$salt = 'v1.0.1'; +$hash = md5($salt . $_SERVER['QUERY_STRING']); + +$data = (count($data) < 2) ? array_fill(0, 2, $data[0]) : $data; +$count = count($data); +$step = $w / ($count - 1); + +$min = min($data); +$max = max($data); +if ($max != $min) { + foreach ($data as $k => $v) { + $data[$k] -= $min; + } + $max = max($data); +} + +if (!extension_loaded('gd')) { + die('GD extension is not installed'); +} + +if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { + if ($_SERVER['HTTP_IF_NONE_MATCH'] == $hash) { + header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); + die(); + } +} + +$im = imagecreatetruecolor($w, $h); +list($r, $g, $b) = hexToRgb($back); +$bg = imagecolorallocate($im, $r, $g, $b); +list($r, $g, $b) = hexToRgb($line); +$fg = imagecolorallocate($im, $r, $g, $b); +list($r, $g, $b) = hexToRgb($fill); +$lg = imagecolorallocate($im, $r, $g, $b); +imagefill($im, 0, 0, $bg); + +imagesetthickness($im, $t); + +foreach ($data as $k => $v) { + $v = $v > 0 ? round($v / $max * $h) : 0; + $data[$k] = max($s, min($v, $h - $s)); +} + +$x1 = 0; +$y1 = $h - $data[0]; +$line = array(); +$poly = array(0, $h + 50, $x1, $y1); +for ($i = 1; $i < $count; $i++) { + $x2 = $x1 + $step; + $y2 = $h - $data[$i]; + array_push($line, array($x1, $y1, $x2, $y2)); + array_push($poly, $x2, $y2); + $x1 = $x2; + $y1 = $y2; +} +array_push($poly, $x2, $h + 50); + +imagefilledpolygon($im, $poly, $count + 2, $lg); + +foreach ($line as $k => $v) { + list($x1, $y1, $x2, $y2) = $v; + imageline($im, $x1, $y1, $x2, $y2, $fg); +} + +$om = imagecreatetruecolor($w / $s, $h / $s); +imagecopyresampled($om, $im, 0, 0, 0, 0, $w / $s, $h / $s, $w, $h); +imagedestroy($im); + +header('Content-Type: image/png'); +header('Content-Disposition: inline; filename="sparkline_' . time() . substr(microtime(), 2, 3) . '.png"'); +header('ETag: ' . $hash); +header('Accept-Ranges: none'); +header('Cache-Control: max-age=604800, must-revalidate'); +header('Expires: ' . gmdate('D, d M Y H:i:s T', strtotime('+7 days'))); +imagepng($om); +imagedestroy($om); |