Legend position above yAxis bar chart
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
How can I set properly legend position right above yAxis (so it will look like attached image1 always)

Now I did like this:
let legend = barChart.legend
legend.form = .none
legend.textColor = UIColor.white
legend.verticalAlignment = .top
legend.horizontalAlignment = .left
legend.direction = .leftToRight
legend.xOffset = -160.0 (bad hardcode)
leftAxis.spaceTop = 0.16 (some space for legend)
so sometimes yAxis values almost covered my legend (image 2):

or in other way - too far (image 3)

maybe I should use not legend, but some other instrument from bar charts?
Thank you in advance for answer
Contributor guide
Research direction
Start with the barChart.legend and leftAxis configuration described in the issue, reproducing the three shown positioning outcomes across different chart sizes and y-axis values. The work is done when the legend remains directly above the yAxis without relying on the hardcoded xOffset or manually reserved spaceTop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- data-visualization, mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100