Ionic + Modal + chart.js canvas refresh issue


#1

Hi,

Using angular-chart.js - we displaying line and doughnut charts on iPad app.

Whenever a modal popup is shown then the charts are disappearing.

Any idea why the modal will cause the charts to disappear in the canvas? Any pointer or solution?


#2

using window.dispatchEvent(new Event(‘resize’));
The refresh issue is fixed.


#3

Hi,
I’m having a similar problem where a modal popup is shown the charts disappear.

Could you elaborate as to what you meant by
"using window.dispatchEvent(new Event(‘resize’)); "

I’m new to this and curious as to where that should be placed.

Thanks.


#4

Hi,
You can call this on hide of your modal with some delay.

function hide() {
    $timeout(function() { /** redraw the canvas  **/
         window.dispatchEvent(new Event('resize'));
    }, 100);
}

#5

That worked perfectly!
Thanks!