Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get width and height from legend #141

Open
flip111 opened this issue Feb 8, 2023 · 0 comments
Open

get width and height from legend #141

flip111 opened this issue Feb 8, 2023 · 0 comments

Comments

@flip111
Copy link

flip111 commented Feb 8, 2023

Could the code calculating the legend width and height

$abs_height = 0;
for ($i = 0; $i < $rows; ++$i) {
$abs_height += $rowheight[$i];
}
// Make sure that the height is at least as high as mark size + ymargin
$abs_height = max($abs_height, $this->mark_abs_vsize);
$abs_height += $this->ybottom_margin;
// Find out the maximum width in each column
for ($i = $numcolumns; $i < $n; ++$i) {
$colwidth[$i % $numcolumns] = max(
$aImg->GetTextWidth($this->txtcol[$i][0]) + 2 * $this->xmargin + 2 * $this->mark_abs_hsize,
$colwidth[$i % $numcolumns]
);
}
// Get the total width
$mtw = 0;
for ($i = 0; $i < $numcolumns; ++$i) {
$mtw += $colwidth[$i];
}
// remove the last rows interpace margin (since there is no next row)
$abs_height -= $this->ylinespacing;
// Find out maximum width we need for legend box
$abs_width = $mtw + $this->xlmargin + ($numcolumns - 1) * $this->mark_abs_hsize;
be refactored into it's own function?

That way we can get the width and height with getter functions. Use case is then you know exactly how big to set the plot margins to reserve sufficient space for the legend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant