Charts 3.0: add support for disabling/enabling the parent scroll view scrolling

Created on 7 Dec 2016  路  4Comments  路  Source: danielgindi/Charts

Please add support for disabling/enabling the parent scroll view scrolling by demand via BarLineChartViewBase property or method.
In my case chartView vertical scrolling is disabled by default but I wish not to prevent the parent scroll view from scrolling.
it's not desirable to prevent parent view from scrolling and I want it to scroll vertically and I think that it would be more convenient to be able to configure such kind of behavior via some property or method.
Thank you again for an awesome chart lib ;)

enhancement

Most helpful comment

I have added this in my own code to override what's in Charts:

extension UIScrollView
{
    var nsuiIsScrollEnabled: Bool
        {
        get { return isScrollEnabled }
        set { 
   //isScrollEnabled = newValue 
        }
    }
}

and seems to do the trick. Hope this helps.

All 4 comments

Can you take a look if self.isDragEnabled
and

                // Check to see if user dragged at all and if so, can the chart be dragged by the given amount
                if didUserDrag && !performPanChange(translation: translation)
                {
                    if _outerScrollView !== nil
                    {
                        // We can stop dragging right now, and let the scroll view take control
                        _outerScrollView = nil
                        _isDragging = false
                    }
                }
                else
                {
                    if _outerScrollView !== nil
                    {
                        // Prevent the parent scroll view from scrolling
                        _outerScrollView?.nsuiIsScrollEnabled = false
                    }
                }

Thank you liuxuan30 for an answer!
I my case the chartView setup looks like this:
self.chartView.scaleXEnabled = true
self.chartView.scaleYEnabled = false
self.chartView.dragEnabled = true

So, when I drag vertically this path executes:
if _outerScrollView !== nil
{
// Prevent the parent scroll view from scrolling
_outerScrollView?.nsuiIsScrollEnabled = false
}
I mean that I wish to drag chart horizontally and not vertically, but I need vertical drag propagation to parent scrollview and _outerScrollView?.nsuiIsScrollEnabled = false just not let any opportunity. So, I think this is point for discussion and improvements

well, I am not very familiar with this part, I just remember somebody asked to disable the outer scrolLView to disable scrolling. In terms of scrolling direction, adding more fine-grained direction control sounds good (also complicated?)

At least it's a private function so you can provide your own implementation for now, and you are welcome to file a PR :)

I have added this in my own code to override what's in Charts:

extension UIScrollView
{
    var nsuiIsScrollEnabled: Bool
        {
        get { return isScrollEnabled }
        set { 
   //isScrollEnabled = newValue 
        }
    }
}

and seems to do the trick. Hope this helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahmedsafadii picture ahmedsafadii  路  3Comments

Bharati555 picture Bharati555  路  4Comments

kirti0525 picture kirti0525  路  3Comments

coop44483 picture coop44483  路  3Comments

JW00332 picture JW00332  路  4Comments