Ng2-charts: Can ng2-charts work with Chart.js zoom plugin?

Created on 8 Jun 2017  路  10Comments  路  Source: valor-software/ng2-charts

I am trying to add zoom functionality to my chart using the chartjs-plugin-zoom project but I haven't been able to get it working yet.

I added the chartjs-plugin-zoom to my project. I have the zoom property added to my chart config as well.

Most helpful comment

@hambecker I'm using ng2-charts. Check out working graph in one of my my projects: math-diet

app.module.ts - module where I import the libs
diet-viewer.ts - component where I init the chart
diet-viewer.html - template where the graph is displayed

All 10 comments

@mac10046: in addition install hammerjs

npm install hammerjs --save

and add to your module:

import 'hammerjs';
import 'chartjs-plugin-zoom';

Is zoom now just a part of chart options after doing what rbaumi just did? Like how do you actually tell your graph to turn its zoomable property on? Because I have inserted that code and there is still no zoom functionality.

For me the plugin works ok with ionic 3.4.0 and angular 4.2 (maybe not completly ok but identical as in the available samples on the plugin repository).

@hambecker did you enabled zoom / pan in graph settings? Take a look at the graph settings from one of the available samples: https://github.com/chartjs/chartjs-plugin-zoom/blob/master/samples/zoom.html

@rbaumi I don't quite understand, so are you using ng2-charts at all in this example? or are you using strictly chartjs and hammerjs?

@hambecker I'm using ng2-charts. Check out working graph in one of my my projects: math-diet

app.module.ts - module where I import the libs
diet-viewer.ts - component where I init the chart
diet-viewer.html - template where the graph is displayed

Thanx rbaumi - it worked like a charm.

Hello,
sorry if I comment here, but I have the same problem. I think that I import the right things but I'm not able to pan or zoom in to the charts. I upload all my code here. Can you help me? I will leave the code on link, so who will need in the future, will have an example.
thanks

@nicscap did you figure it out?

Hello,
In this sample
[https://stackblitz.com/edit/ng2-charts-select-interval-multitouch]
posted by nicscap.
If you change file path app.module.ts
import { ChartsModule } from 'ng2-charts';
to
import { ChartsModule } from 'ng2-charts/ng2-charts';
it麓s works very well.
thanks!!!

Hello, I have some issues building an Ionic 3 app with AOT compiling (--prod flag) and this plugin.
The build fails with errors "Cannot write file [...] because it would overwrite input file" on many .js files.
Can someone give me a hint?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Adwind picture Adwind  路  3Comments

shyamal890 picture shyamal890  路  4Comments

dslima90 picture dslima90  路  3Comments

brandonreid picture brandonreid  路  3Comments

vmironovs picture vmironovs  路  3Comments