wuba / react-native-echarts

📈 React Native ECharts Library: An awesome charting library for React Native, built upon Apache ECharts and leveraging react-native-svg and react-native-skia. Offers significantly better performance compared to WebView-based solutions.
https://wuba.github.io/react-native-echarts/
Apache License 2.0
762 stars 25 forks source link

Disable moveOnMouseMove when 1s long press #181

Open simonho1025 opened 5 months ago

simonho1025 commented 5 months ago

I would like to set moveOnMouseMove to false when 1s long press(mousedown), so I tried to use dispatchAction. And when mouseup, moveOnMouseMove set to true. But this method doesn't work. I also try to use setOption, but the chart will reload that not stay the current position. So I want to know how to achieve disable moveOnMouseMove while trigger click event.

let pressTimer = 0;

chartObj.getZr().on('mousedown', (params: any) => {
    console.log('mousedown: ', params);
    pressTimer = setTimeout(() => {
        setMoveOnMouseMove(false);
        chartObj.dispatchAction({
            type: 'dataZoom',
            moveOnMouseMove: false
        });
    }, 1000);
    return false;
});

chartObj.getZr().on('mouseup', () => {
    console.log('mouseup');
    chartObj.dispatchAction({
        type: 'dataZoom',
        moveOnMouseMove: true
    });

    clearTimeout(pressTimer);
});
zhiqingchen commented 5 months ago

for custom event handle

https://wuba.github.io/react-native-echarts/docs/advanced-guides/use-rngh

simonho1025 commented 5 months ago

for custom event handle

https://wuba.github.io/react-native-echarts/docs/advanced-guides/use-rngh

but may I know how to change moveOnMouseMove value after long press?