function pBubble::drawBubbleChart in Visitors 7
Same name and namespace in other branches
- 7.2 pChart/class/pBubble.class.php \pBubble::drawBubbleChart()
File
- pChart/
class/ pBubble.class.php, line 112
Class
Code
function drawBubbleChart($DataSeries, $WeightSeries, $Format = "") {
$ForceAlpha = isset($Format["ForceAlpha"]) ? $Format["ForceAlpha"] : VOID;
$DrawBorder = isset($Format["DrawBorder"]) ? $Format["DrawBorder"] : TRUE;
$BorderWidth = isset($Format["BorderWidth"]) ? $Format["BorderWidth"] : 1;
$Shape = isset($Format["Shape"]) ? $Format["Shape"] : BUBBLE_SHAPE_ROUND;
$Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
$BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 0;
$BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 0;
$BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 0;
$BorderAlpha = isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : 30;
$RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
if (!is_array($DataSeries)) {
$DataSeries = array(
$DataSeries,
);
}
if (!is_array($WeightSeries)) {
$WeightSeries = array(
$WeightSeries,
);
}
$Data = $this->pDataObject
->getData();
$Palette = $this->pDataObject
->getPalette();
if (isset($Data["Series"]["BubbleFakePositiveSerie"])) {
$this->pDataObject
->setSerieDrawable("BubbleFakePositiveSerie", FALSE);
}
if (isset($Data["Series"]["BubbleFakeNegativeSerie"])) {
$this->pDataObject
->setSerieDrawable("BubbleFakeNegativeSerie", FALSE);
}
$this
->resetSeriesColors();
list($XMargin, $XDivs) = $this->pChartObject
->scaleGetXSettings();
foreach ($DataSeries as $Key => $SerieName) {
$AxisID = $Data["Series"][$SerieName]["Axis"];
$Mode = $Data["Axis"][$AxisID]["Display"];
$Format = $Data["Axis"][$AxisID]["Format"];
$Unit = $Data["Axis"][$AxisID]["Unit"];
if (isset($Data["Series"][$SerieName]["Description"])) {
$SerieDescription = $Data["Series"][$SerieName]["Description"];
}
else {
$SerieDescription = $SerieName;
}
$XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin * 2) / $XDivs;
$X = $this->pChartObject->GraphAreaX1 + $XMargin;
$Y = $this->pChartObject->GraphAreaY1 + $XMargin;
$Color = array(
"R" => $Palette[$Key]["R"],
"G" => $Palette[$Key]["G"],
"B" => $Palette[$Key]["B"],
"Alpha" => $Palette[$Key]["Alpha"],
);
if ($ForceAlpha != VOID) {
$Color["Alpha"] = $ForceAlpha;
}
if ($DrawBorder) {
if ($BorderWidth != 1) {
if ($Surrounding != NULL) {
$BorderR = $Palette[$Key]["R"] + $Surrounding;
$BorderG = $Palette[$Key]["G"] + $Surrounding;
$BorderB = $Palette[$Key]["B"] + $Surrounding;
}
else {
$BorderR = $BorderR;
$BorderG = $BorderG;
$BorderB = $BorderB;
}
if ($ForceAlpha != VOID) {
$BorderAlpha = $ForceAlpha / 2;
}
$BorderColor = array(
"R" => $BorderR,
"G" => $BorderG,
"B" => $BorderB,
"Alpha" => $BorderAlpha,
);
}
else {
$Color["BorderAlpha"] = $BorderAlpha;
if ($Surrounding != NULL) {
$Color["BorderR"] = $Palette[$Key]["R"] + $Surrounding;
$Color["BorderG"] = $Palette[$Key]["G"] + $Surrounding;
$Color["BorderB"] = $Palette[$Key]["B"] + $Surrounding;
}
else {
$Color["BorderR"] = $BorderR;
$Color["BorderG"] = $BorderG;
$Color["BorderB"] = $BorderB;
}
if ($ForceAlpha != VOID) {
$Color["BorderAlpha"] = $ForceAlpha / 2;
}
}
}
foreach ($Data["Series"][$SerieName]["Data"] as $iKey => $Point) {
$Weight = $Point + $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey];
$PosArray = $this->pChartObject
->scaleComputeY($Point, array(
"AxisID" => $AxisID,
));
$WeightArray = $this->pChartObject
->scaleComputeY($Weight, array(
"AxisID" => $AxisID,
));
if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) {
if ($XDivs == 0) {
$XStep = 0;
}
else {
$XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin * 2) / $XDivs;
}
$Y = floor($PosArray);
$CircleRadius = floor(abs($PosArray - $WeightArray) / 2);
if ($Shape == BUBBLE_SHAPE_SQUARE) {
if ($RecordImageMap) {
$this->pChartObject
->addToImageMap("RECT", floor($X - $CircleRadius) . "," . floor($Y - $CircleRadius) . "," . floor($X + $CircleRadius) . "," . floor($Y + $CircleRadius), $this->pChartObject
->toHTMLColor($Palette[$Key]["R"], $Palette[$Key]["G"], $Palette[$Key]["B"]), $SerieDescription, $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]);
}
if ($BorderWidth != 1) {
$this->pChartObject
->drawFilledRectangle($X - $CircleRadius - $BorderWidth, $Y - $CircleRadius - $BorderWidth, $X + $CircleRadius + $BorderWidth, $Y + $CircleRadius + $BorderWidth, $BorderColor);
$this->pChartObject
->drawFilledRectangle($X - $CircleRadius, $Y - $CircleRadius, $X + $CircleRadius, $Y + $CircleRadius, $Color);
}
else {
$this->pChartObject
->drawFilledRectangle($X - $CircleRadius, $Y - $CircleRadius, $X + $CircleRadius, $Y + $CircleRadius, $Color);
}
}
elseif ($Shape == BUBBLE_SHAPE_ROUND) {
if ($RecordImageMap) {
$this->pChartObject
->addToImageMap("CIRCLE", floor($X) . "," . floor($Y) . "," . floor($CircleRadius), $this->pChartObject
->toHTMLColor($Palette[$Key]["R"], $Palette[$Key]["G"], $Palette[$Key]["B"]), $SerieDescription, $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]);
}
if ($BorderWidth != 1) {
$this->pChartObject
->drawFilledCircle($X, $Y, $CircleRadius + $BorderWidth, $BorderColor);
$this->pChartObject
->drawFilledCircle($X, $Y, $CircleRadius, $Color);
}
else {
$this->pChartObject
->drawFilledCircle($X, $Y, $CircleRadius, $Color);
}
}
$X = $X + $XStep;
}
elseif ($Data["Orientation"] == SCALE_POS_TOPBOTTOM) {
if ($XDivs == 0) {
$XStep = 0;
}
else {
$XStep = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1 - $XMargin * 2) / $XDivs;
}
$X = floor($PosArray);
$CircleRadius = floor(abs($PosArray - $WeightArray) / 2);
if ($Shape == BUBBLE_SHAPE_SQUARE) {
if ($RecordImageMap) {
$this->pChartObject
->addToImageMap("RECT", floor($X - $CircleRadius) . "," . floor($Y - $CircleRadius) . "," . floor($X + $CircleRadius) . "," . floor($Y + $CircleRadius), $this->pChartObject
->toHTMLColor($Palette[$Key]["R"], $Palette[$Key]["G"], $Palette[$Key]["B"]), $SerieDescription, $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]);
}
if ($BorderWidth != 1) {
$this->pChartObject
->drawFilledRectangle($X - $CircleRadius - $BorderWidth, $Y - $CircleRadius - $BorderWidth, $X + $CircleRadius + $BorderWidth, $Y + $CircleRadius + $BorderWidth, $BorderColor);
$this->pChartObject
->drawFilledRectangle($X - $CircleRadius, $Y - $CircleRadius, $X + $CircleRadius, $Y + $CircleRadius, $Color);
}
else {
$this->pChartObject
->drawFilledRectangle($X - $CircleRadius, $Y - $CircleRadius, $X + $CircleRadius, $Y + $CircleRadius, $Color);
}
}
elseif ($Shape == BUBBLE_SHAPE_ROUND) {
if ($RecordImageMap) {
$this->pChartObject
->addToImageMap("CIRCLE", floor($X) . "," . floor($Y) . "," . floor($CircleRadius), $this->pChartObject
->toHTMLColor($Palette[$Key]["R"], $Palette[$Key]["G"], $Palette[$Key]["B"]), $SerieDescription, $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]);
}
if ($BorderWidth != 1) {
$this->pChartObject
->drawFilledCircle($X, $Y, $CircleRadius + $BorderWidth, $BorderColor);
$this->pChartObject
->drawFilledCircle($X, $Y, $CircleRadius, $Color);
}
else {
$this->pChartObject
->drawFilledCircle($X, $Y, $CircleRadius, $Color);
}
}
$Y = $Y + $XStep;
}
}
}
}