-
-
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
Legend with NSAttributedString and multiple lines on Vertical #1193
Comments
well, it seems like the legend canno't satisfy your needs... Would you please take a look at ChartLegend code to know how it renders? I want to help but it's a lot of work to answer your questions. |
@soniacasas NSattributedString support multiple formats, please check the example below: _labelns = NSMutableAttributedString()
for index in 0 ..< arrayData.count {
let word = arrayData[index] as! String
let newAttString = NSMutableAttributedString(string: "\(word)\n")
if index % 2 != 0 {
newAttString.addAttribute(NSForegroundColorAttributeName, value: self.textColor, range: NSMakeRange(0, word.characters.count))
} else {
newAttString.addAttribute(NSForegroundColorAttributeName, value: UIColor.grayColor(), range: NSMakeRange(0, word.characters.count))
}
_labelns!.appendAttributedString(newAttString)
} arrayData is an array with all the labels that you want to apply format, as you can see on my example this just change the color between the odd and even, in your case you need a different way to determine the case for every label, but you can add as many attributes as you want for every string, and then append to the legend. |
Hello, I'm answering in this post, because actually LegendEntry doesn't support custom font. I want add custom font in my legend, using attributed string, but it seem's allow us do it. Someone can help me? |
The same problem here. I tried to add custom font using LegendEntry, but it accept only string. |
Hi!
First of all thanks for this amazing job!
Is there a way to use NSAttributedString with the legend to have multiple colors and font sizes? I was trying to use setCustoms with [NSObjects] but reading the doc it says it's just a bridge, and it doesn't work.
Also i'm using the legend in a pie chart and is vertically positioned, the documentation says that word wrap is just usefull on horizontal, what can I do?
this is the sample code
I'm getting this
The text was updated successfully, but these errors were encountered: