From: <var...@us...> - 2009-02-20 13:51:03
|
Revision: 6519 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6519&view=rev Author: vargenau Date: 2009-02-20 13:50:58 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Handle correctly negative values in charts Modified Paths: -------------- trunk/lib/plugin/Chart.php Modified: trunk/lib/plugin/Chart.php =================================================================== --- trunk/lib/plugin/Chart.php 2009-02-20 13:10:56 UTC (rev 6518) +++ trunk/lib/plugin/Chart.php 2009-02-20 13:50:58 UTC (rev 6519) @@ -87,17 +87,24 @@ // x_min = 0 // x_max = number of elements in data - // y_min = 0 + // y_min = 0 or smallest element in data if negative // y_max = biggest element in data - $x_max = sizeof($values); + $x_max = sizeof($values) + 1; + $y_min = min($values); + if ($y_min > 0) { + $y_min = 0; + } $y_max = max($values); + // sum is used for the pie only, so we ignore negative values $sum = 0; foreach ($values as $value) { - $sum += $value; + if ($value > 0) { + $sum += $value; + } } - $source = 'initPicture(0,'.$x_max.',0,'.$y_max.'); axes(); stroke = "'.$color.'"; strokewidth = 5;'; + $source = 'initPicture(0,'.$x_max.','.$y_min.','.$y_max.'); axes(); stroke = "'.$color.'"; strokewidth = 5;'; if ($type == "bar") { $abscisse = 1; @@ -126,8 +133,10 @@ . 'point = [1, 0]; line(center, point);'; $angle = 0; foreach ($values as $value) { - $angle += $value/$sum; - $source .= 'point = [cos(2*pi*'.$angle.'), sin(2*pi*'.$angle.')]; line(center, point);'; + if ($value > 0) { + $angle += $value/$sum; + $source .= 'point = [cos(2*pi*'.$angle.'), sin(2*pi*'.$angle.')]; line(center, point);'; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2011-12-16 10:08:48
|
Revision: 8207 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=8207&view=rev Author: vargenau Date: 2011-12-16 10:08:37 +0000 (Fri, 16 Dec 2011) Log Message: ----------- More generic message Modified Paths: -------------- trunk/lib/plugin/Chart.php Modified: trunk/lib/plugin/Chart.php =================================================================== --- trunk/lib/plugin/Chart.php 2011-12-15 16:27:16 UTC (rev 8206) +++ trunk/lib/plugin/Chart.php 2011-12-16 10:08:37 UTC (rev 8207) @@ -74,7 +74,7 @@ global $WikiTheme; $args = $this->getArgs($argstr, $request); if (!$args['data']) { - return $this->error(_("No mandatory 'data' argument provided.")); + return $this->error(sprintf(_("No mandatory '%s' argument provided."), 'data')); } extract($args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-28 15:43:35
|
Revision: 10598 http://sourceforge.net/p/phpwiki/code/10598 Author: vargenau Date: 2021-09-28 15:43:33 +0000 (Tue, 28 Sep 2021) Log Message: ----------- Chart plugin: new argument "legend" Modified Paths: -------------- trunk/lib/plugin/Chart.php Modified: trunk/lib/plugin/Chart.php =================================================================== --- trunk/lib/plugin/Chart.php 2021-09-28 15:43:02 UTC (rev 10597) +++ trunk/lib/plugin/Chart.php 2021-09-28 15:43:33 UTC (rev 10598) @@ -63,7 +63,7 @@ // 'xlabel' => 'x', // TODO // 'ylabel' => 'y', // TODO 'color' => 'green', - // 'legend' => false, // TODO + 'legend' => '', 'data' => false // required ); } @@ -90,7 +90,7 @@ } extract($args); - $html = HTML(); + $html = HTML::figure(); $js = JavaScript('', array('src' => $WikiTheme->_findData('ASCIIsvg.js'))); $html->pushContent($js); @@ -156,6 +156,9 @@ 'script' => $source); $embed = new SVG_HTML("embed", $embedargs); $html->pushContent($embed); + if (isset($legend) && ($legend != '')) { + $html->pushContent(HTML::figcaption($legend)); + } return $html; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |