Server IP : 103.11.96.170 / Your IP : 18.116.28.60 Web Server : Microsoft-IIS/10.0 System : Windows NT WIN-F6SLGVICLOP 10.0 build 17763 (Windows Server 2016) AMD64 User : elibrary.unsap.ac.id ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF Directory (0777) : D:/localhost/elibrary/lib/phplot/contrib/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /* PHPlot / contrib / prune_labels $Id: prune_labels.php,v 1.1 2009/12/09 03:45:55 lbayuk Exp $ PHPlot contrib code - public domain - no copyright - use as you wish Reduce the number of data labels along the X axis, when the density is too high. This simply blanks out M-1 of every M labels in the data array. There are other ways to do this, but we need to keep the labels uniformly spaced. You select the target maximum label count (maxlabels), and you will get no more than maxlabels data labels. Arguments: $data - The PHPlot data array (reference variable) $maxlabels - The maximum number of data labels you are willing to have, Returns: Nothing Modifies the $data array in place to remove some of the labels. Notes: The data array and its rows must be 0-based integer indexed arrays. */ function prune_labels(&$data, $maxlabels) { # Do nothing if there are not already too many labels: if (($n = count($data)) <= $maxlabels) return; # Compute how many labels to erase. Keep 1 of every $m labels. $m = (int)ceil($n / $maxlabels); # Process the data array, zapping M-1 of every M labels: $k = 0; for ($i = 0; $i < $n; $i++) { if ($k > 0) $data[$i][0] = ''; if (++$k >= $m) $k = 0; } }