You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there. I'm new to Swift, and after hours of research, I still can't find a solution to my problem. I have a bar chart where I would like to have custom values over each bar. Here's a screenshot of the look I'm trying to achieve:
Unfortunately, none of the pre-existing NSNumberFormatterStyles will give me the bottom metric (abbreviated currency string), and I don't see how I can pass an individual bar's value and the sum of all values into a customNumberFormatter to get the top metric (percentage), so that I can have my formatter return a string interpolated with both metrics.
Another solution I thought to try was to access the coordinates and height of each bar and simply create and populate a UILabel over each bar, but when I try:
for entry in chartDataSet or barChartView.data or chartData {
var barRect : CGRect = barChartView.getBarBounds(entry)
...
}
I get " does not have a member named 'Generator'". I apologize if this is a noob question, but I'm honestly at my wit's end.
The text was updated successfully, but these errors were encountered:
trishfromtisch
changed the title
Using NSNumberFormatter or to Display Custom Values
Using NSNumberFormatter or .getBarBounds() to Display Custom Values
Aug 14, 2015
The thing about NSNumberFormatter, is that it can do almost anything, including the "33.3%" or the "$12.4M".
And then you have the case where you just have to have it output weird values. Like "33.3%\n$12.4M". Then come in classic inheritance. Just subclass NSNumberFormatter, and make it spit out the strings that you need for the values it gets. It can include new lines...
About the "does not have a member named 'Generator'" error, it's a common compiler problem, meaning you probably passed an incorrect type. Look carefully at the type it receives and what you pass in, especially any optionals.
Also it currently returns an automatically unwrapped optional CGRect! (which will probably be changed to CGRect? in the future) - so that could also be the cause of the error.
Hi there. I'm new to Swift, and after hours of research, I still can't find a solution to my problem. I have a bar chart where I would like to have custom values over each bar. Here's a screenshot of the look I'm trying to achieve:
Unfortunately, none of the pre-existing NSNumberFormatterStyles will give me the bottom metric (abbreviated currency string), and I don't see how I can pass an individual bar's value and the sum of all values into a customNumberFormatter to get the top metric (percentage), so that I can have my formatter return a string interpolated with both metrics.
Another solution I thought to try was to access the coordinates and height of each bar and simply create and populate a UILabel over each bar, but when I try:
for entry in chartDataSet or barChartView.data or chartData {
var barRect : CGRect = barChartView.getBarBounds(entry)
...
}
I get " does not have a member named 'Generator'". I apologize if this is a noob question, but I'm honestly at my wit's end.
The text was updated successfully, but these errors were encountered: