hansmaad / chartist-plugin-zoom

Zoom Plugin for Chartist.js
Do What The F*ck You Want To Public License
17 stars 15 forks source link

Callback Function not setting #14

Open hambecker opened 7 years ago

hambecker commented 7 years ago

Hi,

I am working with the zoom functionality with chartjs in angular and I've gotten the zoom to work well, however, when trying to set a callback function to zoom back out I am having some trouble. I am writing mine in typescript in a module and this is what I have so far:

`resetFnc =null;

buttonClick() {
console.log('got here'); this.resetFnc && this.resetFnc(); }

onZoom(chart, reset) { this.resetFnc = reset; }

reset() {
  if (this.resetFnc !== null) {
  this.resetFnc();
  this.resetFnc = null;
  document.getElementById('reset').style.display = 'none';
  }
}

private _data = {

PowerOptions: {

  axisX: {
    type: Chartist.AutoScaleAxis,
  },
  axisY: {
    type: Chartist.AutoScaleAxis,
  },

  fullWidth: true,

  color: '#000000',

  chartPadding: {
    right: 5,
    bottom: 0,
  },

  plugins: [
    Chartist.plugins.zoom({ onZoom: this.onZoom }),
 ],

},

};`

My issue is my callback function resetFnc is never getting set unfortunately. I feel like it gets set in my onZoom function, but its not really being set is staying null. Do you guys have any ideas?