function pDraw::drawPlotChart
Search API
5.x pDraw.class.php | pDraw::drawPlotChart($Format = NULL) |
File
- inc/
pchart/ pchart/ class/ pDraw.class.php, line 3332
Class
Code
function drawPlotChart($Format = NULL)
{
$PlotSize = isset($Format ["PlotSize"]) ? $Format ["PlotSize"] : NULL;
$PlotBorder = isset($Format ["PlotBorder"]) ? $Format ["PlotBorder"] : FALSE;
$BorderR = isset($Format ["BorderR"]) ? $Format ["BorderR"] : 50;
$BorderG = isset($Format ["BorderG"]) ? $Format ["BorderG"] : 50;
$BorderB = isset($Format ["BorderB"]) ? $Format ["BorderB"] : 50;
$BorderAlpha = isset($Format ["BorderAlpha"]) ? $Format ["BorderAlpha"] : 30;
$BorderSize = isset($Format ["BorderSize"]) ? $Format ["BorderSize"] : 2;
$Surrounding = isset($Format ["Surrounding"]) ? $Format ["Surrounding"] : NULL;
$DisplayValues = isset($Format ["DisplayValues"]) ? $Format ["DisplayValues"] : FALSE;
$DisplayOffset = isset($Format ["DisplayOffset"]) ? $Format ["DisplayOffset"] : 4;
$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;
$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"])
{
if (isset($Serie ["Weight"])) {
$SerieWeight = $Serie ["Weight"] + 2;
}
else {
$SerieWeight = 2;
}
if ($PlotSize != NULL) {
$SerieWeight = $PlotSize;
}
$R = $Serie ["Color"]["R"];
$G = $Serie ["Color"]["G"];
$B = $Serie ["Color"]["B"];
$Alpha = $Serie ["Color"]["Alpha"];
$Ticks = $Serie ["Ticks"];
if ($Surrounding != NULL) {
$BorderR = $R + $Surrounding;
$BorderG = $G + $Surrounding;
$BorderB = $B + $Surrounding;
}
if (isset($Serie ["Picture"]))
{
$Picture = $Serie ["Picture"];
list($PicWidth, $PicHeight, $PicType) = $this->getPicInfo($Picture);
}
else {
$Picture = NULL;
$PicOffset = 0;
}
if ($DisplayColor == DISPLAY_AUTO) {
$DisplayR = $R;
$DisplayG = $G;
$DisplayB = $B;
}
$AxisID = $Serie ["Axis"];
$Shape = $Serie ["Shape"];
$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;
}
if ($Picture != NULL) {
$PicOffset = $PicHeight / 2;
$SerieWeight = 0;
}
$X = $this->GraphAreaX1 + $XMargin;
if (!is_array($PosArray)) {
$Value = $PosArray;
$PosArray = "";
$PosArray [0] = $Value;
}
foreach ($PosArray as $Key => $Y)
{
if ($DisplayValues) {
$this->drawText($X, $Y -$DisplayOffset -$SerieWeight -$BorderSize -$PicOffset, $this->scaleFormat($Serie ["Data"][$Key], $Mode, $Format, $Unit), array("R" => $DisplayR, "G" => $DisplayG, "B" => $DisplayB, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
}
if ($Y != VOID)
{
if ($RecordImageMap) {
$this->addToImageMap("CIRCLE", floor($X) . "," . floor($Y) . "," . $SerieWeight, $this->toHTMLColor($R, $G, $B), $SerieDescription, $this->scaleFormat($Serie ["Data"][$Key], $Mode, $Format, $Unit));
}
if ($Picture != NULL)
{
$this->drawFromPicture($PicType, $Picture, $X -$PicWidth / 2, $Y -$PicHeight / 2);
}
else
{
$this->drawShape($X, $Y, $Shape, $SerieWeight, $PlotBorder, $BorderSize, $R, $G, $B, $Alpha, $BorderR, $BorderG, $BorderB, $BorderAlpha);
}
}
$X = $X + $XStep;
}
}
else
{
if ($XDivs == 0) {
$YStep = ($this->GraphAreaY2 -$this->GraphAreaY1) / 4;
}
else {
$YStep = ($this->GraphAreaY2 -$this->GraphAreaY1 -$XMargin * 2) / $XDivs;
}
if ($Picture != NULL) {
$PicOffset = $PicWidth / 2;
$SerieWeight = 0;
}
$Y = $this->GraphAreaY1 + $XMargin;
if (!is_array($PosArray)) {
$Value = $PosArray;
$PosArray = "";
$PosArray [0] = $Value;
}
foreach ($PosArray as $Key => $X)
{
if ($DisplayValues) {
$this->drawText($X + $DisplayOffset + $SerieWeight + $BorderSize + $PicOffset, $Y, $this->scaleFormat($Serie ["Data"][$Key], $Mode, $Format, $Unit), array("Angle" => 270, "R" => $DisplayR, "G" => $DisplayG, "B" => $DisplayB, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
}
if ($X != VOID)
{
if ($RecordImageMap) {
$this->addToImageMap("CIRCLE", floor($X) . "," . floor($Y) . "," . $SerieWeight, $this->toHTMLColor($R, $G, $B), $SerieDescription, $this->scaleFormat($Serie ["Data"][$Key], $Mode, $Format, $Unit));
}
if ($Picture != NULL)
{
$this->drawFromPicture($PicType, $Picture, $X -$PicWidth / 2, $Y -$PicHeight / 2);
}
else
{
$this->drawShape($X, $Y, $Shape, $SerieWeight, $PlotBorder, $BorderSize, $R, $G, $B, $Alpha, $BorderR, $BorderG, $BorderB, $BorderAlpha);
}
}
$Y = $Y + $YStep;
}
}
}
}
}