PiChartView center label text scale
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
## What did you do?
I created a PichartView and passed text to the center label.
```
private lazy var pieChartView: PieChartView = {
let pieChartView = PieChartView()
pieChartView.shouldHideToolbarPlaceholder = true
pieChartView.legend.enabled = false
pieChartView.holeRadiusPercent = 0.83
pieChartView.noDataText = ""
pieChartView.highlightPerTapEnabled = false
return pieChartView
}()
```
```
private func setChartCenterText(_ response: InvoiceInfos) {
let amountAtt = NSMutableParagraphStyle()
amountAtt.alignment = .center
let amountWithComma = "\(response.amount)".replaceComma
let amountAttributetText = NSMutableAttributedString(
string: "\(amountWithComma) ₺",
attributes: [
.font: UIFont.medium18,
.paragraphStyle: amountAtt
]
)
let subAtribute = NSMutableParagraphStyle()
subAtribute.alignment = .center
let subAttributedText = NSAttributedString(
string: "\n\(response.energyExpended)".replacingOccurrences(of: ".", with: ",").replaceComma + " kWh", attributes: [
.paragraphStyle: subAtribute,
.font: UIFont.light14
]
)
amountAttributetText.append(subAttributedText)
pieChartView.centerAttributedText = amountAttributetText
}
```
## What did you expect to happen?

When a short value comes in it looks like I want it.
## What happened instead?

But I can't scale the long incoming text.
How can I scale PiChartView center label text?
## Charts Environment
Charts version: 3.6.0
Xcode version: 12.5
Swift version: 5.3
Platform(s) running Charts: iOS Platfrom
Contributor guide
Research direction
Start by reproducing the issue with PieChartView and the provided centerAttributedText, comparing short and long values. Trace how the center label is laid out and identify the relevant tests or entry point; done means long center text scales or fits correctly while preserving the supplied formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100