question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable/Disable Zoom

See original GitHub issue

Hi,

I saw that you removed EventCapture https://github.com/rrag/react-stockcharts/blob/78bbf30e4e29580aceedbc0e6fe0c8829b95b88b/docs/md/CHANGE-LOG.md

Is there any way now to enable/disable the zoom on demand? The problem being when you scroll down a page and happen to be on top of a chart then it starts zooming instead of scrolling. We want to have a button to enable chart interaction instead of having it by default.

Thanks, we ❤️ your lib 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rragcommented, Nov 4, 2016

Great here is what I am thinking

in ChartCanvas.jsx

class ChartCanvas extends Component {
    ...
    ...
    render() {
        ...
        ...
        <EventCapture
-           mouseMove={interaction}
+           mouseMove={!disableMouseMoveEvent && interaction}
-           zoom={interaction}
+           zoom={!disableMouseMoveEvent && interaction}
-           pan={interaction && !drawMode}
+           pan={!disableMouseMoveEvent && interaction && !drawMode}

            width={dimensions.width}
            height={dimensions.height}
            chartConfig={chartConfig}
            xScale={xScale}
        ...
    }
}

ChartCanvas.propTypes = {
    width: PropTypes.number.isRequired,
    height: PropTypes.number.isRequired,
    ...
    ...
+   disableMouseMoveEvent: PropTypes.bool.isRequired,
+   disablePanEvent: PropTypes.bool.isRequired,
+   disableZoomEvent: PropTypes.bool.isRequired,
    onSelect: PropTypes.func,
};

ChartCanvas.defaultProps = {
    ...
    defaultFocus: true,
    onLoadMore: noop,
    onSelect: noop,
    // ratio: 2,
+   disableMouseMoveEvent: false,
+   disablePanEvent: false,
+   disableZoomEvent: false,
};

and then when you use it in your component


handleSelect() {
    this.setState({ focus: true })
}

render() {
    ...
    var focus = this.state.focus;
    ...
    return (<ChartCanvas
        disableMouseMoveEvent={focus}
        disablePanEvent={focus}
        onSelect={this.handleSelect}
        ...
        ...>
        ...
        ...
    </ChartCanvas>

Refer CONTRIBUTING.md on how you can test your changes

Change any of the charts in https://github.com/rrag/react-stockcharts/tree/master/docs/lib/charts to test your changes.

I always use

https://github.com/rrag/react-stockcharts/blob/master/docs/lib/charts/CandleStickChartWithEdge.jsx

to play with my experiments before it becomes an example on its own

0reactions
johnreytanquincocommented, Oct 17, 2018

Okay, I think this is the solution im looking for. https://github.com/rrag/react-stockcharts/pull/164#issuecomment-259113522

look at zoomEnabled prop in XAxis, YAxis in CandleStickChartWithZoomPan.jsx

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling or disabling participants video - Zoom Support
In the Schedule Meeting section, to enable Participants video, click the toggle. Note: If Participant video is disabled and locked, contact your ...
Read more >
How to Disable Zoom on a Mobile Web Page With HTML and ...
To disable the zooming option, you can use the Surefox browser, but still, the page will zoom in and out by double-tapping on...
Read more >
Apple Watch 7: How to Enable/Disable Zoom to Zoom In or Out
Learn how you can enable or disable zoom to zoom in or out on the Apple Watch 7. Gears I use:Velbon Sherpa 200...
Read more >
how to disable Zoom-Out & Zoom… | Apple Developer Forums
Hi developers is there any chanse to disable Zoom-Out & Zoom-In in WkWebView? here's all my code so far keep in mind i'm...
Read more >
Don't disable zoom | Webflow Accessibility Checklist
A meta viewport element tells the browser how to scale and control the page's dimensions, but zoom can be disabled as a result...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found