function pDraw::drawSplineChart in Visitors 7.2
Same name and namespace in other branches
- 7 pChart/class/pDraw.class.php \pDraw::drawSplineChart()
File
- pChart/
class/ pDraw.class.php, line 3435
Class
Code
function drawSplineChart($Format = NULL) {
$BreakVoid = isset($Format["BreakVoid"]) ? $Format["BreakVoid"] : TRUE;
$VoidTicks = isset($Format["VoidTicks"]) ? $Format["VoidTicks"] : 4;
$BreakR = isset($Format["BreakR"]) ? $Format["BreakR"] : NULL;
// 234
$BreakG = isset($Format["BreakG"]) ? $Format["BreakG"] : NULL;
// 55
$BreakB = isset($Format["BreakB"]) ? $Format["BreakB"] : NULL;
// 26
$DisplayValues = isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
$DisplayOffset = isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
$DisplayColor = isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
$DisplayR = isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
$DisplayG = isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
$DisplayB = isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
$RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
$ImageMapPlotSize = isset($Format["ImageMapPlotSize"]) ? $Format["ImageMapPlotSize"] : 5;
$this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
$Data = $this->DataSet
->getData();
list($XMargin, $XDivs) = $this
->scaleGetXSettings();
foreach ($Data["Series"] as $SerieName => $Serie) {
if ($Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"]) {
$R = $Serie["Color"]["R"];
$G = $Serie["Color"]["G"];
$B = $Serie["Color"]["B"];
$Alpha = $Serie["Color"]["Alpha"];
$Ticks = $Serie["Ticks"];
$Weight = $Serie["Weight"];
if ($BreakR == NULL) {
$BreakSettings = array(
"R" => $R,
"G" => $G,
"B" => $B,
"Alpha" => $Alpha,
"Ticks" => $VoidTicks,
);
}
else {
$BreakSettings = array(
"R" => $BreakR,
"G" => $BreakG,
"B" => $BreakB,
"Alpha" => $Alpha,
"Ticks" => $VoidTicks,
"Weight" => $Weight,
);
}
if ($DisplayColor == DISPLAY_AUTO) {
$DisplayR = $R;
$DisplayG = $G;
$DisplayB = $B;
}
$AxisID = $Serie["Axis"];
$Mode = $Data["Axis"][$AxisID]["Display"];
$Format = $Data["Axis"][$AxisID]["Format"];
$Unit = $Data["Axis"][$AxisID]["Unit"];
if (isset($Serie["Description"])) {
$SerieDescription = $Serie["Description"];
}
else {
$SerieDescription = $SerieName;
}
$PosArray = $this
->scaleComputeY($Serie["Data"], array(
"AxisID" => $Serie["Axis"],
));
$this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) {
if ($XDivs == 0) {
$XStep = ($this->GraphAreaX2 - $this->GraphAreaX1) / 4;
}
else {
$XStep = ($this->GraphAreaX2 - $this->GraphAreaX1 - $XMargin * 2) / $XDivs;
}
$X = $this->GraphAreaX1 + $XMargin;
$WayPoints = "";
$Force = $XStep / 5;
if (!is_array($PosArray)) {
$Value = $PosArray;
$PosArray = "";
$PosArray[0] = $Value;
}
$LastGoodY = NULL;
$LastGoodX = NULL;
$LastX = 1;
$LastY = 1;
foreach ($PosArray as $Key => $Y) {
if ($DisplayValues) {
$this
->drawText($X, $Y - $DisplayOffset, $this
->scaleFormat($Serie["Data"][$Key], $Mode, $Format, $Unit), array(
"R" => $DisplayR,
"G" => $DisplayG,
"B" => $DisplayB,
"Align" => TEXT_ALIGN_BOTTOMMIDDLE,
));
}
if ($RecordImageMap && $Y != VOID) {
$this
->addToImageMap("CIRCLE", floor($X) . "," . floor($Y) . "," . $ImageMapPlotSize, $this
->toHTMLColor($R, $G, $B), $SerieDescription, $this
->scaleFormat($Serie["Data"][$Key], $Mode, $Format, $Unit));
}
if ($Y == VOID && $LastY != NULL) {
$this
->drawSpline($WayPoints, array(
"Force" => $Force,
"R" => $R,
"G" => $G,
"B" => $B,
"Alpha" => $Alpha,
"Ticks" => $Ticks,
"Weight" => $Weight,
));
$WayPoints = "";
}
if ($Y != VOID && $LastY == NULL && $LastGoodY != NULL && !$BreakVoid) {
$this
->drawLine($LastGoodX, $LastGoodY, $X, $Y, $BreakSettings);
}
if ($Y != VOID) {
$WayPoints[] = array(
$X,
$Y,
);
}
if ($Y != VOID) {
$LastGoodY = $Y;
$LastGoodX = $X;
}
if ($Y == VOID) {
$Y = NULL;
}
$LastX = $X;
$LastY = $Y;
$X = $X + $XStep;
}
$this
->drawSpline($WayPoints, array(
"Force" => $Force,
"R" => $R,
"G" => $G,
"B" => $B,
"Alpha" => $Alpha,
"Ticks" => $Ticks,
"Weight" => $Weight,
));
}
else {
if ($XDivs == 0) {
$YStep = ($this->GraphAreaY2 - $this->GraphAreaY1) / 4;
}
else {
$YStep = ($this->GraphAreaY2 - $this->GraphAreaY1 - $XMargin * 2) / $XDivs;
}
$Y = $this->GraphAreaY1 + $XMargin;
$WayPoints = "";
$Force = $YStep / 5;
if (!is_array($PosArray)) {
$Value = $PosArray;
$PosArray = "";
$PosArray[0] = $Value;
}
$LastGoodY = NULL;
$LastGoodX = NULL;
$LastX = 1;
$LastY = 1;
foreach ($PosArray as $Key => $X) {
if ($DisplayValues) {
$this
->drawText($X + $DisplayOffset, $Y, $this
->scaleFormat($Serie["Data"][$Key], $Mode, $Format, $Unit), array(
"Angle" => 270,
"R" => $DisplayR,
"G" => $DisplayG,
"B" => $DisplayB,
"Align" => TEXT_ALIGN_BOTTOMMIDDLE,
));
}
if ($RecordImageMap && $X != VOID) {
$this
->addToImageMap("CIRCLE", floor($X) . "," . floor($Y) . "," . $ImageMapPlotSize, $this
->toHTMLColor($R, $G, $B), $SerieDescription, $this
->scaleFormat($Serie["Data"][$Key], $Mode, $Format, $Unit));
}
if ($X == VOID && $LastX != NULL) {
$this
->drawSpline($WayPoints, array(
"Force" => $Force,
"R" => $R,
"G" => $G,
"B" => $B,
"Alpha" => $Alpha,
"Ticks" => $Ticks,
"Weight" => $Weight,
));
$WayPoints = "";
}
if ($X != VOID && $LastX == NULL && $LastGoodX != NULL && !$BreakVoid) {
$this
->drawLine($LastGoodX, $LastGoodY, $X, $Y, $BreakSettings);
}
if ($X != VOID) {
$WayPoints[] = array(
$X,
$Y,
);
}
if ($X != VOID) {
$LastGoodX = $X;
$LastGoodY = $Y;
}
if ($X == VOID) {
$X = NULL;
}
$LastX = $X;
$LastY = $Y;
$Y = $Y + $YStep;
}
$this
->drawSpline($WayPoints, array(
"Force" => $Force,
"R" => $R,
"G" => $G,
"B" => $B,
"Alpha" => $Alpha,
"Ticks" => $Ticks,
"Weight" => $Weight,
));
}
}
}
}