Home › Forums › Report Bugs › Weird Chart Behaviour in IOS Browser on mobile? › Reply To: Weird Chart Behaviour in IOS Browser on mobile?
OK so some further information I found today (I used the safari dev tools panel which includes a canvas tab)
chart.destroy();chart = null
had did not release the earlier canvases memory
[HTMLCanvasElement].height = 0; [HTMLCanvasElement].width = 0; [HTMLCanvasElement].style.width = 0; [HTMLCanvasElement].style.height = 0
before calling destroychart.ctx.canvas, chart.overlayCanvas, chart.legend.ghostCtx.canvas, chart._preRenderCtx.canvas
here is the code i used to clean up before calling chart.destroy;chart = null
const ele = document.getElementById("chartContainer"); const c = chartsInstances[chartId] c.legend.ghostCtx.canvas.style.height = 0; c.legend.ghostCtx.canvas.height = 1; c.legend.ghostCtx.canvas.style.width = 0; c.legend.ghostCtx.canvas.width = 1; c._preRenderCtx.canvas.width = 1; c._preRenderCtx.canvas.height = 1; c._preRenderCtx.canvas.style.width = 0; c._preRenderCtx.canvas.style.height = 0; const canvases = ele.querySelectorAll('canvas'); for (const canvas of canvases) { canvas.width = 1; canvas.height = 1; canvas.style.width = 0; canvas.style.height = 0; }