Open clear-m opened 7 years ago
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.
maybe can try dragYEnabled or dragXEnabled first. if is the effect u want, then all done. "_outerScrollView?.nsuiIsScrollEnabled = false "change this will have our side effect, so be careful
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 ;)