The library cannot do this automatically, but there is the following option.
You check if your data contains exactly one point. If yes, then you add a so called LimitLine.
For example:
let limitLine = ChartLimitLine(
limit: value,
label: labelText)
limitLine.lineColor = .blue
limitLine.labelPosition = .topLeft
limitLine.valueFont = UIFont.systemFont(ofSize: 14)
chartView.leftAxis.addLimitLine(limitLine)
For Swift Charts (Xcode 14 Beta)
Should someone decide to do something similar with Apple's Swift Charts, RuleMark() can be used to draw the line and PointMark() for a point like this:
Chart() {
RuleMark(
xStart: .value("Start", 0),
xEnd: .value("End", 20),
y: .value("Value", 125)
)
PointMark(
x: .value("X Value", 10),
y: .value("Y Value", 125)
)
}
Example Output:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.