function plot($lift) { $MyData = new pData(); $positivelift = array(); $negativelift = array(); foreach ($lift as $heading => $fpm) { if ($fpm > 0) { $positivelift[$heading] = $fpm; $negativelift[$heading] = 0; } else { $negativelift[$heading] = -$fpm; $positivelift[$heading] = 0; } } $MyData->addPoints($positivelift, "ScoreA"); // green $MyData->addPoints($negativelift, "ScoreB"); // red $MyData->addPoints(array_keys($lift), "Coord"); $MyData->setAbscissa("Coord"); $myPicture = new pImage(700, 700, $MyData); $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $SplitChart = new pRadar(); $myPicture->setGraphArea(10, 10, 690, 690); $Options = array("LabelPos" => RADAR_LABELS_HORIZONTAL, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 50, "EndR" => 32, "EndG" => 109, "EndB" => 174, "EndAlpha" => 30), "DrawPoly" => TRUE, "PolyAlpha" => 50, "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6); $SplitChart->drawPolar($myPicture, $MyData, $Options); $myPicture->autoOutput("lift.png"); }
public function drawCompetencyExpertsRadar($img, $points, $competences, $roles, $skale, $palettes) { $MyData = new \pData(); /*$palettes = array( array("R"=>84,"G"=>85,"B"=>86), array("R"=>21,"G"=>101,"B"=>112), array("R"=>223,"G"=>72,"B"=>11), array("R"=>10,"G"=>120,"B"=>40), array("R"=>200,"G"=>150,"B"=>20), );*/ /*$palettes = array( 0 => array('R' => 191, 'G' => 191, 'B' => 191), 1 => array('R' => 226, 'G' => 24, 'B' => 54), 2 => array('R' => 244, 'G' => 122, 'B' => 32), 3 => array('R' => 146, 'G' => 0, 'B' => 61), 4 => array('R' => 91, 'G' => 74, 'B' => 63), 5 => array('R' => 55, 'G' => 96, 'B' => 146), 6 => array('R' => 119, 'G' => 147, 'B' => 60), );*/ $i = 0; foreach ($points as $roleID => $data) { $MyData->addPoints($data, "Score" . $roleID); $MyData->setSerieDescription("Score" . $roleID, $roles[$roleID]['name']); $MyData->setPalette("Score" . $roleID, $palettes[$i++]); } $labels = array(); foreach ($competences as $competency) { $labels[] = strpos($competency, ' ') !== false ? $this->divideString($competency) : $competency; } $MyData->addPoints($labels, "Labels"); $MyData->setAbscissa("Labels"); $myPicture = new \pImage(460 * 1.53, 330 * 1.53, $MyData); $myPicture->setFontProperties(array("FontName" => dirname(__FILE__) . '/fonts/calibri.ttf', "FontSize" => round(7 * 1.53), "R" => 80, "G" => 80, "B" => 80)); /* Create the pRadar object */ $SplitChart = new \pRadar(); /* Draw a radar chart */ $myPicture->setGraphArea(70 * 1.53, 30 * 1.53, 340 * 1.53, 300 * 1.53); $Options = array("Layout" => RADAR_LAYOUT_STAR, 'SegmentHeight' => ceil($skale['max'] / 4), "FontName" => dirname(__FILE__) . '/fonts/calibri.ttf', "FontSize" => round(7 * 1.53), 'LabelPos' => RADAR_LABELS_HORIZONTAL, 'LineWidth' => 3); $SplitChart->drawRadar($myPicture, $MyData, $Options); $myPicture->render($img); }
/* Draw a solid background */ $Settings = array("R" => 179, "G" => 217, "B" => 91, "Dash" => 1, "DashR" => 199, "DashG" => 237, "DashB" => 111); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Overlay some gradient areas */ $Settings = array("StartR" => 194, "StartG" => 231, "StartB" => 44, "EndR" => 43, "EndG" => 107, "EndB" => 58, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "pRadar - Draw radar charts", array("R" => 255, "G" => 255, "B" => 255)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Create the pRadar object */ $SplitChart = new pRadar(); /* Draw a radar chart */ $myPicture->setGraphArea(10, 25, 300, 225); $Options = array("Layout" => RADAR_LAYOUT_STAR, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 100, "EndR" => 207, "EndG" => 227, "EndB" => 125, "EndAlpha" => 50), "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6); $SplitChart->drawRadar($myPicture, $MyData, $Options); /* Draw a radar chart */ $myPicture->setGraphArea(390, 25, 690, 225); $Options = array("Layout" => RADAR_LAYOUT_CIRCLE, "LabelPos" => RADAR_LABELS_HORIZONTAL, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 50, "EndR" => 32, "EndG" => 109, "EndB" => 174, "EndAlpha" => 30), "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6); $SplitChart->drawRadar($myPicture, $MyData, $Options); /* Write the chart legend */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->drawLegend(235, 205, array("Style" => LEGEND_BOX, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.radar.png");
$MyData->addPoints(array(20, 40, 50, 12, 10, 30, 40, 50, 60), "ScoreB"); $MyData->setSerieDescription("ScoreA", "Coverage A"); $MyData->setSerieDescription("ScoreB", "Coverage B"); /* Define the absissa serie */ $MyData->addPoints(array(40, 80, 120, 160, 200, 240, 280, 320, 360), "Coord"); $MyData->setAbscissa("Coord"); /* Create the pChart object */ $myPicture = new pImage(300, 300, $MyData); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMapPolarChart", IMAGE_MAP_STORAGE_FILE, "PolarChart", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMapPolarChart", IMAGE_MAP_STORAGE_FILE, "PolarChart", "../tmp"); /* Draw the background */ $myPicture->drawGradientArea(0, 0, 300, 300, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 240, "EndG" => 240, "EndB" => 240, "Alpha" => 100)); /* Add a border to the picture */ $RectangleSettings = array("R" => 180, "G" => 180, "B" => 180, "Alpha" => 100); $myPicture->drawRectangle(0, 0, 299, 299, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Create the pRadar object */ $SplitChart = new pRadar(); /* Draw a radar chart */ $myPicture->setGraphArea(10, 10, 290, 290); $Options = array("RecordImageMap" => TRUE, "LabelPos" => RADAR_LABELS_HORIZONTAL, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 50, "EndR" => 32, "EndG" => 109, "EndB" => 174, "EndAlpha" => 30), "AxisRotation" => 0, "DrawPoly" => TRUE, "PolyAlpha" => 50, "FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6); $SplitChart->drawPolar($myPicture, $MyData, $Options); /* Render the picture (choose the best way) */ $myPicture->autoOutput("../tmp/PolarChart.png");
public function drawCompetencyExpertsRadar($img, $points, $competences, $roles, $skale) { $MyData = new \pData(); $palettes = array(array("R" => 84, "G" => 85, "B" => 86), array("R" => 21, "G" => 101, "B" => 112), array("R" => 223, "G" => 72, "B" => 11), array("R" => 10, "G" => 120, "B" => 40), array("R" => 200, "G" => 150, "B" => 20)); $i = 0; foreach ($points as $roleID => $data) { $MyData->addPoints($data, "Score" . $roleID); $MyData->setSerieDescription("Score" . $roleID, $roles[$roleID]['name']); $MyData->setPalette("Score" . $roleID, $palettes[$i++]); } $labels = array(); foreach ($competences as $competency) { $labels[] = strpos($competency, ' ') !== false ? $this->divideString($competency) : $competency; } $MyData->addPoints($labels, "Labels"); $MyData->setAbscissa("Labels"); $myPicture = new \pImage(700 * 1.53, 700 * 1.53, $MyData); $myPicture->setFontProperties(array("FontName" => dirname(__FILE__) . '/fonts/georgia.ttf', "FontSize" => round(14 * 1.53), "R" => 80, "G" => 80, "B" => 80)); /* Create the pRadar object */ $SplitChart = new \pRadar(); /* Draw a radar chart */ $myPicture->setGraphArea(10 * 1.53, 80 * 1.53, 640 * 1.53, 640 * 1.53); $Options = array("Layout" => RADAR_LAYOUT_STAR, 'SegmentHeight' => ceil($skale['max'] / 4), "FontName" => dirname(__FILE__) . '/fonts/georgia.ttf', "FontSize" => round(14 * 1.53), 'LabelPos' => RADAR_LABELS_HORIZONTAL, 'LineWidth' => 3); $SplitChart->drawRadar($myPicture, $MyData, $Options); /* Write the chart legend */ $myPicture->setFontProperties(array("FontName" => dirname(__FILE__) . '/fonts/georgia.ttf', "FontSize" => round(12 * 1.53))); $myPicture->drawLegend(220 * 1.53, 20 * 1.53, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); $myPicture->render($img); }
function buildChartImageRadar($chartPicture, $chartData, $recordImageMap) { $SplitChart = new pRadar(); $Options = array("LabelPos" => RADAR_LABELS_HORIZONTAL, "RecordImageMap" => $recordImageMap); $SplitChart->drawRadar($chartPicture, $chartData, $Options); }
/** * eval_ccpc_genGraphRadar - Génère un graphique de type Radar simple 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 du label<br> * ['settings']['max'] => (int) Valeur maximale<br> * ['settings']['height'] => (int) Hauteur du graphique (en px)<br> * ['settings']['width'] => (int) Largeur du graphique (en px) * */ function eval_ccpc_genGraphRadar($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'; 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/pRadar.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 $tempLegendArray = array(); // Contient les légendes $tempDataArray = array(); // Contient les données chiffrés foreach ($data['data'] as $tempDataLegend => $tempDataValue) { $tempLegendArray[] = $tempDataLegend; if (is_numeric($tempDataValue)) { $tempDataArray[] = $tempDataValue; } else { return FALSE; } } $MyData = new pData(); $MyData->addPoints($tempDataArray, 'Valeurs'); $MyData->setPalette("Valeurs", array("R" => 150, "G" => 5, "B" => 217)); $MyData->addPoints($tempLegendArray, 'Label'); $MyData->setAbscissa("Label"); $MyData->setSerieDescription("Label", "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, TRUE); $myPicture->setFontProperties(array("FontName" => PLUGIN_PATH . 'core/pChart2.1.4/fonts/verdana.ttf', "FontSize" => 10, "R" => 0, "G" => 0, "B" => 0)); // On détermine les limites $myPicture->setGraphArea(0, 0, $width, $height - 30); /* On crée l'objet pRadar */ $SplitChart = new pRadar(); $Options = array("DrawPoly" => TRUE, "LabelPos" => RADAR_LABELS_HORIZONTAL, "WriteValues" => TRUE, "WriteValuesInBubble " => TRUE, "InnerBubbleR" => 255, "InnerBubbleG" => 255, "InnerBubbleB" => 255, "ValueFontSize" => 20, "ValuePadding" => 10, "Layout" => RADAR_LAYOUT_CIRCLE, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 100, "EndR" => 207, "EndG" => 227, "EndB" => 125, "EndAlpha" => 50)); if (isset($data['settings']['max']) && is_numeric($data['settings']['max'])) { // Prise en charge de la possibilité d'imposer le min et le max $Options['FixedMax'] = $data['settings']['max']; } $SplitChart->drawRadar($myPicture, $MyData, $Options); $myPicture->render($filePath); return $filePathURI; } } else { return FALSE; } }
function pch_kiviat_graph($graph_type, $data_values, $legend_values, $width, $height, $font, $font_size) { /* CAT:Radar/Polar charts */ /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints($data_values, "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints($legend_values, "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage($width, $height, $MyData, TRUE); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => $font_size, "R" => 80, "G" => 80, "B" => 80)); /* Create the pRadar object */ $SplitChart = new pRadar(); /* Draw a radar chart */ $myPicture->setGraphArea(20, 25, $width - 10, $height - 10); /* Draw an AA pie chart */ switch ($graph_type) { case "radar": $Options = array("SkipLabels" => 0, "LabelPos" => RADAR_LABELS_HORIZONTAL, "LabelMiddle" => FALSE, "Layout" => RADAR_LAYOUT_STAR, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 100, "EndR" => 207, "EndG" => 227, "EndB" => 125, "EndAlpha" => 50), "FontName" => $font, "FontSize" => $font_size); $SplitChart->drawRadar($myPicture, $MyData, $Options); break; case "polar": $Options = array("Layout" => RADAR_LAYOUT_CIRCLE, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 100, "EndR" => 207, "EndG" => 227, "EndB" => 125, "EndAlpha" => 50), "FontName" => $font, "FontSize" => $font_size); $SplitChart->drawRadar($myPicture, $MyData, $Options); break; } /* Render the picture */ $myPicture->stroke(); }
$myData->setSerieDescription('Legend', ''); $myData->setAbscissa('Legend'); /* Will replace the whole color scheme by the selected palette */ $myData->loadPalette(dirname(dirname(dirname(__FILE__))) . '/lib/pchart2/palettes/' . $PALETTE . '.color', TRUE); /* Create a pChart object and associate your dataset */ $myPicture = new pImage($WIDTH, $HEIGHT, $myData); /* Draw border around the chart */ $myPicture->drawRectangle(0, 0, $WIDTH - 1, $HEIGHT - 1, array("R" => 0, "G" => 0, "B" => 0)); /* Draw chart background */ $myPicture->drawFilledRectangle(0, 0, $WIDTH, $HEIGHT, array("R" => $COLORS[1]['R'], "G" => $COLORS[1]['G'], "B" => $COLORS[1]['B'], "Alpha" => 10)); /* Define the boundaries of the graph area */ $myPicture->setGraphArea(20, 20, $WIDTH - 20, $HEIGHT - 40); /* Choose a nice font */ switch ($FONT['type']) { case 'serif': $fontname = dirname(dirname(dirname(__FILE__))) . '/lib/pchart2/fonts/LiberationSerif-Regular.ttf'; break; case 'sans': $fontname = dirname(dirname(dirname(__FILE__))) . '/lib/pchart2/fonts/LiberationSans-Regular.ttf'; break; } $myPicture->setFontProperties(array('FontName' => $fontname, 'FontSize' => $FONT['size'])); /* Draw chart legend */ $myPicture->drawLegend(20, $HEIGHT - 30, array("R" => $COLORS[1]['R'], "G" => $COLORS[1]['G'], "B" => $COLORS[1]['B'], "Alpha" => 20)); /* Create the radar object */ $SplitChart = new pRadar(); /* Draw a simple radar chart */ $mySettings = array("Layout" => RADAR_LAYOUT_STAR, "LabelPos" => RADAR_LABELS_HORIZONTAL, "BackgroundGradient" => array("StartR" => $COLORS[3]['R'], "StartG" => $COLORS[3]['G'], "StartB" => $COLORS[3]['B'], "StartAlpha" => 30, "EndR" => $COLORS[5]['R'], "EndG" => $COLORS[5]['G'], "EndB" => $COLORS[5]['B'], "EndAlpha" => 30), "SegmentHeight" => 1, "Segments" => 3, "DrawPoly" => true); $SplitChart->drawRadar($myPicture, $myData, $mySettings); /* Build the PNG file and send it to the web browser */ $myPicture->Stroke();