本文整理汇总了PHP中pChart::drawStackedBarGraph方法的典型用法代码示例。如果您正苦于以下问题:PHP pChart::drawStackedBarGraph方法的具体用法?PHP pChart::drawStackedBarGraph怎么用?PHP pChart::drawStackedBarGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pChart
的用法示例。
在下文中一共展示了pChart::drawStackedBarGraph方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _showGraph_pChart
public function _showGraph_pChart($buscarBarra)
{
// Dataset definition
$DataSet = new pData();
if ($buscarBarra == "semana") {
$semana = array("1era Semana", "2da Semana", "3era Semana", "4ta Semana");
$cantidadSemanal = array(2, 4, 5, 6);
$DataSet->AddPoint($semana, "Serie1");
$DataSet->AddPoint($cantidadSemanal, "Serie2");
// Initialise the graph
define("WIDTH", 500);
define("HEIGHT", 500);
$Test = new pChart(WIDTH, HEIGHT);
$Test->setFontProperties("../font/arial.ttf", 7);
$Test->setGraphArea(40, 30, WIDTH - 30, HEIGHT - 30);
$Test->drawFilledRoundedRectangle(7, 7, WIDTH - 7, HEIGHT - 7, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, WIDTH - 5, HEIGHT - 5, 5, 230, 230, 230);
} elseif ($buscarBarra == "mes") {
$mensual = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Setiembre", "Octubre");
$cantidadMensual = array(4, 6, 11, 23, 9, 2, 30, 20, 12, 45);
$DataSet->AddPoint($mensual, "Serie1");
$DataSet->AddPoint($cantidadMensual, "Serie2");
// Initialise the graph
define("WIDTH", 700);
define("HEIGHT", 500);
$Test = new pChart(WIDTH, HEIGHT);
$Test->setFontProperties("../font/arial.ttf", 7);
$Test->setGraphArea(40, 30, WIDTH - 30, HEIGHT - 30);
$Test->drawFilledRoundedRectangle(7, 7, WIDTH - 7, HEIGHT - 7, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, WIDTH - 5, HEIGHT - 5, 5, 230, 230, 230);
$Test->setColorPalette(0, 224, 100, 46);
}
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie1");
$DataSet->SetSerieName("Productos Comprados", "Serie2");
// Initialise the graph
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties("../font/arial.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
// Set labels
$Test->setFontProperties("../font/arial.ttf", 7);
$Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie2");
// Finish the graph
$Test->setFontProperties("../font/arial.ttf", 8);
$Test->drawLegend(WIDTH / 5, 25, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("../font/arial.ttf", 10);
$Test->drawTitle(WIDTH - 200, 22, "Estadistica de Barra de Grafico", 50, 50, 50, 185);
$Test->Render("../img/imagenBarra_pChart.png");
}
示例2: pChart
$DataSet->AddPoint(array(9, 9, 9, 10, 10, 11, 12, 14, 16, 17, 18, 18, 19, 19, 18, 15, 12, 10, 9), "Serie1");
$DataSet->AddPoint(array(10, 11, 11, 12, 12, 13, 14, 15, 17, 19, 22, 24, 23, 23, 22, 20, 18, 16, 14), "Serie2");
$DataSet->AddPoint(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Serie3");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie3");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
$DataSet->SetYAxisName("Temperature");
$DataSet->SetYAxisUnit("°C");
$DataSet->SetXAxisUnit("h");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->drawGraphAreaGradient(132, 173, 131, 50, TARGET_BACKGROUND);
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->setGraphArea(120, 20, 675, 190);
$Test->drawGraphArea(213, 217, 221, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE);
$Test->drawGraphAreaGradient(163, 203, 167, 50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// Draw the bar chart
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
// Draw the title
$Title = " Average Temperatures during\r\n the first months of 2008 ";
$Test->drawTextBox(0, 0, 50, 230, $Title, 90, 255, 255, 255, ALIGN_BOTTOM_CENTER, TRUE, 0, 0, 0, 30);
// Draw the legend
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->drawLegend(610, 10, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
// Render the picture
$Test->addBorder(2);
$Test->Render("example23.png");
示例3: testDrawStackedBarGraph
public function testDrawStackedBarGraph()
{
// Dataset definition
$DataSet = new pData();
$DataSet->addPoints(array(1, 4, -3, 2, -3, 3, 2, 1, 0, 7, 4), "Serie1");
$DataSet->addPoints(array(3, 3, -4, 1, -2, 2, 1, 0, -1, 6, 3), "Serie2");
$DataSet->addPoints(array(4, 1, 2, -1, -4, -2, 3, 2, 1, 2, 2), "Serie3");
$DataSet->AddAllSeries();
$DataSet->SetAbscissaLabelSeries();
$DataSet->SetSeriesName("January", "Serie1");
$DataSet->SetSeriesName("February", "Serie2");
$DataSet->SetSeriesName("March", "Serie3");
// Initialise the graph
$canvas = new TestCanvas();
$Test = new pChart(700, 230, $canvas);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(50, 30, 680, 200);
$canvas->drawFilledRoundedRectangle(new Point(7, 7), new Point(693, 223), 5, new Color(240), 1, 0, ShadowProperties::NoShadow());
$backgroundStyle = new BackgroundStyle(new Color(255), TRUE);
$Test->drawGraphBackground($backgroundStyle);
$scaleStyle = new ScaleStyle(SCALE_ADDALL, new Color(150));
$Test->drawScale($DataSet, $scaleStyle, 0, 2, TRUE);
$Test->drawGrid(new GridStyle(4, TRUE, new Color(230), 50));
// Draw the 0 line
$Test->setFontProperties("Fonts/tahoma.ttf", 6);
$Test->drawTreshold(0, new Color(143, 55, 72), TRUE, TRUE);
// Draw the bar graph
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 100);
// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(596, 150, $DataSet->GetDataDescription(), new Color(255));
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(50, 22, "Example 20", new Color(50), 585);
$this->assertEquals('9981801f58bf03e0b2bbe5f8b8f36c2c', md5($canvas->getActionLog()));
}
示例4: pData
//.........这里部分代码省略.........
// If there's a Pie chart we want to draw different legends
$piechart = false;
foreach ($this->plot as $k => $v) {
disableAllSeries($this->plot, $graphData);
$series = $v["name"] . $k;
setSerieDrawable($this->plot, $graphData, $series, TRUE);
switch ($v["type"]) {
case "PIE":
$piedrawn = true;
$piechart = true;
$graphImage->drawFilledCircle($this->width_pdf_actual / 2 + 2, $this->margintop_actual + 2 + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.45 + 1, 200, 200, 200);
$graphImage->drawBasicPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $this->width_pdf_actual / 2, $this->margintop_actual + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.45, PIE_PERCENTAGE_LABEL, 255, 255, 218);
break;
case "PIE3D":
$piedrawn = true;
$piechart = true;
$graphImage->drawPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $this->width_pdf_actual / 2, $this->margintop_actual + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.5, PIE_PERCENTAGE_LABEL, true, 60, 20, 0, 0);
break;
case "OVERLAYBAR":
case "STACKEDBAR":
case "BAR":
if ($stackeddrawn) {
break;
}
if ($barexists || $overlayexists) {
foreach ($this->plot as $k1 => $v1) {
if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR" || $v1["type"] == "OVERLAYBAR") {
setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
}
}
}
$stackeddrawn = true;
if ($stackedexists) {
$graphImage->drawStackedBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
} else {
if ($overlayexists) {
$graphImage->drawOverlayBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
} else {
$graphImage->drawBarGraph($graphData->GetData(), $graphData->GetDataDescription());
}
}
break;
case "SCATTER":
if ($scatterdrawn) {
break;
}
$scatterdrawn = true;
$series1 = false;
$series2 = false;
$graphImage->reportWarnings("GD");
$ct = 0;
foreach ($this->plot as $k1 => $v1) {
if ($v1["type"] == "SCATTER") {
if ($ct == 0) {
$series1 = $v1["name"] . $k1;
}
if ($ct == 1) {
$series2 = $v1["name"] . $k1;
}
$ct++;
setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
}
}
if (count($v["data"]) == 1) {
$v["data"][] = 0;
}
示例5: foreach
case "OVERLAYBAR":
case "STACKEDBAR":
case "BAR":
if ($stackeddrawn) {
break;
}
if ($barexists || $overlayexists) {
foreach ($plot as $k1 => $v1) {
if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR" || $v1["type"] == "OVERLAYBAR") {
setSerieDrawable($plot, $graphData, $v1["name"] . $k1, TRUE);
}
}
}
$stackeddrawn = true;
if ($stackedexists) {
$graphImage->drawStackedBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
} else {
if ($overlayexists) {
$graphImage->drawOverlayBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
} else {
$graphImage->drawBarGraph($graphData->GetData(), $graphData->GetDataDescription());
}
}
break;
case "SCATTER":
if ($scatterdrawn) {
break;
}
$scatterdrawn = true;
$series1 = false;
$series2 = false;
示例6: render
/**
* Render graph
*
*@return nothing
**/
function render($p_stack = FALSE)
{
// declare the graph
$Test = new pChart(800, 250);
$Test->tmpFolder = $this->tmpPath;
$fileId = time() . '_' . rand(1, 1000);
$fontFile = "tahoma.ttf";
// prepare the map
echo '<SCRIPT TYPE="text/javascript" SRC="' . $this->pChartPath . 'overlib.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="' . $this->pChartPath . 'pMap.js"></SCRIPT>';
$MapID = "map_" . $fileId . ".map";
$Test->setImageMap(TRUE, $MapID);
$Map = new pChart(800, 250);
$Map->tmpFolder = $this->tmpPath;
$imgName = "img_" . $fileId . ".png";
$img = $this->tmpPath . $imgName;
$imgLink = GLPI_ROOT . "/plugins/fusioninventory/front/send.php?file=" . urlencode("tmp/" . $imgName);
$mapLink = GLPI_ROOT . "/plugins/fusioninventory/front/send.php?file=" . urlencode("tmp/" . $MapID);
echo '<DIV ID="overDiv" STYLE="position:absolute; visibility:hidden; z-index:1000;"></DIV>';
echo "<IMG ID='fusioninventory_graph_{$fileId}' SRC='{$imgLink}' WIDTH=800 HEIGHT=250 BORDER=0 OnMouseMove='fusioninventory_graph(event);' OnMouseOut='nd();'>";
echo '<SCRIPT>
function fusioninventory_graph(event) {
LoadImageMap("fusioninventory_graph_' . $fileId . '","' . $mapLink . '");
getMousePosition(event);
}
</SCRIPT>';
// configure the graph
$Test->setFontProperties($this->fontsPath . $fontFile, 8);
$Test->setGraphArea(80, 30, 580, 185);
// graph size : keep place for titles on X and Y axes
$Test->drawFilledRoundedRectangle(7, 7, 793, 243, 5, 240, 240, 240);
// background rectangle
$Test->drawRoundedRectangle(5, 5, 795, 245, 5, 230, 230, 230);
// 3D effect
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->setFixedScale(0, $this->getMaxY($this->maxValue), $this->divisionsY);
// to see values from 0
$Test->drawScale($this->pData->GetData(), $this->pData->GetDataDescription(), SCALE_ADDALL, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties($this->fontsPath . $fontFile, 6);
// Draw the bar graph
if ($p_stack) {
$Test->drawStackedBarGraph($this->pData->GetData(), $this->pData->GetDataDescription(), 100);
} else {
$Test->drawBarGraph($this->pData->GetData(), $this->pData->GetDataDescription(), FALSE, 100);
}
// Finish the graph
$Test->setFontProperties($this->fontsPath . $fontFile, 8);
$Test->drawLegend(590, 30, $this->pData->GetDataDescription(), 255, 255, 255);
// take care of legend text size
$Test->setFontProperties($this->fontsPath . $fontFile, 10);
$Test->drawTitle(50, 22, $this->title . ' (/ ' . $this->timeUnitName . ')', 50, 50, 50, 585);
$Test->Render($img);
}
示例7: componentLineGraph
public function componentLineGraph()
{
$DataSet = new pData();
$maxvals = array();
foreach ($this->datasets as $ds_id => $dataset) {
$DataSet->AddPoint($dataset['values'], "Serie" . $ds_id, array_keys($dataset['values']));
$maxvals[] = max($dataset['values']);
if (isset($dataset['burndown'])) {
$amount = count($dataset['values']) > 1 ? $dataset['burndown']['maxEstimation'] / (count($dataset['values']) - 1) : 0;
for ($i = 0; $i < count($dataset['values']); $i++) {
$burndownValues[] = $dataset['burndown']['maxEstimation'] - $i * $amount;
}
$DataSet->AddPoint($burndownValues, "Burndown" . $ds_id, $dataset['burndown']['maxEstimation']);
}
}
$DataSet->AddAllSeries();
if (isset($this->labels)) {
$DataSet->AddPoint($this->labels, "Labels");
$DataSet->SetAbsciseLabelSerie("Labels");
} else {
$DataSet->SetAbsciseLabelSerie();
}
foreach ($this->datasets as $ds_id => $dataset) {
$DataSet->SetSerieName($dataset['label'], "Serie" . $ds_id);
if (isset($dataset['burndown'])) {
$DataSet->SetSerieName($dataset['burndown']['label'], "Burndown" . $ds_id);
}
}
if (isset($this->values_title)) {
$DataSet->SetYAxisName($this->values_title);
}
if (isset($this->labels_title)) {
$DataSet->SetXAxisName($this->labels_title);
}
// Initialise the graph
$Test = new pChart($this->width, $this->height);
$Test->setFixedScale(0, ceil(max($maxvals) / 5) * 5);
$Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'DroidSans.ttf', 8);
if (isset($this->labels_title)) {
$Test->setGraphArea(50, 30, $this->width - 30, $this->height - 45);
} else {
$Test->setGraphArea(50, 30, $this->width - 30, $this->height - 30);
}
$Test->drawFilledRoundedRectangle(2, 2, $this->width - 3, $this->height - 3, 5, 240, 240, 240);
$Test->drawRoundedRectangle(0, 0, $this->width - 1, $this->height - 1, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'DroidSans.ttf', 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the cubic curve graph
if (isset($this->style) && $this->style == 'curved') {
$Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
} elseif (isset($this->style) && $this->style == 'filled_line') {
$Test->drawFilledLineGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 50, true);
} elseif (isset($this->style) && $this->style == 'stacked_bar') {
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 50, true);
} elseif (isset($this->style) && $this->style == 'single_bar') {
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
} else {
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
}
if (isset($this->include_plotter) && $this->include_plotter) {
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
}
// Finish the graph
$Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'DroidSans.ttf', 8);
//$Test->drawLegend(600, 30, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->drawLegend(55, 35, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'DroidSansBold.ttf', 10);
$Test->drawTitle(50, 22, $this->title, 50, 50, 50, $this->width - 30);
$Test->Stroke();
//("example2.png");
}
示例8: preGraphCreation
//.........这里部分代码省略.........
if ($this->strGraphTitle != "") {
//$intHeight -= 12; //TODO: why not needed???
$intTopStart += 12;
}
if ($this->intCurrentGraphMode != $this->GRAPH_TYPE_PIE) {
$this->objChart->setGraphArea($intLeftStart, $intTopStart, $intWidth, $intHeight);
$arrPaneBackground = hex2rgb($this->strGraphBackgroundColor);
$this->objChart->drawGraphArea($arrPaneBackground[0], $arrPaneBackground[1], $arrPaneBackground[2], true);
}
$arrFontColors = hex2rgb($this->strFontColor);
$this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 8);
//set up the axis-titles
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_BAR || $this->intCurrentGraphMode == $this->GRAPH_TYPE_STACKEDBAR || $this->intCurrentGraphMode == $this->GRAPH_TYPE_LINE) {
if ($this->strXAxisTitle != "") {
$this->objDataset->SetXAxisName($this->strXAxisTitle);
}
if ($this->strYAxisTitle != "") {
$this->objDataset->SetYAxisName($this->strYAxisTitle);
}
}
//the x- and y axis, in- / exclusive margins
if ($this->bitAdditionalDatasetAdded && $this->bitScaleFromAdditionalDataset) {
$this->objChart->drawScale($this->objAdditionalDataset->GetData(), $this->objAdditionalDataset->GetDataDescription(), SCALE_START0, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, true);
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_BAR) {
$this->objChart->drawScale($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), SCALE_START0, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, true);
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_STACKEDBAR) {
$this->objChart->drawScale($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), SCALE_ADDALLSTART0, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, true);
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_LINE) {
$this->objChart->drawScale($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), SCALE_NORMAL, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, false);
}
}
}
}
//the background grid
if ($this->intCurrentGraphMode != $this->GRAPH_TYPE_PIE) {
$arrGridColor = hex2rgb($this->strGridColor);
$this->objChart->drawGrid(4, true, $arrGridColor[0], $arrGridColor[1], $arrGridColor[2], 50);
}
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_LINE) {
// Draw the line graph
$this->objChart->drawLineGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription());
//dots in line
$this->objChart->drawPlotGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), 3, 2, 255, 255, 255);
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_BAR) {
//the zero-line
$this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 6);
$this->objChart->drawBarGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), TRUE);
$this->objChart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
//if given, render the line-plots on top
if ($this->bitAdditionalDatasetAdded) {
//the line itself
$this->objChart->drawLineGraph($this->objAdditionalDataset->GetData(), $this->objAdditionalDataset->GetDataDescription());
//the dots
$this->objChart->drawPlotGraph($this->objAdditionalDataset->GetData(), $this->objAdditionalDataset->GetDataDescription(), 3, 2, 255, 255, 255);
}
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_STACKEDBAR) {
//the zero-line
$this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 6);
$this->objChart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
$this->objChart->drawStackedBarGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), 75);
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_PIE) {
$this->objChart->drawPieGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), ceil($this->intWidth / 2) - 20, ceil($this->intHeight / 2), ceil($intHeight / 2) + 20, PIE_PERCENTAGE, TRUE, 50, 20, 5);
}
}
}
}
//render values?
if (count($this->arrValueSeriesToRender) > 0) {
$this->objChart->writeValues($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), $this->arrValueSeriesToRender);
}
// Finish the graph
$this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 7);
//set up the legend
if ($this->bitRenderLegend) {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_PIE) {
$this->objChart->drawPieLegend($this->intWidth - $intLegendWidth - $intRightMargin + 10 - $this->intLegendAdditionalMargin, $intTopStart, $this->objDataset->GetData(), $this->objDataset->GetDataDescription(), 255, 255, 255);
} else {
$arrLegend = $this->objDataset->GetDataDescription();
//merge legends
if ($this->bitAdditionalDatasetAdded) {
$arrAdditionalLegend = $this->objAdditionalDataset->GetDataDescription();
foreach ($arrAdditionalLegend["Description"] as $strKey => $strName) {
$arrLegend["Description"][$strKey] = $strName;
}
}
$this->objChart->drawLegend($this->intWidth - $intLegendWidth - $intRightMargin + 10 - $this->intLegendAdditionalMargin, $intTopStart, $arrLegend, 255, 255, 255);
}
}
//draw the title
if ($this->strGraphTitle != "") {
$this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 10);
$this->objChart->drawTitle(0, $intTopMargin, $this->strGraphTitle, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], $this->intWidth, 10);
}
}
示例9: createChart
function createChart(&$info, &$cfg)
{
$backgndColor = array('R' => 255, 'G' => 255, 'B' => 254);
$chartCfg = new stdClass();
$chartCfg->XSize = $info->canDraw ? $cfg->XSize : 600;
$chartCfg->YSize = $info->canDraw ? $cfg->YSize : 50;
$chartCfg->border = new stdClass();
$chartCfg->border->width = 1;
$chartCfg->border->color = array('R' => 0, 'G' => 0, 'B' => 0);
$chartCfg->graphArea = new stdClass();
$chartCfg->graphArea->color = array('R' => 213, 'G' => 217, 'B' => 221);
$chartCfg->graphArea->beginX = property_exists($cfg, 'beginX') ? $cfg->beginX : 40;
$chartCfg->graphArea->beginY = property_exists($cfg, 'beginY') ? $cfg->beginY : 100;
$chartCfg->graphArea->endX = $chartCfg->XSize - $chartCfg->graphArea->beginX;
$chartCfg->graphArea->endY = $chartCfg->YSize - $chartCfg->graphArea->beginY;
$chartCfg->scale = new stdClass();
// 20100914 - franciscom
// After reading documentation
// drawScale
// Today there is four way of computing scales :
//
// - Getting Max & Min values per serie : ScaleMode = SCALE_NORMAL
// - Like the previous one but setting the min value to 0 : ScaleMode = SCALE_START0
// - Getting the series cumulative Max & Min values : ScaleMode = SCALE_ADDALL
// - Like the previous one but setting the min value to 0 : ScaleMode = SCALE_ADDALLSTART0
//
// This will depends on the kind of graph you are drawing, today only the stacked bar chart
// can use the SCALE_ADDALL mode.
// Drawing graphs were you want to fix the min value to 0 you must use the SCALE_START0 option.
//
$chartCfg->scale->mode = SCALE_ADDALLSTART0;
$chartCfg->scale->color = array('R' => 0, 'G' => 0, 'B' => 0);
$chartCfg->scale->drawTicks = TRUE;
$chartCfg->scale->angle = $cfg->scale->legendXAngle;
$chartCfg->scale->decimals = 1;
$chartCfg->scale->withMargin = TRUE;
$chartCfg->legend = new stdClass();
$chartCfg->legend->X = $chartCfg->XSize - 80;
$chartCfg->legend->Y = 15;
$chartCfg->legend->color = array('R' => 236, 'G' => 238, 'B' => 240);
$chartCfg->title = new stdClass();
$chartCfg->title->value = $cfg->chartTitle;
$chartCfg->title->X = 2 * $chartCfg->graphArea->beginX;
$chartCfg->title->Y = $chartCfg->legend->Y;
$chartCfg->title->color = array('R' => 0, 'G' => 0, 'B' => 255);
$Test = new pChart($chartCfg->XSize, $chartCfg->YSize);
$Test->reportWarnings("GD");
$Test->drawBackground($backgndColor['R'], $backgndColor['G'], $backgndColor['B']);
$Test->drawGraphArea($chartCfg->graphArea->color['R'], $chartCfg->graphArea->color['G'], $chartCfg->graphArea->color['B']);
$Test->setGraphArea($chartCfg->graphArea->beginX, $chartCfg->graphArea->beginY, $chartCfg->graphArea->endX, $chartCfg->graphArea->endY);
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
if ($info->canDraw) {
$DataSet = new pData();
foreach ($info->chart_data as $key => $values) {
$id = $key + 1;
$DataSet->AddPoint($values, "Serie{$id}");
$DataSet->SetSerieName($info->series_label[$key], "Serie{$id}");
}
$DataSet->AddPoint($info->xAxis->values, $info->xAxis->serieName);
$DataSet->AddAllSeries();
$DataSet->RemoveSerie($info->xAxis->serieName);
$DataSet->SetAbsciseLabelSerie($info->xAxis->serieName);
$chartData = $DataSet->GetData();
$chartLegend = $DataSet->GetDataDescription();
foreach ($info->series_color as $key => $hexrgb) {
$rgb = str_split($hexrgb, 2);
$Test->setColorPalette($key, hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2]));
}
// $Test->setFixedScale($info->scale->minY,$info->scale->maxY,$info->scale->divisions);
$Test->drawScale($chartData, $chartLegend, $chartCfg->scale->mode, $chartCfg->scale->color['R'], $chartCfg->scale->color['G'], $chartCfg->scale->color['B'], $chartCfg->scale->drawTicks, $chartCfg->scale->angle, $chartCfg->scale->decimals, $chartCfg->scale->withMargin);
$Test->drawStackedBarGraph($chartData, $chartLegend, 70);
// Draw the legend
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
$Test->drawLegend($chartCfg->legend->X, $chartCfg->legend->Y, $chartLegend, $chartCfg->legend->color['R'], $chartCfg->legend->color['G'], $chartCfg->legend->color['B']);
$Test->addBorder($chartCfg->border->width, $chartCfg->border->color['R'], $chartCfg->border->color['G'], $chartCfg->border->color['B']);
} else {
$chartCfg->title->value .= '/' . lang_get('no_data_available');
}
$Test->drawTitle($chartCfg->title->X, $chartCfg->title->Y, $chartCfg->title->value, $chartCfg->title->color['R'], $chartCfg->title->color['G'], $chartCfg->title->color['B']);
$Test->Stroke();
}
示例10: stacked2
function stacked2($data, $title, $filename)
{
// Dataset definition
$DataSet = new pData();
$values = $data['values'];
$keys = $data['keys'];
$bar = new pChart(1040, 230);
for ($i = 0; $i < count($values); $i++) {
$DataSet->AddPoint($values[$i], "Serie" . ($i + 1));
if ($i != 0) {
$DataSet->AddSerie("Serie" . ($i + 1));
$DataSet->SetSerieName($keys[$i - 1], "Serie" . ($i + 1));
}
}
$DataSet->SetAbsciseLabelSerie("Serie1");
$DataSet->SetXAxisFormat("date");
// Initialise the graph
$bar->setDateFormat("M.d");
$bar->setFontProperties("Fonts/consola.ttf", 8);
$bar->setGraphArea(80, 30, 1020, 200);
$bar->drawFilledRoundedRectangle(2, 2, 1037, 227, 5, 240, 240, 240);
$bar->drawRoundedRectangle(0, 0, 1039, 229, 5, 230, 230, 230);
$bar->loadColorPalette('chartcolors.txt', ',');
$bar->drawGraphArea(255, 255, 255, TRUE);
$bar->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 150, 150, 150, TRUE, 0, 2, TRUE);
$bar->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$bar->setFontProperties("Fonts/consola.ttf", 6);
$bar->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$bar->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 100);
$bar->drawLegend(85, 35, $DataSet->GetDataDescription(), 255, 255, 255);
// Finish the graph
$bar->setFontProperties("Fonts/MankSans.ttf", 10);
$bar->drawTitle(10, 20, $title, 100, 100, 100);
$bar->Render($filename);
}
示例11: createChart
function createChart(&$info, &$cfg)
{
$backgndColor = array('R' => 255, 'G' => 255, 'B' => 254);
$chartCfg = new stdClass();
$chartCfg->XSize = $info->canDraw ? $cfg->XSize : 600;
$chartCfg->YSize = $info->canDraw ? $cfg->YSize : 50;
$chartCfg->border = new stdClass();
$chartCfg->border->width = 1;
$chartCfg->border->color = array('R' => 0, 'G' => 0, 'B' => 0);
$chartCfg->graphArea = new stdClass();
$chartCfg->graphArea->color = array('R' => 213, 'G' => 217, 'B' => 221);
$chartCfg->graphArea->beginX = 40;
$chartCfg->graphArea->beginY = 40;
$chartCfg->graphArea->endX = $chartCfg->XSize - $chartCfg->graphArea->beginX;
$chartCfg->graphArea->endY = $chartCfg->YSize - $chartCfg->graphArea->beginY;
$chartCfg->scale = new stdClass();
$chartCfg->scale->mode = SCALE_ADDALL;
$chartCfg->scale->color = array('R' => 0, 'G' => 0, 'B' => 0);
$chartCfg->scale->drawTicks = TRUE;
$chartCfg->scale->angle = $cfg->scale->legendXAngle;
$chartCfg->scale->decimals = 1;
$chartCfg->scale->withMargin = TRUE;
$chartCfg->legend = new stdClass();
$chartCfg->legend->X = $chartCfg->XSize - 80;
$chartCfg->legend->Y = 15;
$chartCfg->legend->color = array('R' => 236, 'G' => 238, 'B' => 240);
$chartCfg->title = new stdClass();
$chartCfg->title->value = $cfg->chartTitle;
$chartCfg->title->X = 2 * $chartCfg->graphArea->beginX;
$chartCfg->title->Y = $chartCfg->legend->Y;
$chartCfg->title->color = array('R' => 0, 'G' => 0, 'B' => 255);
$Test = new pChart($chartCfg->XSize, $chartCfg->YSize);
$Test->drawBackground($backgndColor['R'], $backgndColor['G'], $backgndColor['B']);
$Test->drawGraphArea($chartCfg->graphArea->color['R'], $chartCfg->graphArea->color['G'], $chartCfg->graphArea->color['B']);
$Test->setGraphArea($chartCfg->graphArea->beginX, $chartCfg->graphArea->beginY, $chartCfg->graphArea->endX, $chartCfg->graphArea->endY);
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
if ($info->canDraw) {
$DataSet = new pData();
foreach ($info->chart_data as $key => $values) {
$id = $key + 1;
$DataSet->AddPoint($values, "Serie{$id}");
$DataSet->SetSerieName($info->series_label[$key], "Serie{$id}");
}
$DataSet->AddPoint($info->xAxis->values, $info->xAxis->serieName);
$DataSet->AddAllSeries();
$DataSet->RemoveSerie($info->xAxis->serieName);
$DataSet->SetAbsciseLabelSerie($info->xAxis->serieName);
$chartData = $DataSet->GetData();
$chartLegend = $DataSet->GetDataDescription();
foreach ($info->series_color as $key => $hexrgb) {
$rgb = str_split($hexrgb, 2);
$Test->setColorPalette($key, hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2]));
}
// $Test->setFixedScale($info->scale->minY,$info->scale->maxY,$info->scale->divisions);
$Test->drawScale($chartData, $chartLegend, $chartCfg->scale->mode, $chartCfg->scale->color['R'], $chartCfg->scale->color['G'], $chartCfg->scale->color['B'], $chartCfg->scale->drawTicks, $chartCfg->scale->angle, $chartCfg->scale->decimals, $chartCfg->scale->withMargin);
$Test->drawStackedBarGraph($chartData, $chartLegend, 70);
// Draw the legend
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
$Test->drawLegend($chartCfg->legend->X, $chartCfg->legend->Y, $chartLegend, $chartCfg->legend->color['R'], $chartCfg->legend->color['G'], $chartCfg->legend->color['B']);
$Test->addBorder($chartCfg->border->width, $chartCfg->border->color['R'], $chartCfg->border->color['G'], $chartCfg->border->color['B']);
} else {
$chartCfg->title->value .= '/' . lang_get('no_data_available');
}
$Test->drawTitle($chartCfg->title->X, $chartCfg->title->Y, $chartCfg->title->value, $chartCfg->title->color['R'], $chartCfg->title->color['G'], $chartCfg->title->color['B']);
$Test->Stroke();
}
示例12: grafico
function grafico($dados, $eixo, $cor1, $grafico, $situacao, $legenda)
{
include_once "pChart/pChart/pData.class";
include_once "pChart/pChart/pChart.class";
$DataSet = new pData();
$DataSet->AddPoint($dados, "Serie1");
$DataSet->AddPoint($eixo, "Serie2");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie2");
$DataSet->SetAbsciseLabelSerie("Serie2");
$DataSet->SetSerieName($legenda, "Serie1");
$Test = new pChart(720, 430);
$Test->drawGraphAreaGradient($cor1, 173, 131, 50, TARGET_BACKGROUND);
$Test->setFontProperties("pChart/Fonts/tahoma.ttf", 8);
$Test->setGraphArea(50, 80, 675, 390);
$Test->drawGraphArea(217, 217, 211, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE);
$Test->drawGraphAreaGradient(163, 203, 167, 50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
$Title = "{$situacao}";
$Test->setFontProperties("pChart/Fonts/tahoma.ttf", 14);
$Test->drawTextBox(0, 0, 700, 60, $Title, 0, 255, 255, 255, ALIGN_CENTER, TRUE, 30, 0, 0, 30);
$Test->setFontProperties("pChart/Fonts/tahoma.ttf", 9);
$Test->drawLegend(520, 70, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
$Test->addBorder(2);
$Test->Render("images/" . $grafico);
}
示例13: cartesianChart
//.........这里部分代码省略.........
$xdata .= $settings['XAxisUnit'];
$Position = imageftbbox($FontSize, 0, $FontName, $xdata);
$TextWidth = $Position[2] - $Position[0];
$TextHeightX = $Position[1] - $Position[7];
$WXmax = $TextWidth > $WXmax ? $TextWidth : $WXmax;
}
}
if ($settings['XAngle'] > 0) {
$sin = abs(sin(deg2rad($settings['XAngle'])));
$cos = abs(cos(deg2rad($settings['XAngle'])));
$HXmax = $WXmax * $sin + $TextHeightX * $cos;
} else {
$HXmax = $TextHeightX;
}
//on Y axis...
if ($settings['YAxisFormat'] == 'time') {
$ydata = "99:99:99";
$Position = imageftbbox($FontSize, 0, $FontName, $ydata);
$WYmax = $Position[2] - $Position[0];
$TextHeightY = $Position[1] - $Position[7];
} elseif ($settings['YAxisFormat'] == 'date') {
$ydata = "99/99/9999";
$Position = imageftbbox($FontSize, 0, $FontName, $ydata);
$WYmax = $Position[2] - $Position[0];
$TextHeightY = $Position[1] - $Position[7];
} else {
$WYmax = 0;
foreach ($y as $ydata) {
$ydata .= $settings['YAxisUnit'];
//echo $ydata."<br>";
$Position = imageftbbox($FontSize, 0, $FontName, $ydata);
$TextWidth = $Position[2] - $Position[0];
$TextHeightY = $Position[1] - $Position[7];
$WYmax = $TextWidth > $WYmax ? $TextWidth : $WYmax;
}
}
$Test->setGraphArea($WYmax + $TextHeightY + 35, 20, $w - 25, $h - $HXmax - $TextHeightX - $TextboxHeight - 20);
//$Test->setGraphArea(60,20,$w-25,($settings['XAngle']==0)?$h-70:$h-100);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, $settings['XAngle'], 0, TRUE);
$Test->drawGraphAreaGradient($settings['BGR'], $settings['BGG'], $settings['BGB'], $settings['Decay2']);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// This will put the picture "logo.png" with transparency
if (strlen($settings['Logo'])) {
$XLogo = $WYmax + $TextHeightY + 35 + $settings['XLogo'];
$YLogo = 20 + $settings['XLogo'];
$logo = $settings['Logo'];
//Fing extension of logo : png,gif or jpg
if ($this->_findexts($logo) == "png") {
echo "png!";
$Test->drawFromPNG($logo, $XLogo, $YLogo, $settings['LogoTransparency']);
} elseif ($this->_findexts($logo) == "gif") {
echo "gif!";
$Test->drawFromGIF($logo, $XLogo, $YLogo, $settings['LogoTransparency']);
} elseif ($this->_findexts($logo) == "jpg") {
echo "jpg";
$Test->drawFromJPG($logo, $XLogo, $YLogo, $settings['LogoTransparency']);
}
}
$Test->setColorPalette(0, $settings['DataR'], $settings['DataG'], $settings['DataB']);
if ($type == "bar") {
// Draw the bar chart
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
} elseif ($type == "line") {
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE);
} elseif ($type == "cubic") {
$Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4);
$Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->clearShadow();
if ($settings['Filled'] == 'yes') {
$Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30);
}
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE);
}
// Draw the textbox
if (strlen($settings['Textbox'])) {
$Test->setFontProperties($TextboxFontName, $TextboxFontSize);
$Test->drawTextBox(0, $h - $TextboxHeight, $w, $h, $settings['Textbox'], 0, 255, 255, 255, ALIGN_CENTER, TRUE, 0, 0, 0, 30);
}
// Draw the legend
if (strlen($settings['Legend'])) {
$LegendFontSize = $settings['LegendFontSize'];
$LegendFontName = $this->_ext_path . "/fonts/" . $settings['LegendFontName'];
$Position = imageftbbox($LegendFontSize, 0, $LegendFontName, $settings['Legend']);
$LegendW = $Position[2] - $Position[0] + 40;
$Test->setFontProperties($LegendFontName, $LegendFontSize);
$Test->drawLegend($w - $LegendW, 10, $DataSet->GetDataDescription(), $settings['LBR'], $settings['LBG'], $settings['LBB'], 52, 58, 82, $settings['LR'], $settings['LG'], $settings['LB'], TRUE);
}
// Render the picture
$Test->addBorder(2);
if (strlen($imgname)) {
//custom image name
$imgname = $this->_img_path . "/" . $imgname;
} else {
$this->obj->load->helper('string');
$imgname = $this->_img_path . "/{$type}-" . random_string('alnum', 16) . ".png";
}
$Test->Render($imgname);
return array("name" => '/' . $imgname, "w" => $w + 4, "h" => $h + 4);
}