map limit line yOffset to a specific data point on chart
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
How can we map the limit line yOffset to a specific data point on the chart?
In my app, the height of the chart view depends on the height of the device. For example, the chart on a 5S device has a chartView.frame.size.height value that is less than that of a XR device. The amount of data shown on the chart, however, is the same (therefore, charts on taller screens have more space between data points).
I'm trying to set the yoffset of several vertical limit lines so that the label appears at the same spot on the chart relative to the data. For example, I'm trying to set a y offset so that the limit line label appears at the origin of the chart. However, on a shorter screen, the label appears at one position, and on a taller screen, it appears at another position.
This is my code but I've tried to play around with viewport content height, chart frame height, and transformers but with no luck.
`let limitLine = ChartLimitLine(limit: date.timeIntervalSince1970, label: viewModel.getFormattedXLabel(date: date))`
`limitLine.labelPosition = .bottomRight`
`limitLine.yOffset = 10.0`
How can I compute the limitLine.yOffset value so that it maps to a specific data point (and therefore would be consistent across all iOS devices)?
Contributor guide
Assessment
This issue has not been assessed yet.