当前位置: 首页>>代码示例>>PHP>>正文


PHP WT_I18N::percentage方法代码示例

本文整理汇总了PHP中WT_I18N::percentage方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_I18N::percentage方法的具体用法?PHP WT_I18N::percentage怎么用?PHP WT_I18N::percentage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WT_I18N的用法示例。


在下文中一共展示了WT_I18N::percentage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: print_chart_by_decade

function print_chart_by_decade($data, $title)
{
    $count = 0;
    $vmax = 0;
    foreach ($data as $v) {
        $n = strlen($v);
        $vmax = max($vmax, $n);
        $count += $n;
    }
    if ($count < 1) {
        return;
    }
    $chart_url = "https://chart.googleapis.com/chart?cht=bvs";
    // chart type
    $chart_url .= "&amp;chs=360x150";
    // size
    $chart_url .= "&amp;chbh=3,3";
    // bvg : 4,1,2
    $chart_url .= "&amp;chf=bg,s,FFFFFF99";
    //background color
    $chart_url .= "&amp;chco=0000FF,FFA0CB";
    // bar color
    $chart_url .= "&amp;chtt=" . rawurlencode($title);
    // title
    $chart_url .= "&amp;chxt=x,y,r";
    // axis labels specification
    $chart_url .= "&amp;chxl=0:|&lt;|||";
    // <1570
    for ($y = 1600; $y < 2030; $y += 50) {
        $chart_url .= $y . "|||||";
        // x axis
    }
    $chart_url .= "|1:||" . rawurlencode(WT_I18N::percentage($vmax / $count));
    // y axis
    $chart_url .= "|2:||";
    $step = $vmax;
    for ($d = $vmax; $d > 0; $d--) {
        if ($vmax < $d * 10 + 1 && $vmax % $d == 0) {
            $step = $d;
        }
    }
    if ($step == $vmax) {
        for ($d = $vmax - 1; $d > 0; $d--) {
            if ($vmax - 1 < $d * 10 + 1 && ($vmax - 1) % $d == 0) {
                $step = $d;
            }
        }
    }
    for ($n = $step; $n < $vmax; $n += $step) {
        $chart_url .= $n . "|";
    }
    $chart_url .= rawurlencode($vmax . " / " . $count);
    // r axis
    $chart_url .= "&amp;chg=100," . round(100 * $step / $vmax, 1) . ",1,5";
    // grid
    $chart_url .= "&amp;chd=s:";
    // data : simple encoding from A=0 to 9=61
    $CHART_ENCODING61 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    for ($y = 1570; $y < 2030; $y += 10) {
        $chart_url .= $CHART_ENCODING61[(int) (substr_count($data[$y], "M") * 61 / $vmax)];
    }
    $chart_url .= ",";
    for ($y = 1570; $y < 2030; $y += 10) {
        $chart_url .= $CHART_ENCODING61[(int) (substr_count($data[$y], "F") * 61 / $vmax)];
    }
    $html = '<img src="' . $chart_url . '" alt="' . $title . '" title="' . $title . '" class="gchart">';
    return $html;
}
开发者ID:brambravo,项目名称:webtrees,代码行数:68,代码来源:functions_print_lists.php

示例2: chartFamsWithSources

 function chartFamsWithSources($params = null)
 {
     global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
     if ($params === null) {
         $params = array();
     }
     if (isset($params[0]) && $params[0] != '') {
         $size = strtolower($params[0]);
     } else {
         $size = $WT_STATS_S_CHART_X . "x" . $WT_STATS_S_CHART_Y;
     }
     if (isset($params[1]) && $params[1] != '') {
         $color_from = strtolower($params[1]);
     } else {
         $color_from = $WT_STATS_CHART_COLOR1;
     }
     if (isset($params[2]) && $params[2] != '') {
         $color_to = strtolower($params[2]);
     } else {
         $color_to = $WT_STATS_CHART_COLOR2;
     }
     $sizes = explode('x', $size);
     $tot_fam = $this->_totalFamilies();
     if ($tot_fam == 0) {
         return '';
     } else {
         $tot_sfam_per = round($this->_totalFamsWithSources() / $tot_fam, 3);
         $chd = self::_array_to_extended_encoding(array(100 - 100 * $tot_sfam_per, 100 * $tot_sfam_per));
         $chl = WT_I18N::translate('Without sources') . ' - ' . WT_I18N::percentage(1 - $tot_sfam_per, 1) . '|' . WT_I18N::translate('With sources') . ' - ' . WT_I18N::percentage($tot_sfam_per, 1);
         $chart_title = WT_I18N::translate('Families with sources');
         return "<img src=\"https://chart.googleapis.com/chart?cht=p3&amp;chd=e:{$chd}&chs={$size}&amp;chco={$color_from},{$color_to}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
     }
 }
开发者ID:sadr110,项目名称:webtrees,代码行数:33,代码来源:Stats.php


注:本文中的WT_I18N::percentage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。