Thanks Claude, I agree it is rather strange and feels like a bug.
I should explain that in the real code I’ve created a generic view containing a chart that can plot different types of data e.g. speed, temperature, pressure with different scales. In one case temperature and humidity are shown at the same time using different leading and trailing scales. The scales for the data are part of the data model. This means I can’t use a static scale for chartYScale, the scale needs to adjust depending on the data being plotted.
I found a work around using chartYScale and pass a function to chartYScale that returns a range
e.g.
.chartYScale(
domain: self.yAxisDomain(),
type: .linear
)
The function works out what the scale should be depending on the data being plotted and is scale in the data model. The crucial thing is the function needs to produce the same scale as the code under chartYAxis, then scales values are as expected and no inversion occurs.