-
-
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
How to show custom text on Y-axis of Line Chart? #1720
Comments
It's not complicated let leftAxis = scatterChartView.leftAxis
leftAxis.valueFormatter = DoubleAxisValueFormatter(postFixe: "m/s") and open class DoubleAxisValueFormatter : NSObject, IAxisValueFormatter
{
open var postFixe :String = ""
public init(postFixe: String)
{
self.postFixe = postFixe
}
public func stringForValue(_ value: Double, axis: AxisBase?) -> String
{
let formatter = NumberFormatter()
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2
formatter.localizesFormat = true
let num = NSDecimalNumber(value: value)
let strVal = formatter.string( from: num)
let str = strVal! + " " + postFixe
return str
}
} |
edited @thierryH91200 post. good job! |
Guys thanks for helping out, however I'm using version 2.2.5. Can you help out as I believe the above answer is valid only for 3.0 and above of charts version. And also it's just I want to display 'visits/day', no number. Left axis just has a textual unit representation. Thanks in advance. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using line chart view in my app. Here's the screenshot of the line chart.
However I don't want the auto-calculated values on the y-axis (e.g 1.800, 2.000, 2.200), instead I want to put my unit value, e.g 'miles/h', 'meters/sec' etc.
How can I achieve this?
I also want to toggle values on a node when tapped. Is there a way to achieve this?
I've searched for the first one I didn't find it.
The text was updated successfully, but these errors were encountered: