Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Fix for issue #143 identified by @gabrielfreitas (thank you)
There are in fact two problems
Issue one was fixed with a refactor of the
labelIndexInterval
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