I do not know whether this can be considered as a patch, rather it is feature. Not so long ago I had to make a pie chart (with labels) using your library. There is a tcpdf::PieSector function to draw a pie sector. Unfortunately, I wasn't able to find the function that draws a label inside or outside the sector. So I wrote it myself. Perhaps it will be interesting to you and the users of this library. Thank you for your time.
Code of the PieLabel method (see the attached file):
public function PieLabel($txt, $xc, $yc, $r, $a, $b, $l, $h=0) {
$angle = $a + $b / 2;
if ($angle >= 270) {
$angle = (360 - $angle) * M_PI / 180;
$x0 = ($r + $l) * sin($angle);
$y0 = ($r + $l) * cos($angle);
$this->Text($xc - $x0 - strlen($txt), $yc - $y0 - $h, $txt);
}
else if ($angle >= 180 && $angle < 270) {
$angle = ($angle - 180) * M_PI / 180;
$x0 = ($r + $l) * sin($angle);
$y0 = ($r + $l) * cos($angle);
$this->Text($xc - $x0 - strlen($txt), $yc + $y0 - $h, $txt);
}
else if ($angle >= 90 && $angle < 180) {
$angle = (180 - $angle) * M_PI / 180;
$x0 = ($r + $l) * sin($angle);
$y0 = ($r + $l) * cos($angle);
$this->Text($xc + $x0, $yc + $y0 - $h, $txt);
}
else {
$angle = $angle * M_PI / 180;
$x0 = ($r + $l) * sin($angle);
$y0 = ($r + $l) * cos($angle);
$this->Text($xc + $x0, $yc - $y0 - $h, $txt);
}
}
View and moderate all "patches Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Patches"
PieLabel
what is $l, $a and $b here? Perhaps, $a and $b are the start and end angles.
Last edit: Anonymous 2021-12-21