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

fix: allow padding function 2 #887

Merged
merged 3 commits into from
Feb 11, 2025
Merged

fix: allow padding function 2 #887

merged 3 commits into from
Feb 11, 2025

Conversation

bao-ho
Copy link
Collaborator

@bao-ho bao-ho commented Dec 3, 2024

Checklist

Description

This PR is a continuation from my last PR #880
It handles the cases where paddings can be functions. This comes in handy when there is a need for flexible placement of labels that are dependent on some bars.

@bao-ho bao-ho requested a review from veinfors December 3, 2024 11:49
@@ -209,6 +209,10 @@ export function findBestPlacement(

function approxTextBounds(label, textMetrics, rotated, rect, padding = {}) {
const { top = PADDING, bottom = PADDING, left = PADDING, right = PADDING } = padding;
const leftPadding = typeof left === 'function' ? left(textMetrics) : left;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same padding properties as you added and documented in your previous PR, right? So there is no need for adding anything new in the api specs if I understand correct.

Could you adjust the testcase you added in. the last pr to also validate these bounds gets calculated using the functions?

@quanho quanho self-requested a review February 10, 2025 13:06
@quanho quanho merged commit f4ba42e into master Feb 11, 2025
12 checks passed
@quanho quanho deleted the gqm/allow-padding-functions-4 branch February 11, 2025 08:04
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

Successfully merging this pull request may close these issues.

3 participants