Home forums Using CanvasJS Useing CanvasJS with mousewheel

This topic contains 4 replies, has 2 voices, and was last updated by  mihaela 1 week ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #23355

    mihaela
    Member

    Do you have any examples or recommendations for using CanvasJS charts (in particular zoom in) from mouse wheel?

    Same question for keyboard keys interaction with the plots.

    Thanks

    #23356

    Vishwas R
    Keymaster

    @mihaela,

    You can achieve this by attaching wheel event to the chart as shown in this JSFiddle.


    Vishwas R
    Team CanvasJS

    #23371

    mihaela
    Member

    Great example, exactly as needed, thanks!

    Is there an example you can provide for attaching keyboard events? We would like to use keyboard keys as shortcuts for certain operations like zoom in/out or pan left right.

    Thanks again for your excellent support.

    #23374

    Vishwas R
    Keymaster

    @mihaela,

    Similar to how wheel event was attached to achieve zooming the chart with mouse-wheel, you need to attach keydown event to achieve on pressing any key in the keyboard. Please take a look at this JSFiddle. Please refer this stackoverflow thread for more information on key-codes.

    Note: As JSFiddle has multiple panels (like HTML, JS, Result, etc), make sure you click somewhere in the result panel and then on top of chart once so that keyboard events are captured by chart.


    Vishwas R
    Team CanvasJS

    #23380

    mihaela
    Member

    Thanks for the example, it is working great.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.