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


PHP pImage::drawBarChartAli方法代码示例

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


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

示例1: eval_ccpc_genGraphPie

/**
 * eval_ccpc_genGraphPie - Génère un graphique de type camenbert sous forme d'image au format PNG
 *
 * @category : eval_ccpc_functions
 * @param array $data Données à partir desquelles le graphique est généré
 * @return string URL de l'image générée
 *
 * @Author Ali Bellamine
 *
 * Structure de $data :<br>
 * 	['data'][nom du label] => (int) Valeur liée au label<br>
 * 	['settings']['height'] => (int) Hauteur du graphique (en px)<br>
 * 	['settings']['width'] => (int) Largeur du graphique (en px)
 *
 */
function eval_ccpc_genGraphPie($data)
{
    // On vérifie les données fournit
    if (isset($data) && isset($data['data']) && count($data['data']) > 0) {
        // On récupère le hash de $data
        $hash = md5(json_encode($data));
        // Chemin du fichier
        $filePath = PLUGIN_PATH . 'cache/' . $hash . '.png';
        $filePathURI = ROOT . 'evaluations/ccpc/cache/' . $hash . '.png';
        // Si le hash existe déjà : on renvoie le lien de l'image // sinon en crée le graphique
        if (is_file($filePath)) {
            return $filePathURI;
        } else {
            // On crée l'image
            /* On inclut la librairie */
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pData.class.php';
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pDraw.class.php';
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pImage.class.php';
            /* On crée l'objet pData */
            // Préparation des données
            $tempDataArray = array();
            // Contient les données chiffrés de chaque part du camenbert
            $tempLegendArray = array();
            // Contient la légend chaque part de camenbert
            foreach ($data['data'] as $tempDataLegend => $tempDataValue) {
                $tempLegendArray[] = $tempDataLegend;
                if (isset($tempDataValue) && is_numeric($tempDataValue)) {
                    $tempDataArray[] = $tempDataValue;
                } else {
                    return FALSE;
                }
            }
            $MyData = new pData();
            $MyData->addPoints($tempDataArray, 'Values');
            $MyData->addPoints($tempLegendArray, 'Label');
            $MyData->setAbscissa("Label");
            /* On crée l'objet pChart */
            if (isset($data['settings']['width'])) {
                $width = $data['settings']['width'];
            } else {
                $width = 600;
            }
            if (isset($data['settings']['height'])) {
                $height = $data['settings']['height'];
            } else {
                $height = 300;
            }
            $myPicture = new pImage($width, $height, $MyData);
            $myPicture->setFontProperties(array("FontName" => PLUGIN_PATH . 'core/pChart2.1.4/fonts/verdana.ttf', "FontSize" => 8, "R" => 223, "G" => 223, "B" => 223));
            /* Set the graph area */
            $myPicture->setGraphArea(10, 20, $width - 20, $height - 20);
            $myPicture->drawGradientArea(10, 20, $width - 20, $height - 20, DIRECTION_HORIZONTAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 30));
            /* Draw the chart scale */
            $scaleSettings = array("RemoveXAxis" => TRUE, "AxisAlpha" => 10, "TickAlpha" => 10, "DrawXLines" => FALSE, "Mode" => SCALE_MODE_START0, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM);
            $myPicture->drawScale($scaleSettings);
            /* Turn on shadow computing */
            $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
            /* Draw the chart */
            $myPicture->drawBarChartAli(array("DisplayValues" => TRUE, "DisplayShadow" => TRUE, "DisplayPos" => LABEL_POS_INSIDE, "Rounded" => TRUE, "Surrounding" => 30));
            $myPicture->render($filePath);
            return $filePathURI;
        }
    } else {
        return FALSE;
    }
}
开发者ID:alibell,项目名称:PAS,代码行数:81,代码来源:fnGraphGen.php


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