- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
/* Draw the legend of the active series */
function drawLegend($X,$Y,$Format="")
{
$Family = isset($Format["Family"]) ? $Format["Family"] : LEGEND_FAMILY_BOX;
...
$Mode = isset($Format["Mode"]) ? $Format["Mode"] : LEGEND_VERTICAL;
if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
$YStep = max($this->FontSize,$BoxHeight) + 5;
$XStep = $BoxWidth + 5;
$XStep = $XSpacing;
$Data = $this->DataSet->getData();
$Boundaries = ""; $Boundaries["L"] = $X; $Boundaries["T"] = $Y; $Boundaries["R"] = 0; $Boundaries["B"] = 0; $vY = $Y; $vX = $X;
foreach($Data["Series"] as $SerieName => $Serie)
{
if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
{
if ( $Mode == LEGEND_VERTICAL )
{
$BoxArray = $this->getTextBox($vX+$BoxWidth+4,$vY+$BoxHeight/2,$FontName,$FontSize,0,$Serie["Description"]);
if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$BoxHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$BoxHeight/2; }
if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$BoxHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$BoxHeight/2; }
$Lines = preg_split("/\n/",$Serie["Description"]);
$vY = $vY + max($this->FontSize*count($Lines),$BoxHeight) + 5;
}
elseif ( $Mode == LEGEND_HORIZONTAL )
{
$Lines = preg_split("/\n/",$Serie["Description"]);
$Width = "";
foreach($Lines as $Key => $Value)
{
$BoxArray = $this->getTextBox($vX+$BoxWidth+6,$Y+$BoxHeight/2+(($YStep-3)*$Key),$FontName,$FontSize,0,$Value);
if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$BoxHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$BoxHeight/2; }
if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$BoxHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$BoxHeight/2; }
$Width[] = $BoxArray[1]["X"];
}
$vX=max($Width)+$XStep;
}
}
}
$vY=$vY-$YStep; $vX=$vX-$XStep;
$TopOffset = $Y - $Boundaries["T"];
if ( $Boundaries["B"]-($vY+$BoxHeight) < $TopOffset ) { $Boundaries["B"] = $vY+$BoxHeight+$TopOffset; }
if ( $Style == LEGEND_ROUND ) $this->drawRoundedFilledRectangle(...);
elseif ( $Style == LEGEND_BOX ) $this->drawFilledRectangle(...);
$RestoreShadow = $this->Shadow; $this->Shadow = FALSE;
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"];
$Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
if ( $Family == LEGEND_FAMILY_BOX )
}
$this->Shadow = $RestoreShadow;
}
Наша либа, которая рисует графики: функция рисующая легенду.