本文整理汇总了PHP中pImage::drawLegend方法的典型用法代码示例。如果您正苦于以下问题:PHP pImage::drawLegend方法的具体用法?PHP pImage::drawLegend怎么用?PHP pImage::drawLegend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pImage
的用法示例。
在下文中一共展示了pImage::drawLegend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grafico
/**
* Gera um gráfico de linha
* @param array $dados Array no formato array('Label' => array(pontos))
* @param string $tipo linha ou barra
*/
function grafico($dados, $tipo = 'linha')
{
require_once 'exemplos/graficos/pChart/class/pDraw.class.php';
require_once 'exemplos/graficos/pChart/class/pImage.class.php';
require_once 'exemplos/graficos/pChart/class/pData.class.php';
// precisamos ter dados para montar os gráficos
$DataSet = new pData();
// Adicionando os pontos de um gráfico de linha
// horas de trabalho na semana
foreach ($dados as $label => $pontos) {
$DataSet->addPoints($pontos, $label);
}
$DataSet->setAxisName(0, 'Horas');
// unidade
$DataSet->setAxisUnit(0, 'h');
$settings = array("R" => 229, "G" => 11, "B" => 11, "Alpha" => 80);
$DataSet->setPalette("Joao", $settings);
// Labels
$DataSet->addPoints(array('Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'), 'Dias');
$DataSet->setSerieDescription('Dias', 'Dias da Semana');
$DataSet->setAbscissa('Dias');
$Graph = new pImage(700, 230, $DataSet);
$Graph->setFontProperties(array('FontName' => 'exemplos/graficos/pChart/fonts/verdana.ttf', 'FontSize' => 8));
$Graph->setGraphArea(50, 40, 670, 190);
$scale = array('GridR' => 150, 'GridG' => 150, 'GridB' => 150, 'DrawSubTicks' => true, 'CycleBackground' => true);
$Graph->drawScale($scale);
if ($tipo == 'linha') {
$Graph->drawLineChart();
} else {
$Graph->drawBarChart();
}
$Graph->drawLegend(540, 25, array('Style' => LEGEND_ROUND, 'Mode' => LEGEND_VERTICAL));
$Graph->drawText(60, 20, "Horas Trabalhadas");
$Graph->autoOutput();
}
示例2: index
function index()
{
$width = 600;
$height = 230;
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(-4, VOID, VOID, 12, 8, 3), "Female");
$MyData->addPoints(array(3, 12, 15, 8, 5, -5), "Male");
//$MyData->addPoints(array(2,0,5,18,19,22),"Probe 3");
$MyData->setSerieTicks("Male", 4);
$MyData->setAxisName(0, "Number of males, females");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage($width, $height, $MyData);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, $width, $height, 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"=>80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
//$myPicture->setFontProperties(array("FontName"=>pClass."fonts/Silkscreen.ttf","FontSize"=>6));
//$myPicture->drawText(10,13,"drawBarChart() - draw a bar chart",array("R"=>255,"G"=>255,"B"=>255));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => pClass . "fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(250, 55, "Average time to find a set", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw the scale and the 1st chart */
$myPicture->setGraphArea(60, 60, 450, 190);
$myPicture->drawFilledRectangle(60, 60, 450, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("DrawSubTicks" => TRUE));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->setFontProperties(array("FontName" => pClass . "fonts/pf_arma_five.ttf", "FontSize" => 10));
$myPicture->drawBarChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Rounded" => TRUE, "Surrounding" => 30));
//$myPicture->drawBarChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO,"Surrounding"=>30));
$myPicture->setShadow(FALSE);
/* Draw the scale and the 2nd chart */
/*
$myPicture->setGraphArea(500,60,670,190);
$myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
$myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE));
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->drawBarChart();
$myPicture->setShadow(FALSE);
*/
/* Write the chart legend */
//$myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
$myPicture->drawLegend(500, 105, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
/* Render the picture (choose the best way) */
$myPicture->stroke();
}
示例3: RenderValueChart
function RenderValueChart(&$debug2)
{
$conditions = [["BETWEEN 1 AND 19"], ["BETWEEN 20 AND 49"], ["BETWEEN 50 AND 99"], ["BETWEEN 100 AND 199"], ["BETWEEN 200 AND 299"], ["BETWEEN 300 AND 499"], ["BETWEEN 500 AND 999"], ["> 999"]];
$label = ["1-19", "20-49", "50-99", "100-199", "200-299", "300-499", "500-999", ">1000"];
coinValueCount($conditions, $array_result);
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($array_result, "Värde (kr)");
$MyData->setAxisName(0, "Antal");
$MyData->addPoints($label, "Months");
$MyData->setSerieDescription("Months", "Month");
$MyData->setAbscissa("Months");
/* Create the cache object */
$myCache1 = new pCache(array("CacheFolder" => PCHART_PATH . "/class/cache"));
/* Compute the hash linked to the chart data */
$ChartHash1 = $myCache1->getHash($MyData);
/* Test if we got this hash in our cache already */
if ($myCache1->isInCache($ChartHash1)) {
/* If we have it, get the picture from the cache! */
$myCache1->saveFromCache($ChartHash1, WWW_PATH . "/tmp/valuechart.png");
$debug2 = "Old image";
} else {
/* Create the pChart object */
$myPicture = new pImage(700, 400, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = TRUE;
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 399, array("R" => 0, "G" => 0, "B" => 0));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => PCHART_PATH . "/fonts/Forgotte.ttf", "FontSize" => 15, "R" => 80, "G" => 80, "B" => 80));
/* Define the chart area */
$myPicture->setGraphArea(60, 40, 650, 350);
/* Draw the scale */
$scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_START0);
$myPicture->drawScale($scaleSettings);
/* Write the chart legend */
$myPicture->drawLegend(340, 12, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$settings = array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "DisplayR" => 255, "DisplayG" => 255, "DisplayB" => 255, "DisplayShadow" => TRUE, "Surrounding" => 10);
$myPicture->drawBarChart();
/* Push the rendered picture to the cache */
$myCache1->writeToCache($ChartHash1, $myPicture);
/* Render the picture (choose the best way) */
$myPicture->Render(WWW_PATH . "/tmp/valuechart.png");
$debug2 = "Picture rendered";
}
}
示例4: min
}
$nSerie += 1;
}
}
if (isset($arrSeriesY2)) {
$myData->setAxisPosition(1, AXIS_POSITION_RIGHT);
}
$myData->setAxisUnit(0, $unitY);
/* Write the chart legend */
$myPicture->setFontProperties(array("FontName" => "./fonts/simsun.ttc", "FontSize" => $font));
$width_offset = 0;
$height_offset = 0;
if ($legend == 1) {
$sizeLegend = $myPicture->getLegendSize(array("Mode" => LEGEND_VERTICAL));
$widthLegend = min($sizeLegend['Width'], max(120, $width * 0.25));
$myPicture->drawLegend($width - $marg - $widthLegend, $marg + $font_t * 3, array("Style" => LEGEND_BOX, "Mode" => LEGEND_VERTICAL, "Alpha" => 10, "Margin" => 4, "R" => 255, "G" => 255, "B" => 255));
$width_offset += max($widthLegend, 50) + $marg;
}
if ($legend == 2) {
$sizeLegend = $myPicture->getLegendSize(array("Mode" => LEGEND_HORIZONTAL));
$myPicture->drawLegend(max($width * 0.5 - $sizeLegend['Width'] * 0.5, $marg), $height - $marg - $sizeLegend['Height'] * 0.5, array("Style" => LEGEND_BOX, "Mode" => LEGEND_HORIZONTAL, "Alpha" => 10, "Margin" => 4, "R" => 255, "G" => 255, "B" => 255));
$height_offset += $sizeLegend['Height'];
}
$myPicture->setFontProperties(array("FontName" => "./fonts/simhei.ttf", "FontSize" => $font, "R" => 0, "G" => 0, "B" => 0));
/* Define the chart area */
if (isset($arrSeriesY2)) {
$width_offset += 15 + $font * 3;
}
$myPicture->setGraphArea($marg + 18 + $font * 3, $marg + $font_t * 3, $width - $marg - $width_offset, $height - $marg - 18 - $font * 3 - $height_offset);
// $myPicture->setGraphArea(28+$font*3,11+$font_t*3,$width-15-$width_offset,$height-23-$font*3);
/* Draw the scale */
示例5: PlotLine
function PlotLine($rowX, $rowY, $name, $ch)
{
include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pData.class.php";
include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pDraw.class.php";
include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pImage.class.php";
include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pPie.class.php";
//**************************************
$myData = new pData();
$myData->addPoints($rowX, "Serie1");
$myData->setSerieDescription("Serie1", $name);
//$myData->setSerieOnAxis("Serie1",0);
$myData->addPoints($rowY, "Absissa");
$myData->setAbscissa("Absissa");
//$myData->addPoints(array("January","February","March","April","May","June","July","August"),"Absissa");
//$myData->setAbscissa("Absissa");
$myData->setAxisPosition(0, AXIS_POSITION_LEFT);
//$myData->setAxisName(0,"1st axis");
$myData->setAxisUnit(0, "");
$myPicture = new pImage(700, 230, $myData);
$Settings = array("R" => 240, "G" => 242, "B" => 241, "Dash" => 1, "DashR" => 260, "DashG" => 262, "DashB" => 261);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
$Settings = array("StartR" => 252, "StartG" => 255, "StartB" => 254, "EndR" => 252, "EndG" => 255, "EndB" => 254, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 14));
$TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 252, "G" => 252, "B" => 252, "DrawBox" => 1, "BoxAlpha" => 30);
//$myPicture->drawText(350,25,$name,$TextSettings);
$myPicture->setShadow(FALSE);
$myPicture->setGraphArea(50, 50, 675, 190);
//$myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0,"FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6));
$Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL);
$myPicture->drawScale($Settings);
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
$Config = "";
if ($ch == 1) {
$myPicture->drawSplineChart($Config);
}
if ($ch == 2) {
$myPicture->drawBarChart($Config);
}
if ($ch == 3) {
$myPicture->drawLineChart($Config);
}
if ($ch == 4) {
$myPicture->drawPlotChart($Config);
}
if ($ch == 5) {
$myPicture->drawStepChart($Config);
}
if ($ch == 6) {
$myPicture->drawAreaChart($Config);
}
if ($ch == 7) {
$myPicture->drawFilledSplineChart($Config);
}
if ($ch == 8) {
$myPicture->drawFilledStepChart($Config);
}
if ($ch == 9) {
$myPicture->drawStackedAreaChart($Config);
}
$Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL);
$myPicture->drawLegend(563, 16, $Config);
$myPicture->stroke();
}
示例6: pData
/* CAT:Stacked chart */
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(4, VOID, VOID, 12, 8, 3), "Frontend #1");
$MyData->addPoints(array(3, 12, 15, 8, 5, 5), "Frontend #2");
$MyData->addPoints(array(2, 7, 5, 18, 19, 22), "Frontend #3");
$MyData->setAxisName(0, "Average Usage");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale and the chart */
$myPicture->setGraphArea(60, 20, 680, 190);
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0));
$myPicture->setShadow(FALSE);
$myPicture->drawStackedBarChart(array("Surrounding" => -15, "InnerSurrounding" => 15));
/* Write a label */
$myPicture->writeLabel(array("Frontend #1", "Frontend #2", "Frontend #3"), 1, array("DrawVerticalLine" => TRUE));
/* Write the chart legend */
$myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedBarChart.shaded.png");
示例7: render_graph
protected function render_graph($title, pData $MyData, $zoom, $width = 0, $height = 0)
{
// Check graph size sanity
$width = intval($width);
if ($width <= 50 || $width > 4096) {
$width = 700;
}
$height = intval($height);
if ($height <= 60 || $height > 4096) {
$height = 260;
}
$MyData->setSerieDescription("TimeStamp", "time");
$MyData->setAbscissa("TimeStamp");
switch ($zoom) {
case 'hour':
$MyData->setXAxisDisplay(AXIS_FORMAT_TIME, "H:00");
break;
case 'year':
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "Y");
break;
case 'month':
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "Y-m");
break;
case 'day':
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "Y-m-d");
break;
}
/* Create the pChart object */
$myPicture = new pImage($width, $height, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Draw a background */
$Settings = array("R" => 90, "G" => 90, "B" => 90, "Dash" => 1, "DashR" => 120, "DashG" => 120, "DashB" => 120);
$myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_HORIZONTAL, $Settings);
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => AmpConfig::get('prefix') . "/modules/pChart/fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(150, 35, $title, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => AmpConfig::get('prefix') . "/modules/pChart/fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Define the chart area */
$myPicture->setGraphArea(60, 40, $width - 20, $height - 50);
/* Draw the scale */
$scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "RemoveSkippedAxis" => TRUE, "DrawSubTicks" => FALSE, "Mode" => SCALE_MODE_START0, "LabelRotation" => 45, "LabelingMethod" => LABELING_DIFFERENT);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Draw the line chart */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->drawLineChart();
/* Write a label over the chart */
$myPicture->writeLabel("Inbound", 720);
/* Write the chart legend */
$myPicture->drawLegend(280, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
header("Content-Disposition: filename=\"ampache-graph.png\"");
/* Render the picture (choose the best way) */
$myPicture->autoOutput();
}
示例8: drawBarChart
private function drawBarChart($filename, $yAxisLabel, $dataSeries, $labelSeries)
{
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($dataSeries, "Members");
$MyData->setAxisName(0, "Members");
$MyData->addPoints($labelSeries, "Languages");
$MyData->setSerieDescription("Languages", "Languages");
$MyData->setAbscissa("Languages");
/* Create the pChart object */
$myPicture = new pImage(400, 250, $MyData, true);
//$myPicture->drawGradientArea(0,0,500,500,DIRECTION_VERTICAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>100));
//$myPicture->drawGradientArea(0,0,500,500,DIRECTION_HORIZONTAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>20));
$myPicture->setFontProperties(array("FontName" => "../lib/pchart-2.1.3/fonts/verdana.ttf", "FontSize" => 6));
/* Draw the chart scale */
$myPicture->setGraphArea(70, 20, 380, 200);
$myPicture->drawScale(array("CycleBackground" => TRUE, "LabelRotation" => 30, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Create the per bar palette */
$Palette = array("0" => array("R" => 188, "G" => 224, "B" => 46, "Alpha" => 100), "1" => array("R" => 224, "G" => 100, "B" => 46, "Alpha" => 100), "2" => array("R" => 224, "G" => 214, "B" => 46, "Alpha" => 100), "3" => array("R" => 46, "G" => 151, "B" => 224, "Alpha" => 100), "4" => array("R" => 176, "G" => 46, "B" => 224, "Alpha" => 100), "5" => array("R" => 224, "G" => 46, "B" => 117, "Alpha" => 100), "6" => array("R" => 92, "G" => 224, "B" => 46, "Alpha" => 100), "7" => array("R" => 224, "G" => 176, "B" => 46, "Alpha" => 100), "8" => array("R" => 120, "G" => 59, "B" => 19, "Alpha" => 100), "9" => array("R" => 10, "G" => 79, "B" => 39, "Alpha" => 100), "10" => array("R" => 100, "G" => 200, "B" => 59, "Alpha" => 100));
/* Draw the chart */
$myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_OUTSIDE, "DisplayValues" => TRUE, "Surrounding" => 30, "OverrideColors" => $Palette));
/* Write the legend */
$myPicture->drawLegend(570, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
$myPicture->render($filename . ".png");
}
示例9: array
$myPicture->setGraphArea(58, 27, 816, 228);
/* Draw a rectangle */
$myPicture->drawFilledRectangle(58, 27, 816, 228, array("R" => 0, "G" => 0, "B" => 0, "Dash" => TRUE, "DashR" => 0, "DashG" => 51, "DashB" => 51, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
/* Draw the scale */
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
$ScaleSettings = array("XMargin" => 4, "DrawSubTicks" => TRUE, "GridR" => 255, "GridG" => 255, "GridB" => 255, "AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "GridAlpha" => 30, "CycleBackground" => TRUE);
$myPicture->drawScale($ScaleSettings);
/* Draw the spline chart */
$myPicture->drawFilledSplineChart();
/* Write the chart boundaries */
$BoundsSettings = array("MaxDisplayR" => 237, "MaxDisplayG" => 23, "MaxDisplayB" => 48, "MinDisplayR" => 23, "MinDisplayG" => 144, "MinDisplayB" => 237);
$myPicture->writeBounds(BOUND_BOTH, $BoundsSettings);
/* Write the 0 line */
$myPicture->drawThreshold(0, array("WriteCaption" => TRUE));
/* Write the chart legend */
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
$myPicture->drawLegend(560, 266, array("Style" => LEGEND_NOBORDER));
/* Write the 1st data series statistics */
$Settings = array("R" => 188, "G" => 224, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT);
$myPicture->drawText(620, 270, "Max : " . ceil($MyData->getMax("Probe 1")), $Settings);
$myPicture->drawText(680, 270, "Min : " . ceil($MyData->getMin("Probe 1")), $Settings);
$myPicture->drawText(740, 270, "Avg : " . ceil($MyData->getSerieAverage("Probe 1")), $Settings);
/* Write the 2nd data series statistics */
$Settings = array("R" => 224, "G" => 100, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT);
$myPicture->drawText(620, 283, "Max : " . ceil($MyData->getMax("Probe 2")), $Settings);
$myPicture->drawText(680, 283, "Min : " . ceil($MyData->getMin("Probe 2")), $Settings);
$myPicture->drawText(740, 283, "Avg : " . ceil($MyData->getSerieAverage("Probe 2")), $Settings);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawFilledSplineChart.png");
开发者ID:Esleelkartea,项目名称:herramienta_para_autodiagnostico_ADEADA,代码行数:31,代码来源:example.drawFilledSplineChart.php
示例10: eval_ccpc_genGraphLine
/**
* eval_ccpc_genGraphLine - Génère un graphique de type Line 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>
* ['option'] => (array) Liste des labels disponibles<br>
* ['data'][nom de la catégorie][nom du label] => (int) Valeur du label<br>
* ['settings']['min'] => (int) Valeur (ordonnée) minimale<br>
* ['settings']['max'] => (int) Valeur (ordonnée) maximale<br>
* ['settings']['height'] => (int) Hauteur du graphique (en px)<br>
* ['settings']['width'] => (int) Largeur du graphique (en px)
*
*/
function eval_ccpc_genGraphLine($data)
{
// On vérifie les données fournit
if (isset($data) && isset($data['data']) && count($data['data']) > 0 && isset($data['option']) && count($data['option']) > 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
foreach ($data['data'] as $tempDataLegend => $tempDataValue) {
if (is_array($tempDataValue)) {
foreach ($data['option'] as $key) {
if (isset($tempDataValue[$key]) && is_numeric($tempDataValue[$key])) {
$tempDataArray[$tempDataLegend][$key] = $tempDataValue[$key];
} else {
$tempDataArray[$tempDataLegend][$key] = VOID;
}
}
} else {
return FALSE;
}
}
$MyData = new pData();
foreach ($tempDataArray as $key => $value) {
$MyData->addPoints($value, $key);
}
$MyData->addPoints($data['option'], '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/MankSans.ttf", "FontSize" => 14, "R" => 80, "G" => 80, "B" => 80));
// On détermine les limites
$myPicture->setGraphArea(0, 0, $width, $height - 30);
$scaleSettings = array("DrawSubTicks" => TRUE);
if (isset($data['settings']['min']) && is_numeric($data['settings']['min']) && isset($data['settings']['max']) && is_numeric($data['settings']['max']) && $data['settings']['min'] < $data['settings']['max']) {
// Prise en charge de la possibilité d'imposer le min et le max
$scaleSettings['Mode'] = SCALE_MODE_MANUAL;
$scaleSettings['ManualScale'][0] = array('Min' => $data['settings']['min'], 'Max' => $data['settings']['max']);
// Min et Max sur l'axe des ordonnées
}
$myPicture->drawScale($scaleSettings);
$myPicture->drawLegend(10, 10, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
$settings = array("Surrounding" => -30, "InnerSurrounding" => 30, "DisplayValues" => TRUE, "ORIENTATION_HORIZONTAL" => TRUE);
$myPicture->drawLineChart($settings);
$myPicture->render($filePath);
return $filePathURI;
}
} else {
return FALSE;
}
}
示例11: min
$myData->setSerieDescription($field, "右){$field}");
}
}
$nSerie += 1;
}
}
if (isset($arrSeriesY2)) {
$myData->setAxisPosition(1, AXIS_POSITION_RIGHT);
}
$myData->setAxisUnit(0, $unitY);
/* Write the chart legend */
$sizeLegend = $myPicture->getLegendSize(array("Mode" => LEGEND_VERTICAL));
$widthLegend = min($sizeLegend['Width'], max(120, $width * 0.25));
if ($legend > 0) {
$myPicture->setFontProperties(array("FontName" => "./fonts/simsun.ttc", "FontSize" => $font, "R" => 0, "G" => 0, "B" => 0));
$myPicture->drawLegend($width - 5 - $widthLegend, 5 + $font_t * 3, array("Style" => LEGEND_BOX, "Mode" => LEGEND_VERTICAL, "Alpha" => 10, "Margin" => 4, "R" => 255, "G" => 255, "B" => 255));
}
$myPicture->setFontProperties(array("FontName" => "./fonts/simhei.ttf", "FontSize" => $font, "R" => 0, "G" => 0, "B" => 0));
/* Define the chart area */
$width_offset = 0;
if ($legend > 0) {
$width_offset += max($widthLegend, 50);
}
if (isset($arrSeriesY2)) {
$width_offset += 15 + $font * 3;
}
$myPicture->setGraphArea(28 + $font * 3, 11 + $font_t * 3, $width - 15 - $width_offset, $height - 23 - $font * 3);
#$myPicture->setGraphArea(28+$font*3,3+$font_t*3,$width-15-$width_offset,$height-23-$font*3);
/* Draw the scale */
$scaleMode = ($chartType == 'bar2' or $chartType == 'area2') ? SCALE_MODE_ADDALL_START0 : SCALE_MODE_START0;
if ($labelSkip == -1) {
示例12: sortByHigh
$myData->setSerieDescription("Serie4", "Low");
$myData->setSerieOnAxis("Serie4", 0);
$myData->addPoints($famArray, "Absissa");
$myData->setAbscissa("Absissa");
$myData->setAxisPosition(0, AXIS_POSITION_LEFT);
$myData->setAxisName(0, "");
$myData->setAxisUnit(0, "");
$myPicture = new pImage(700, 230, $myData);
$Settings = array("R" => 220, "G" => 220, "B" => 220);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
$myPicture->drawRectangle(0, 0, 799, 249, array("R" => 162, "G" => 181, "B" => 205));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => "../../pChart/fonts/Forgotte.ttf", "FontSize" => 14));
$TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 0, "G" => 0, "B" => 0);
$myPicture->drawText(350, 25, "Vulnerability Distribution (by Family)", $TextSettings);
$myPicture->setShadow(FALSE);
$myPicture->setGraphArea(100, 70, 675, 210);
$myPicture->setFontProperties(array("R" => 0, "G" => 0, "B" => 0, "FontName" => "../../pChart/fonts/pf_arma_five.ttf", "FontSize" => 6));
$Settings = array("Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL_START0, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL);
$myPicture->drawScale($Settings);
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
$Config = array("DisplayValues" => 1, "Rounded" => 1, "AroundZero" => 1);
$myPicture->drawStackedBarChart($Config);
$Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "../../pChart/fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL);
$myPicture->drawLegend(535, 16, $Config);
$myPicture->stroke();
function sortByHigh($a, $b)
{
return strnatcmp($b['critical'], $a['critical']);
}
// sort alphabetically by name
示例13: array
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
if ($g_gradient_enabled == "on") {
list($StartR, $StartG, $StartB) = extractColors($g_gradient_start);
list($EndR, $EndG, $EndB) = extractColors($g_gradient_end);
$Settings = array("StartR" => $StartR, "StartG" => $StartG, "StartB" => $StartB, "EndR" => $EndR, "EndG" => $EndG, "EndB" => $EndB, "Alpha" => 50);
if ($g_direction == "vertical") {
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
} else {
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, $Settings);
}
} else {
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
}
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 14));
$TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 255, "G" => 255, "B" => 255);
$myPicture->drawText(350, 25, $title, $TextSettings);
$myPicture->setShadow(FALSE);
$myPicture->setGraphArea(50, 50, 675, 190);
$myPicture->setFontProperties(array("R" => 0, "G" => 0, "B" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6));
$Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL);
$myPicture->drawScale($Settings);
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
$Config = array("AroundZero" => 1);
$myPicture->{$dibujo}($Config);
$Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL, "Family" => LEGEND_FAMILY_LINE);
$myPicture->drawLegend(500, 10, $Config);
$myPicture->stroke();
示例14: pImage
$data->addPoints($readings, 'Disk Used');
$data->setAxisName(0, "Gigabytes");
}
}
}
// Read data from the database, and add it
$data->addPoints($times, "Labels");
$data->setSerieDescription("Labels", "Time of day");
$data->setAbscissa("Labels");
$chart = new pImage(700, 230, $data);
/* Turn of Antialiasing */
$chart->Antialias = FALSE;
/* Add a border to the picture */
$chart->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the chart title */
$chart->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 11));
$chart->drawText(150, 35, $title, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$chart->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6));
/* Define the chart area */
$chart->setGraphArea(60, 40, 650, 200);
/* Draw the scale */
$chart->drawScale($scaleSettings);
/* Write the chart legend */
$chart->drawLegend(540, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Turn on Antialiasing */
$chart->Antialias = TRUE;
/* Draw the area chart */
$chart->drawAreaChart();
/* Render the picture (choose the best way) */
$chart->stroke();
示例15: drawImage
public function drawImage()
{
$qr_result = $this->values;
//var_dump($qr_result);die();
$va_columns = $this->parameters["columns"];
$width = $this->parameters["width"];
$format = $this->parameters["format"];
$va_charting_columns = $this->parameters["charting_columns"];
$va_chart_types = $this->parameters["chart_types"];
$qr_result->seek();
if ($qr_result->numRows() == 0) {
//if no result nothing to do
return false;
}
// Loading chart format specifications
// TODO : this coding part should be out of this function, sending values in 1 parameter
if (is_array($va_chart_types)) {
foreach ($va_chart_types as $type => $settings) {
if ($type == $format) {
$chart_type = $settings["googletype"];
$message = $settings["message"];
}
}
}
/* Create and populate the pData object */
$MyData = new pData();
// Fulfillment of the results
$va_row_no = 0;
$va_content = array();
while ($qr_result->nextRow()) {
$va_column_no = 0;
foreach ($va_columns as $va_column => $va_column_label) {
// only render columns specified in XML field charting_columns
if (in_array($va_column_label, $va_charting_columns)) {
$va_content[$va_column_label][$va_row_no] = $qr_result->get($va_column_label);
$va_column_no++;
}
}
$va_row_no++;
}
//var_dump($va_content);
$va_row_no = 0;
foreach ($va_charting_columns as $va_column_label) {
//print "MyData->addPoints(\"".implode("\",\"",$va_content[$va_column_label])."\",\"".$va_column_label."\");<br/>";
$MyData->addPoints($va_content[$va_column_label], $va_column_label);
if ($va_row_no == 0) {
//print "MyData->setAbscissa(\"Labels\")<br/>";
$MyData->setAbscissa($va_column_label);
} else {
//print "MyData->setSerieDescription(\"".$va_column_label."\",\"".$va_column_label."\");<br/>";
$MyData->setSerieDescription($va_column_label, $va_column_label);
}
$va_row_no++;
}
/* Create the pChart object */
$myPicture = new pImage($width, $width / 2, $MyData);
/* Set the common properties */
$myPicture->setFontProperties(array("FontName" => __CA_STATISTICSVIEWER_CLASS_DIR__ . "/fonts/verdana.ttf", "FontSize" => 0.014 * $width, "R" => 80, "G" => 80, "B" => 80));
$RectangleSettings = array("R" => 200, "G" => 200, "B" => 200);
$myPicture->drawRectangle(1, 1, $width - 1, $width / 2 - 1, $RectangleSettings);
$myPicture->setGraphArea($width / 9, $width / 10, $width * 0.75, $width * 0.4);
// if not pie, draw the legend
if ($format != "pie") {
$myPicture->drawLegend($width * 0.8, $width * 0.05, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
}
switch ($format) {
case "bar":
$myPicture->drawScale(array("Pos" => SCALE_POS_TOPBOTTOM, "DrawSubTicks" => FALSE, "RemoveYAxis" => TRUE, "GridAlpha" => 90, "DrawXLines" => FALSE));
$myPicture->drawBarChart();
break;
case "column":
$myPicture->drawScale(array("DrawSubTicks" => FALSE, "RemoveYAxis" => TRUE, "GridAlpha" => 90, "DrawXLines" => FALSE));
$myPicture->drawBarChart();
break;
case "step":
$myPicture->drawScale(array("DrawXLines" => FALSE, "DrawYLines" => ALL, "GridR" => 127, "GridG" => 127, "GridB" => 127));
$myPicture->drawStepChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO));
break;
case "area":
$myPicture->drawScale(array("DrawXLines" => FALSE, "DrawYLines" => ALL, "GridR" => 127, "GridG" => 127, "GridB" => 127));
$myPicture->drawAreaChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO));
break;
case "pie":
$PieChart = new pPie($myPicture, $MyData);
$PieChart->draw2DPie(0.4 * $width, 0.25 * $width, array("WriteValues" => PIE_VALUE_PERCENTAGE, "ValueR" => 95, "ValueG" => 95, "ValueB" => 95, "ValuePadding" => 0.03 * $width, "Radius" => 0.16 * $width, "SecondPass" => TRUE, "Border" => TRUE, "Precision" => 0));
$myPicture->setShadow(FALSE);
$myPicture->setFontProperties(array("FontName" => __CA_STATISTICSVIEWER_CLASS_DIR__ . "/fonts/verdana.ttf", "FontSize" => 0.018 * $width, "R" => 80, "G" => 80, "B" => 80));
$PieChart->drawPieLegend(0.8 * $width, 0.05 * $width, array("Style" => LEGEND_NOBORDER, "BoxSize" => $width / 60, "FontR" => 0, "FontG" => 0, "FontB" => 0));
break;
case "line":
default:
$myPicture->drawScale(array("DrawXLines" => FALSE, "DrawYLines" => ALL, "GridR" => 127, "GridG" => 127, "GridB" => 127));
$myPicture->drawLineChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO));
break;
}
/* Render the picture (choose the best way) */
$myPicture->autoOutput();
}