C3: How to access current zoom and how to set zoom?

Created on 9 Oct 2014  路  2Comments  路  Source: c3js/c3

I have to listen to some kind of zoom events to get the current scale of the zoom. Also it would be helpful to have a function to set the zoom. Is there any (internal) function already?

I would like to have something like:

chart.zoom.onzoom = function(x1, x2) {};
chart.zoom.setzoom(x1, x2);
C-feature-request resolved maybe

Most helpful comment

Hi, onzoom callback is already implemented in the latest code. You can set this callback when init like this:

...
zoom: {
  enabled: true,
  onzoom: function (domain) {
    // do something with domain, which is the domain after zoomed
  }
},
...

And I implemented zoom API, so now it's possible to zoom programmatically like:

chart.zoom([4, 10]); // then, the chart will be zoomed to the range from 4 to 10

Could you try these? Thanks.

All 2 comments

Hi, onzoom callback is already implemented in the latest code. You can set this callback when init like this:

...
zoom: {
  enabled: true,
  onzoom: function (domain) {
    // do something with domain, which is the domain after zoomed
  }
},
...

And I implemented zoom API, so now it's possible to zoom programmatically like:

chart.zoom([4, 10]); // then, the chart will be zoomed to the range from 4 to 10

Could you try these? Thanks.

Wonderful! That is exactly what I was looking for.

~ Thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kethomassen picture kethomassen  路  3Comments

Zerim picture Zerim  路  3Comments

jstone-ponderosa picture jstone-ponderosa  路  3Comments

Kreozot picture Kreozot  路  3Comments

udhaya2kmrv picture udhaya2kmrv  路  3Comments