-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Feature] added ability to rotate ChartLimitLine label #5085
Conversation
@pmairoldi, @FelixHerrmann, @liuxuan30, could I get a review of this PR? |
@berbaspin could you share a screenshot, what this can achieve? how 'configurable' the angle can be? Have you tested it thoroughfuly? btw if the angle is fully configurable, I would hope we could add a UT for this feature? like define 0/30/45/60/90/180 degree rotation for one chart(e.g. line chart) so we make sure this is robust. |
@liuxuan30 previously, we had a functionality that allowed us to rotate the xAxis label. I added the same functionality for Limit Line. As example: 90 degrees. But also we can use non-standard angle. Examples: 17 and 285 degrees We can rotate limit line without xAxis label rotation. I tested this on Bar Chart, Line Chart and Horizontal Chart. For all types of label position (leftTop, leftBottom, rightTop, rightBottom). Examples: Yeah, I also can write a UT for this feature. Will it be enough to write 3 tests with different angles?
|
So we are just adding limitline label rotation, no xAxis label rotation, right? What's the center of the rotated limitline label? e.g. where's the center of the limitline label in different angel? Is the center same as non rotated position? |
Yeah, I suggest we add 30/45/60/90/120/180 to cover the typical angles |
@liuxuan30, yes. My pull request contains only limitline label rotation. Example of rotation by 3 angles (0, 45, 90) of horizontal limit line. Example of rotation by 3 angles (45, 90, 180) of vertical limit line. |
Are the tests above correct? I can append 45/60/120/180 to them and update current pull request. |
@pmairoldi @jjatie any comments? I think we could get this merged. |
Seems fine to me. |
ok then. @berbaspin please help add the tests, and we will take a look and move forward, thank you for your efforts! |
@liuxuan30, cool! Should I create new commit with tests or will you add them by yourself?
|
@liuxuan30, are there any improvements I should make? |
Sorry for the late response, took a week off work. I have completed the review, left a few comments. Meanwhile, I have triggered the work flow so we can check the CI result later |
regarding |
labelLineRotated_Width/Height got the same position
@liuxuan30, I added two commits:
We can abandon align, because it was used only for calculating the position of the label. But I used a different methodology. In method, that was used before, the anchor was CGPoint(x: 0.5, y: 0.5) and TextAlignment (.left or .right). It works fine with non rotated labels. That's why I decided to Ρhange label x position by calculating labelLineRotatedWidth and set anchor to CGPoint(x: 0.0, y: 0.0).
|
thanks! let's wait for the CI results |
I'm kind of concerned that, it used to support |
@liuxuan30, sorry, but I can't find the place, where we can change the alignment of the limitline's label. Neither
There are no cases centerTop or centerBottom. This function also doesn't have the alignment parameter. But there is an initialization of align and a value assignment depending of
The first function was used with ChartLimitLine label in current version of DGCharts. But I replaced it with the second one. If user overrides one of this function P.S. Just for test. I took the current of DGCharts and tried to change align for leftAxis limit line label from .left to .center in |
Previously I added generated images for
Can you create them for x86_64? Using Rosetta I got an error:
|
I can. I will update today or tomorrow. Let's check if iOS CI works, it was canceld that I don't know how. @berbaspin please add me with write acess to your Charts fork repo |
My mistake. My memory with Charts is rusty. You are right that this is the entry for drawText, not the opposite. I was thinking you are modifying drawText(), but actually it's renderLimitLines. So should be fine. Let's fix the CI issues and get it merged |
@liuxuan30, I sent the invite |
it's strange that master passed CI easily. Not sure why this PR always has canceled. Need investigate further. |
I trigged a test CI https://github.com/danielgindi/Charts/actions/runs/5933792579, it seems after correctly generating snapshots for the specific arch, it can now pass. the cancelled failures look like due to arch issue. |
add tvOS and iOS snapshots on x64 arch
@liuxuan30, thank you! I merged your pull request |
All green and merged. Thank you! |
* gindi-master: (55 commits) [Feature] added ability to rotate ChartLimitLine label (ChartsOrg#5085) update readme fix podspec update ci update readme versions fix build issue remove swift-algorithms package in favor of manully importing needed functions fix ChartsOrg#5033: always run snapshot tests in light mode update tvos undo framework bump bump min version to 13 for ios project Bump actions/checkout to v3 Fix Xcode 14.3 import warnings add discardable results to operations that do not require result update readme to change name update workflow to run on release branches Change library name from Charts to DGCharts Unnecessary space Removal and Semicolons are removed Update README.md Turn on the BUILD_LIBRARY_FOR_DISTRIBUTION flag ...
* added labelRotationAngle to ChartLimitLine * added limit line label rotation tests * fixed the code style labelLineRotated_Width/Height got the same position * generated test images for apple TV * add snapshots on x64 arch for tvOS and iOS --------- Co-authored-by: Xuan <liuxuan30@noreply.github.com>
Goals β½
Added labelRotationAngle to ChartLimitLine
Testing Details π
Tested on line chart and horizontal bar chart both XAxis and YAxis and all four label positions.