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

Label-angles #145

Merged
merged 2 commits into from
Mar 20, 2025
Merged

Label-angles #145

merged 2 commits into from
Mar 20, 2025

Conversation

eatyourpeas
Copy link
Member

Overview

Fix for issue #143 identified by @gabrielfreitas (thank you)

There are in fact two problems

  1. the interval between the labels did not resize on zoom
  2. the inline labels should rotate to the gradient of the centile line. This is only partially fixed.

Issue one was fixed with a refactor of thelabelIndexInterval function. This now mandates 2 labels to be visible in the viewport at any time, irrespective of the domains of the chart and degree of zoom.

Issue 2 is only partially fixed and actually I am not completely sure how best completely to solve this. The problem resides within the labelAngle function which receives the data for each line, the domains of the chart, the reference, sex and other parameters and uses this to identify x and y values above and below the label to calculate the gradient and rotate the label accordingly. Where the x axis values are close together (such as in infancy), a multiplier is used to increase the accuracy.

The difficulty here possibly sits within the way Victory handles labels as there seems to be some offsetting that occurs that interferes as the labels are perfect in some places and off by some margin in others. This has meant a certain amount of trial and error with conditionals for different charts and measurement methods. Not ideal. If someone has a more concise approach with a better knowledge of the VictoryLabel component I am all ears.

This PR at least fixes the core problem and restores the label angle to how it was.

closes #143

@eatyourpeas eatyourpeas merged commit 61aed1c into live Mar 20, 2025
4 of 5 checks passed
@eatyourpeas eatyourpeas deleted the label-angles branch March 20, 2025 19:33
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.

Centile labels do not appear when the lifespan is zoomed in
1 participant