Pre loader

Setting `visibleRange` messes `dataRange`

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

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:

  1. Do a zoom (via pinch)
  2. Click the button titled “Set visibleRange to dataRange” -> this step works as expected
  3. Do a zoom
  4. Click again the button -> “zoom to extent” no longer works, dataRange is messed up
Version
4.4.2.5871
Attachments
  • You must to post comments
1
0

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.

  • Andrew Burnett-Thompson
    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 to post comments
Showing 1 result
Your Answer

Please first to submit.