本文整理汇总了PHP中pData::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP pData::getData方法的具体用法?PHP pData::getData怎么用?PHP pData::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pData
的用法示例。
在下文中一共展示了pData::getData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddAllSeries
public function testAddAllSeries()
{
$data = new pData();
$data->addPoint(array(1, 2), 'testseries1');
$data->addPoint(array(3, 4), 'testseries2');
$data->addAllSeries();
/** @todo It's not clear how to test the effect of
addAllSeries(). The assertion below passes whether or not
addAllSeries() has been called */
$this->assertEquals(array(0 => array('testseries1' => 1, 'testseries2' => 3, 'Name' => 0), 1 => array('testseries1' => 2, 'testseries2' => 4, 'Name' => 1)), $data->getData());
}
示例2: PieChart
/**
* Create a PieChart
*
* @param array $data associative array contianing label and values
*/
protected function PieChart($data)
{
$DataSet = new pData();
$Canvas = new GDCanvas(400, 200, false);
$Chart = new PieChart(400, 200, $Canvas);
$Chart->setFontProperties(dirname(__FILE__) . '/pchart/Fonts/DroidSans.ttf', 8);
$DataSet->AddPoints(array_values($data), 'Serie1');
$DataSet->AddPoints(array_keys($data), 'Serie2');
$DataSet->AddAllSeries();
$DataSet->SetAbscissaLabelSeries("Serie2");
$Chart->drawBasicPieGraph($DataSet->getData(), $DataSet->GetDataDescription(), 120, 100, 60, PIE_PERCENTAGE);
$Chart->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250));
header('Content-Type: image/png');
$Chart->Render('');
}
示例3: plotPieChart
protected function plotPieChart(pImage $picture, pData $data, $options = array())
{
$pie = new pPie($picture, $data);
$raw_data = $data->getData();
$n_series = $options['n_series'];
$series_names = array_keys($raw_data['Series']);
$chart_height = $options['chart_height'];
$title_height = isset($options['title_height']) ? $options['title_height'] : 50;
$c = -1;
foreach ($series_names as $key => $id) {
if ('labels' == $id) {
continue;
}
$c++;
$data->setSerieDrawable($id, true);
$posX = $c == 0 ? 225 : (($c + 1) % 2 == 1 ? 225 + 450 : 225);
$posY = $c == 0 ? $chart_height / 2 : $chart_height / 2 + $chart_height * (floor($c / 2) + $c % 2);
$posY = $title_height + $posY;
// title
$options = array('Radius' => $chart_height / 2 * 0.9, 'SkewFactore' => 0.5, 'SliceHeight' => 10, 'DataGapAngle' => 0, 'Border' => TRUE, 'BorderR' => 255, 'BorderG' => 255, 'BorderB' => 255, 'SecondPass' => true, 'WriteValues' => true, 'ValueR' => 0, 'ValueG' => 0, 'ValueB' => 0);
$pie->draw3DPie($posX, $posY, $options);
$data->setSerieDrawable($id, false);
$TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 40, "G" => 40, "B" => 43);
$picture->drawText($posX, $posY - $chart_height / 2 * 0.9, $raw_data['Series'][$id]['Description'], $TextSettings);
}
$Config = array("FontName" => sfConfig::get('sf_web_dir') . "/fonts/Ubuntu-R.ttf", "FontSize" => 6, "FontR" => 40, "FontG" => 40, "FontB" => 43, "Margin" => 6, "Alpha" => 100, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL, "Family" => LEGEND_FAMILY_LINE);
$pie->drawPieLegend(450, 50, $Config);
}
示例4: testDrawBasicPieGraph
public function testDrawBasicPieGraph()
{
// Dataset definition
$DataSet = new pData();
$DataSet->addPoints(array(10, 2, 3, 5, 3), "Serie1");
$DataSet->addPoints(array("Jan", "Feb", "Mar", "Apr", "May"), "Serie2");
$DataSet->AddAllSeries();
$DataSet->setAbscissaLabelSeries("Serie2");
$this->assertEquals(array(0 => array('Serie1' => 10, 'Name' => 0, 'Serie2' => 'Jan'), 1 => array('Serie1' => 2, 'Name' => 1, 'Serie2' => 'Feb'), 2 => array('Serie1' => 3, 'Name' => 2, 'Serie2' => 'Mar'), 3 => array('Serie1' => 5, 'Name' => 3, 'Serie2' => 'Apr'), 4 => array('Serie1' => 3, 'Name' => 4, 'Serie2' => 'May')), $DataSet->getData());
$this->assertEquals(array(0 => 'Serie1', 1 => 'Serie2'), $DataSet->getDataDescription()->values);
// Initialise the graph
$canvas = new TestCanvas();
$Test = new PieChart(300, 200, $canvas);
$Test->loadColorPalette(dirname(__FILE__) . "/../sample/softtones.txt");
// Draw the pie chart
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, ShadowProperties::NoShadow(), 70, PIE_PERCENTAGE, new Color(255, 255, 218));
$Test->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250));
$this->assertEquals('0ec1d5de67ae53239101143106d5ee4a', md5($canvas->getActionLog()));
}
示例5: drawPieGraph
/**
* This function draw a pseudo-3D pie chart
* @param pData
* @param int X-Position of the Center
* @param int Y-Position of the Center
* @param int Radius of the cake
* @param const int Draw the Labels to the pies? PIE_LABELS, PIE_NOLABEL, PIE_PERCENTAGE, PIE_PERCENATGE_LABEL
* @param bool Enhance colors?
* @param int Skew
* @param int Height of the splices
* @param int Distance between the splices
* @param int number of decimals
* @param ShadowProperties
* @access public
*/
public function drawPieGraph(pData $data, $XPos, $YPos, $Radius = 100, $DrawLabels = PIE_NOLABEL, $EnhanceColors = TRUE, $Skew = 60, $SpliceHeight = 20, $SpliceDistance = 0, $Decimals = 0, ShadowProperties $shadowProperties = null)
{
if ($shadowProperties == null) {
$shadowProperties = ShadowProperties::FromDefaults();
}
/* Validate the Data and DataDescription array */
$this->validateDataDescription("drawPieGraph", $data->getDataDescription(), FALSE);
$this->validateData("drawPieGraph", $data->getData());
/* Determine pie sum */
$Series = 0;
$PieSum = 0;
$rPieSum = 0;
foreach ($data->getDataDescription()->values as $ColName) {
if ($ColName != $data->getDataDescription()->getPosition()) {
$Series++;
$dataArray = $data->getData();
foreach (array_keys($dataArray) as $Key) {
if (isset($dataArray[$Key][$ColName])) {
if ($dataArray[$Key][$ColName] == 0) {
$iValues[] = 0;
$rValues[] = 0;
$iLabels[] = $dataArray[$Key][$data->getDataDescription()->getPosition()];
} else {
$PieSum += $dataArray[$Key][$ColName];
$iValues[] = $dataArray[$Key][$ColName];
$iLabels[] = $dataArray[$Key][$data->getDataDescription()->getPosition()];
$rValues[] = $dataArray[$Key][$ColName];
$rPieSum += $dataArray[$Key][$ColName];
}
}
}
}
}
/* Validate serie */
if ($Series != 1) {
throw new Exception("Pie chart can only accept one serie of data.");
}
/** @todo Proper exception type needed here */
$SpliceDistanceRatio = $SpliceDistance;
$SkewHeight = $Radius * $Skew / 100;
$SpliceRatio = (360 - $SpliceDistanceRatio * count($iValues)) / $PieSum;
$SplicePercent = 100 / $PieSum;
$rSplicePercent = 100 / $rPieSum;
/* Calculate all polygons */
$Angle = 0;
$CDev = 5;
$TopPlots = "";
$BotPlots = "";
$aTopPlots = "";
$aBotPlots = "";
foreach ($iValues as $Key => $Value) {
$XCenterPos = cos(($Angle - $CDev + ($Value * $SpliceRatio + $SpliceDistanceRatio) / 2) * M_PI / 180) * $SpliceDistance + $XPos;
$YCenterPos = sin(($Angle - $CDev + ($Value * $SpliceRatio + $SpliceDistanceRatio) / 2) * M_PI / 180) * $SpliceDistance + $YPos;
$XCenterPos2 = cos(($Angle + $CDev + ($Value * $SpliceRatio + $SpliceDistanceRatio) / 2) * M_PI / 180) * $SpliceDistance + $XPos;
$YCenterPos2 = sin(($Angle + $CDev + ($Value * $SpliceRatio + $SpliceDistanceRatio) / 2) * M_PI / 180) * $SpliceDistance + $YPos;
$TopPlots[$Key][] = round($XCenterPos);
$BotPlots[$Key][] = round($XCenterPos);
$TopPlots[$Key][] = round($YCenterPos);
$BotPlots[$Key][] = round($YCenterPos + $SpliceHeight);
$aTopPlots[$Key][] = $XCenterPos;
$aBotPlots[$Key][] = $XCenterPos;
$aTopPlots[$Key][] = $YCenterPos;
$aBotPlots[$Key][] = $YCenterPos + $SpliceHeight;
/* Process labels position & size */
$Caption = "";
if (!($DrawLabels == PIE_NOLABEL)) {
$TAngle = $Angle + $Value * $SpliceRatio / 2;
if ($DrawLabels == PIE_PERCENTAGE) {
$Caption = round($rValues[$Key] * pow(10, $Decimals) * $rSplicePercent) / pow(10, $Decimals) . "%";
} elseif ($DrawLabels == PIE_LABELS) {
$Caption = $iLabels[$Key];
} elseif ($DrawLabels == PIE_PERCENTAGE_LABEL) {
$Caption = $iLabels[$Key] . "\r\n" . round($Value * pow(10, $Decimals) * $SplicePercent) / pow(10, $Decimals) . "%";
}
$Position = imageftbbox($this->FontSize, 0, $this->FontName, $Caption);
$TextWidth = $Position[2] - $Position[0];
$TextHeight = abs($Position[1]) + abs($Position[3]);
$TX = cos($TAngle * M_PI / 180) * ($Radius + 10) + $XPos;
if ($TAngle > 0 && $TAngle < 180) {
$TY = sin($TAngle * M_PI / 180) * ($SkewHeight + 10) + $YPos + $SpliceHeight + 4;
} else {
$TY = sin($TAngle * M_PI / 180) * ($SkewHeight + 4) + $YPos - $TextHeight / 2;
}
if ($TAngle > 90 && $TAngle < 270) {
$TX = $TX - $TextWidth;
//.........这里部分代码省略.........
示例6: drawFilledCubicCurve
/**
* This function draw a filled cubic curve
*/
function drawFilledCubicCurve(pData $data, $Accuracy = 0.1, $Alpha = 100, $AroundZero = FALSE)
{
/* Validate the Data and DataDescription array */
$this->validateDataDescription("drawFilledCubicCurve", $data->getDataDescription());
$this->validateData("drawFilledCubicCurve", $data->getData());
$LayerWidth = $this->GArea_X2 - $this->GArea_X1;
$LayerHeight = $this->GArea_Y2 - $this->GArea_Y1;
$YZero = $LayerHeight - (0 - $this->VMin) * $this->DivisionRatio;
if ($YZero > $LayerHeight) {
$YZero = $LayerHeight;
}
$GraphID = 0;
foreach ($data->getDataDescription()->values as $ColName) {
$XIn = array();
$YIn = array();
$Yt = array();
$U = array();
$ColorID = $data->getDataDescription()->getColumnIndex($ColName);
$numElements = 1;
$XLast = -1;
$Missing = array();
$data->getXYMap($ColName, $XIn, $YIn, $Missing, $numElements);
$Yt[0] = 0;
$Yt[1] = 0;
$U[1] = 0;
$this->calculateCubicCurve($Yt, $XIn, $YIn, $U, $numElements);
$Yt[$numElements] = 0;
for ($k = $numElements - 1; $k >= 1; $k--) {
$Yt[$k] = $Yt[$k] * $Yt[$k + 1] + $U[$k];
}
$Points = "";
$Points[] = $this->GAreaXOffset + $this->GArea_X1;
$Points[] = $LayerHeight + $this->GArea_Y1;
$YLast = NULL;
$XPos = $this->GAreaXOffset;
$PointsCount = 2;
for ($X = 1; $X <= $numElements; $X = $X + $Accuracy) {
$klo = 1;
$khi = $numElements;
$k = $khi - $klo;
while ($k > 1) {
$k = $khi - $klo;
if ($XIn[$k] >= $X) {
$khi = $k;
} else {
$klo = $k;
}
}
$klo = $khi - 1;
$h = $XIn[$khi] - $XIn[$klo];
$a = ($XIn[$khi] - $X) / $h;
$b = ($X - $XIn[$klo]) / $h;
$Value = $a * $YIn[$klo] + $b * $YIn[$khi] + (($a * $a * $a - $a) * $Yt[$klo] + ($b * $b * $b - $b) * $Yt[$khi]) * ($h * $h) / 6;
$YPos = $LayerHeight - ($Value - $this->VMin) * $this->DivisionRatio;
if ($YLast != NULL && $AroundZero && !isset($Missing[floor($X)]) && !isset($Missing[floor($X + 1)])) {
$aPoints = "";
$aPoints[] = $XLast + $this->GArea_X1;
$aPoints[] = min($YLast + $this->GArea_Y1, $this->GArea_Y2);
$aPoints[] = $XPos + $this->GArea_X1;
$aPoints[] = min($YPos + $this->GArea_Y1, $this->GArea_Y2);
$aPoints[] = $XPos + $this->GArea_X1;
$aPoints[] = $YZero + $this->GArea_Y1;
$aPoints[] = $XLast + $this->GArea_X1;
$aPoints[] = $YZero + $this->GArea_Y1;
$this->canvas->drawFilledPolygon($aPoints, 4, $this->palette->getColor($ColorID), $alpha);
}
if (!isset($Missing[floor($X)]) || $YLast == NULL) {
$PointsCount++;
$Points[] = $XPos + $this->GArea_X1;
$Points[] = min($YPos + $this->GArea_Y1, $this->GArea_Y2);
} else {
$PointsCount++;
$Points[] = $XLast + $this->GArea_X1;
$Points[] = min($LayerHeight + $this->GArea_Y1, $this->GArea_Y2);
}
$YLast = $YPos;
$XLast = $XPos;
$XPos = $XPos + $this->DivisionWidth * $Accuracy;
}
// Add potentialy missing values
$XPos = $XPos - $this->DivisionWidth * $Accuracy;
if ($XPos < $LayerWidth - $this->GAreaXOffset) {
$YPos = $LayerHeight - ($YIn[$numElements] - $this->VMin) * $this->DivisionRatio;
if ($YLast != NULL && $AroundZero) {
$aPoints = "";
$aPoints[] = $XLast + $this->GArea_X1;
$aPoints[] = max($YLast + $this->GArea_Y1, $this->GArea_Y1);
$aPoints[] = $LayerWidth - $this->GAreaXOffset + $this->GArea_X1;
$aPoints[] = max($YPos + $this->GArea_Y1, $this->GArea_Y1);
$aPoints[] = $LayerWidth - $this->GAreaXOffset + $this->GArea_X1;
$aPoints[] = max($YZero + $this->GArea_Y1, $this->GArea_Y1);
$aPoints[] = $XLast + $this->GArea_X1;
$aPoints[] = max($YZero + $this->GArea_Y1, $this->GArea_Y1);
$this->canvas->drawFilledPolygon($aPoints, 4, $this->palette->getColor($ColorID), $alpha);
}
if ($YIn[$klo] != "" && $YIn[$khi] != "" || $YLast == NULL) {
$PointsCount++;
//.........这里部分代码省略.........
示例7: pData
$MyData = new pData();
$MyData->addPoints(array(24, 25, 26, 25, 25), "My Serie 1");
$MyData->addPoints(array(12, 13, 14, 16, 18), "My Serie 2");
$MyData->addPoints(array(80, 76, 73, 71, 33), "My Serie 3");
$MyData->addPoints(array(47, 67, 78, 76, 54), "My Serie 4");
/* Define the series name */
$MyData->setSerieDescription("My Serie 1", "Temperature");
$MyData->setSerieDescription("My Serie 2", "Humidity");
/* Dispatche the series on different axis */
$MyData->setSerieOnAxis("My Serie 1", 1);
$MyData->setSerieOnAxis("My Serie 2", 1);
$MyData->setSerieOnAxis("My Serie 3", 2);
$MyData->setSerieOnAxis("My Serie 4", 2);
/* Set the format of the axis */
$MyData->setAxisDisplay(1, AXIS_FORMAT_DEFAULT);
$MyData->setAxisDisplay(2, AXIS_FORMAT_DEFAULT);
$MyData->setAxisDisplay(1, AXIS_FORMAT_TIME, "H:i");
/* Set the unit of the axis */
$MyData->setAxisUnit(1, "°C");
$MyData->setAxisUnit(2, "%");
/* Set the name of the axis */
$MyData->setAxisName(1, "Temperature");
$MyData->setAxisName(2, "Humidity");
/* Change the color of one serie */
$serieSettings = array("R" => 229, "G" => 11, "B" => 11, "Alpha" => 80);
$MyData->setPalette("My Serie 4", $serieSettings);
/* Load a palette file */
$MyData->loadPalette("resources/palette.txt", FALSE);
/* Output the data structure */
print_r($MyData->getData());