Hi,
I’m using SciChart for macOS (v4.4.2.5871 installed via CocoaPods) and one thing that I tried was to implement the an axis to show full extent of data, as described in the first bullet of https://www.scichart.com/documentation/ios/current/axis-ranging—get-or-set-visiblerange.html#zooming-to-fit-all-the-data
However, what I’m getting is that after setting the visibleRange
to match the dataRange
, the dataRange
no longer reflects the “true” range, but something else. Also “zoom to extent” no longer works
Attached is a super basic example (project) for this. To reproduce, do the following:
- Do a zoom (via pinch)
- Click the button titled “Set visibleRange to dataRange” -> this step works as expected
- Do a zoom
- Click again the button -> “zoom to extent” no longer works,
dataRange
is messed up
- Vlad Badea asked 1 year ago
- You must login to post comments
After writing the above ticket (and also https://www.scichart.com/questions/ios/restricting-visiblerange-causes-the-app-to-hang), it hit me where the problem is: visibleRange
property has a strong
semantic, meaning it will point to object passed as parameter and will increment its reference count. Also, most likely the getter of dataRange
returns a pointer to the object used internally, not a copy of it.
This means doing visibleRange = dataRange
will cause visibleRange and dataRange to point to the same object. Panning or zooming will cause modifications to object referenced by visibleRange
, and which is also referenced by dataRange
-> hence the dataRange
will contain wrong values.
To test the above, I did the following:
xAxis.visibleRange = SCIDoubleRange(min: xAxis.dataRange.minAsDouble, max: xAxis.dataRange.maxAsDouble)
yAxis.visibleRange = SCIDoubleRange(min: yAxis.dataRange.minAsDouble, max: yAxis.dataRange.maxAsDouble)
After this change everything works as expected.
If what I said is true, then my recommendation is to update the documentation, because they will lead into bad behavior, no matter if you do iOS or Mac or Swift or Obj C.
- Vlad Badea answered 1 year ago
- last edited 1 year ago
- Hi Vlad, it is the weekend, but I did see this and you’re absolutely right – it’s generally a good idea to treat all DoubleRange objects as immutable, creating a new one when assigning to a property like visibleRange. Glad you found the solution and point noted about the docs!
- You must login to post comments
Please login first to submit.