Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: How to capture resize event? #1199

Open
ShrinivasKattimani opened this issue Jan 23, 2020 · 2 comments
Open

Query: How to capture resize event? #1199

ShrinivasKattimani opened this issue Jan 23, 2020 · 2 comments

Comments

@ShrinivasKattimani
Copy link

Chart.js provides onResize option in the configuration, which gets invoked upon canvas resize. Do we also have a similar event getting emitted in ng2-charts?

@ha100790tag
Copy link

Did you try common event binding?
something like this:

<canvas #chart (resize)="handleResize($event)"></canvas>

@BigPackie
Copy link

BigPackie commented Nov 6, 2020

<canvas #chart (resize)="handleResize($event)"></canvas>

Unfortunately the above traditional event binding does not seem to work. But I have found one solution. in the ChartOptions there is a property onResize where you can bind a callback function. Example:

public lineChartOptions: ChartOptions = {
    responsive: true,
    maintainAspectRatio: false,
    onResize: this.chartResizing,
}


 chartResizing($event: any) {
    console.log('chart resizing:', $event);
}

Official doc: https://www.chartjs.org/docs/latest/general/responsive.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants