Victory: Can't scroll page on touch device

Created on 2 Jul 2018  Â·  11Comments  Â·  Source: FormidableLabs/victory

Bugs and Questions

Checklist

  • [x] This is not a victory-native specific issue. (Issues that only appear in victory-native should be opened here)

  • [x] I have read through the FAQ and Guides before asking a question

  • [x] I am using the latest version of Victory

  • [x] I've searched open issues to make sure I'm not opening a duplicate issue

The Problem

On a touch device it is not possible to scroll the page if you touch a victory element

Reproduction

The gallery is a good example :
https://formidable.com/open-source/victory/gallery/
Just try to scroll the page on a smartphone

Most helpful comment

this is still issue, atleast on android. I just test and implemented on IOS using simulator. i can't click using mouse and scroll but on Android real device, i can't scroll when i click on victory-bar component

UPDATE: i just did <View pointerEvents="none"> around the victory component. all good 😄

All 11 comments

@jadus I'm not able to reproduce this issue. Some elements in the gallery do have scroll events enabled (like the brush and zoom example), and these will capture the scroll event rather than scrolling the page. I haven't seen this behavior happen with other chart elements, though.

I've added around my chart and standalone={false} width={400} height={400} in my component and it solves my problem, thanks.

I have faced the same issue. My solution for it is wrap the chart component with Svg. It will make your cart as svg, but it will reduce preformance of antimation process.

import Svg from 'react-native-svg';

<Svg width='100%' height={222}>
    <VictoryChart
        standalone={false}>
            <VictoryBar />
    </VictoryChart>
</Svg>

this is still issue, atleast on android. I just test and implemented on IOS using simulator. i can't click using mouse and scroll but on Android real device, i can't scroll when i click on victory-bar component

UPDATE: i just did <View pointerEvents="none"> around the victory component. all good 😄

this is still issue, atleast on android. I just test and implemented on IOS using simulator. i can't click using mouse and scroll but on Android real device, i can't scroll when i click on victory-bar component

UPDATE: i just did <View pointerEvents="none"> around the victory component. all good 😄

After 3 hours, you have saved me! Thank you

this is still issue, atleast on android. I just test and implemented on IOS using simulator. i can't click using mouse and scroll but on Android real device, i can't scroll when i click on victory-bar component

UPDATE: i just did <View pointerEvents="none"> around the victory component. all good 😄

After many hours, you saved my charts :> Thank you

Where does this components come from?

Attempted import error: 'View' is not exported from 'victory'.

Ok, seems to be something related to react-native. But the issue affects normal React on Safari browser, without using react-native.

Ok, for future readers who are not using react-native, the solution is similar to what @sinoridha described but with native svg wrapper:

<svg width='100%' height='50%'>
    <VictoryChart standalone={false} />
</svg>

This however makes your chart not responsible anymore.

👋 Hi all,

In case people are looking at this issue for reference, the reason this happens is because <VictoryContainer /> (which renders the <div> containing the chart) has a style prop of
{ pointerEvents: 'none', touchAction: 'none' }. This is there for the reason @boygirl mentioned above.

If you don't want this behavior, your can override it by providing your own containerComponent

<VictoryChart
  containerComponent={
    <VictoryContainer
      style={{
        pointerEvents: "auto",
        userSelect: "auto",
        touchAction: "auto"
      }}
    />
  }
>
  <VictoryLine />
</VictoryChart>

The comment above led me in the right direction for my use case. The requirements for my mobile web app:
• users should be able to scroll if they touch the chart
• users should be able to touch the chart and interact with VictoryVoronoiContainer

Omitting the style overrides, except for touch-action, did the trick.

<VictoryChart
  containerComponent={
    <VictoryVoronoiContainer
      style={{
        touchAction: "auto"
      }}
    />
  }
>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tylermassey picture tylermassey  Â·  5Comments

robinwkurtz picture robinwkurtz  Â·  3Comments

jotak picture jotak  Â·  4Comments

purplecones picture purplecones  Â·  3Comments

seddonm1 picture seddonm1  Â·  5Comments