Ng2-charts: can't resetZoom()

Created on 19 Aug 2020  路  1Comment  路  Source: valor-software/ng2-charts

i can't access to te resetZoom() of the plugin charjs-zoom-plugin, any idea how can i resetZoom to the normal?

Most helpful comment

Hi @biocrista96

First you have to obtain a reference to the original chart object, then you can call resetZoom on it.

To do this:

In your template

 <canvas
    baseChart
    #myChart="base-chart"
...

In your component:

  @ViewChild("myChart")
  myChart: BaseChartDirective;

  onButtonClick() { 
    this.myChart.chart.resetZoom();
  }

Here is a working example: https://stackblitz.com/edit/angular-ivy-q8jcls?file=src%2Fapp%2Fapp.component.ts

>All comments

Hi @biocrista96

First you have to obtain a reference to the original chart object, then you can call resetZoom on it.

To do this:

In your template

 <canvas
    baseChart
    #myChart="base-chart"
...

In your component:

  @ViewChild("myChart")
  myChart: BaseChartDirective;

  onButtonClick() { 
    this.myChart.chart.resetZoom();
  }

Here is a working example: https://stackblitz.com/edit/angular-ivy-q8jcls?file=src%2Fapp%2Fapp.component.ts

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tssobe picture tssobe  路  4Comments

Adwind picture Adwind  路  3Comments

mrpotato3 picture mrpotato3  路  5Comments

hggeorgiev picture hggeorgiev  路  4Comments

shenriksen4 picture shenriksen4  路  3Comments