-
-
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
Added value text rotation #2200
Conversation
Codecov Report
@@ Coverage Diff @@
## 4.0.0 #2200 +/- ##
=========================================
+ Coverage 29.98% 30.18% +0.2%
=========================================
Files 116 116
Lines 13197 13252 +55
=========================================
+ Hits 3957 4000 +43
- Misses 9240 9252 +12
Continue to review full report at Codecov.
|
@chinh-tran are you able to rebase on master? |
@jjatie yes, rebase done :) |
if this is a good feature to have, let's target 4.0 branch? |
I think this is good for 4.0 |
Alright, I replayed the changes onto 4.0.0. |
@@ -302,6 +302,9 @@ open class ChartBaseDataSet: NSObject, ChartDataSetProtocol | |||
/// the font for the value-text labels | |||
open var valueFont: NSUIFont = NSUIFont.systemFont(ofSize: 7.0) | |||
|
|||
/// the rotation angle for value-text labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to "The rotation angle (in degrees) for value-text labels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change it in the protocol, you can delete the documentation comment here and Xcode will use the one from the protocol.
@@ -302,6 +302,9 @@ open class ChartBaseDataSet: NSObject, ChartDataSetProtocol | |||
/// the font for the value-text labels | |||
open var valueFont: NSUIFont = NSUIFont.systemFont(ofSize: 7.0) | |||
|
|||
/// the rotation angle for value-text labels | |||
open var valueRotationAngle: CGFloat = CGFloat(0.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valueLabelAngle
@@ -200,6 +200,9 @@ public protocol ChartDataSetProtocol | |||
/// the font for the value-text labels | |||
var valueFont: NSUIFont { get set } | |||
|
|||
/// the rotation angle for value-text labels | |||
var valueRotationAngle: CGFloat { get set } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valueLabelAngle
Source/Charts/Utils/ChartUtils.swift
Outdated
@@ -209,6 +207,21 @@ extension CGContext { | |||
NSUIGraphicsPopContext() | |||
} | |||
|
|||
func getDrawPoint(text: String, point: CGPoint, align: NSTextAlignment, attributes: [NSAttributedStringKey : Any]?) -> CGPoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private func
{ | ||
// align left to center text with rotation | ||
context.drawText(value, at: CGPoint(x: xPos, y: yPos), align: align, anchor: anchor, | ||
angleRadians: angleRadians, attributes: [.font: font, .foregroundColor: color]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no line break please
Ah! Sorry, I thought I had submitted this review ages ago. @chinh-tran please take a look |
@jjatie It's updated now, however the CI build is failing but it's not related to this PR I guess. |
No, it’s my fault. I moved 4.0.0 to swift 4.1 and forgot to update the Travis script. It’s done in a different branch atm, but @liuxuan30 is busy this week. I’ll let you know when it’s merged. |
@jjatie I'm seeing many PRs you updated and many conflicts. Is this caused by new commits on 4.0 branch? |
@liuxuan30 4.0.0 is updated for Swift 4.1, but I forgot to update the travis ci file. It's updated in the top ticket in the 4.0 project, so when that's merged everything will be good to go again. |
Can you send me the link. I didn't see a similar one neither in More Swift nor 4.0 project |
would love to see in this feature in master,is there any plan on master to archive this? |
I've implemented the option to rotate value texts, which looks like below:
Usage:
There is a new attribute in
IChartDataSet
:and
ChartBaseDataSet
:In order to rotate the values, I'm reusing the drawText function in ChartUtils, which is already being used to rotate the labels: