-
-
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
Custom Format YAxis #1768
Comments
that's because in Chart 3.0, axis changes to use public init(formatter: NumberFormatter)
{
super.init()
self.formatter = formatter
} Just take a look at these classes. /// Sets the formatter to be used for formatting the axis labels.
/// If no formatter is set, the chart will automatically determine a reasonable formatting (concerning decimals) for all the values that are drawn inside the chart.
/// Use `nil` to use the formatter calculated by the chart.
open var valueFormatter: IAxisValueFormatter?
{
get
{
if _axisValueFormatter == nil ||
(_axisValueFormatter is DefaultAxisValueFormatter &&
(_axisValueFormatter as! DefaultAxisValueFormatter).hasAutoDecimals &&
(_axisValueFormatter as! DefaultAxisValueFormatter).decimals != decimals)
{
_axisValueFormatter = DefaultAxisValueFormatter(decimals: decimals)
}
return _axisValueFormatter
}
set
{
_axisValueFormatter = newValue ?? DefaultAxisValueFormatter(decimals: decimals)
}
} |
I am getting this error - Cannot assign value of type 'DayAxisValueFormatter' to type '(any AxisValueFormatter)?' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to use a custom format in YAxis, specifically I'm trying to put a "$" symbol and a thousands separator "," also I want to put the thousands separator on the value that is showing above the bars.
Looking in documentation, you use the NSNumberFormatter but I can't, XCode show me an error.
I'm using this code:
let formatoNumeros: NSNumberFormatter = NSNumberFormatter()
formatoNumeros.minimumFractionDigits = 0
formatoNumeros.maximumFractionDigits = 2
formatoNumeros.currencyGroupingSeparator = ","
formatoNumeros.negativeSuffix = " $"
formatoNumeros.positiveSuffix = " $"
yaxis.valueFormatter = formatoNumeros
The error appears on the line:
yaxis.valueFormatter = formatoNumeros
and it says: "Cannot assign value of type 'NSNumberFormatter' to type 'IAxisValueFormatter', also I've tried casting the variable but it cannot be posible and also have tried to use the NSNumberFormatter on the chartData, like this:chartData.setValueFormatter(formatoNumeros)
but here XCode says that cannot assign value of type NSNumber.. to IValueFormatter.And my questions is what would be the way or ways to customize the YAxis on BarCharts?
PS. The language I'm using is swift
Thanks!
The text was updated successfully, but these errors were encountered: