[Chartjs]-How to add panning to chart in chartjs?

11👍

ꜰɪʀꜱᴛ

add hammer.js to your project :

<script src="http://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>

ꜱᴇᴄᴏɴᴅ

enable pan option for your chart, like so :

options: {
   pan: {
      enabled: true,
      mode: 'x',
   },
   ...
}

see demo on jsFiddle

0👍

Maybe you can use this plugin. See the example.

Basically you need to import and initialize it. By default, if you hold shift and drag the chart, it will pan, but you can also set a custom input trigger.

Leave a comment