Using chartjs-plugin-zoom with angular ng2-charts #638
Replies: 6 comments
-
@alfabetagama do you have a reproducable sample for this because it seems to work fine, although there is no version https://codesandbox.io/s/ng2charts-chart-js-issue-template-forked-ggoq7 |
Beta Was this translation helpful? Give feedback.
-
It is really not an issue. I think it is an ng2-charts problem, seems like zoom plugin is initialized without default options. I posted this if someone has the same issue. |
Beta Was this translation helpful? Give feedback.
-
No ng2-charts doesnt need to initialise anything, the defaults are being defined here in the plugin itself: https://github.com/chartjs/chartjs-plugin-zoom/blob/master/src/plugin.js#L14-L36 so the line you linked with the speed will use a default of 0.1 if nothing has been provided by the user. But as you can see in my sandbox it also works fine barebone with ng2charts so the issue lies somewhere with you so without a reproducable sample there is no way we can help you |
Beta Was this translation helpful? Give feedback.
-
The defaults are applied when the plugin is registered. I'm guessing that part is missing. |
Beta Was this translation helpful? Give feedback.
-
I'm also having this problem with svelte-chartjs. There's not a global registration step, so that could be the problem. |
Beta Was this translation helpful? Give feedback.
-
I've had a similar issue with Setting these properties manually did fix the immediate issue but I suppose the proper fix is to import the various components and register the plugin. |
Beta Was this translation helpful? Give feedback.
-
When using zoom plugin with angular ng2 charts, you have to explicitly set wheel.speed and pan.threshold for pan and wheel zoom to work. If those are not set in plugin options those functions won't work.
ng2-charts 3.0.8
chart.js 3.0.3
This works:
Beta Was this translation helpful? Give feedback.
All reactions