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

Implemented support for rotated labels on the x-axis #513

Merged
merged 1 commit into from
Oct 27, 2015

Conversation

danielgindi
Copy link
Collaborator

No description provided.

danielgindi added a commit that referenced this pull request Oct 27, 2015
Implemented support for rotated labels on the x-axis (Resolves #61)
@danielgindi danielgindi merged commit 13306c3 into master Oct 27, 2015
@danielgindi danielgindi deleted the x-axis-label-rotation branch October 27, 2015 20:31
@liuxuan30
Copy link
Member

do you mind explaining some core parts here? sort of lost after looking at various offset and size and the radians... and of cause the scene behind rotation? :) Thanks a lot!

@danielgindi
Copy link
Collaborator Author

Well:

In some places the charts are trying to figure out a labels width/height,
or the "longest label".
This is invalid now because the label may be rotated, so I calculate the
width/height of the box enclosing the rotated label (some trigonometry
magic)

The old drawing method always took a point, drawn the text above it
(that's android's behavior), and to the right/left/center of it depending
on the align property.
Now a label may be rotated, and after some trial and error, I figured out
that the label should always be rotated around its center. So the drawing
function takes a point, plays with matrices and renders the label.

Now in some cases we still want alignment.
Like drawing everything to the left/right i.e in horizontal bar's axis.
Or draw th label below/above the point, becuase we don't want the labels to
be aligned vertically and then the axis looks wierd. I tried custom offsets
but it does not offer a solution.
So now instead of aligning the drawing on the corner of the label and
rotating around it- I align it to the corner of the outer box enclosing the
rotated label. That's a trick that took some time to figure out.

To specify the alignment I'm using float x/y, where 0.0 x means the label
draws to the right of the specified point, 1.0 means to the left. y=0 means
below, 1.0 means above.
Basically the anchor point is the percentage on the outer rect, at which
the anchor point resides.

‏בתאריך יום רביעי, 28 באוקטובר 2015, Xuan notifications@github.com כתב:

do you mind explain some core parts here? sort of lost after looking at
various offset and size and the radians... and of cause the scene behind
rotation? :) Thanks a lot!


Reply to this email directly or view it on GitHub
#513 (comment)
.

@liuxuan30
Copy link
Member

Thanks for the details!

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.

2 participants