[Chartjs]-Chart.js 3+, Firefox 68 and Angular: "ReferenceError: "ResizeObserver is not defined"

5👍

Looking at how others fixed it, it seems like you still need to register it to the browser before you do anything with chart.js so it can use it:

import {ResizeObserver as ResizeObserverPolyfill} from '@juggle/resize-observer';

if (typeof window !== 'undefined') {
  window.ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
}

Comming from: https://github.com/jenkins-infra/plugin-site/pull/714

2👍

Support for older browsers got dropped a while back, so you need a polyfill to keep chartJS working. if you have really old browser and you can’t import, you can add a script from polyfill.io. It’s pretty heavy, but it will be an easy fix and you can add other polyfills easily if you need.

<script type="application/javascript" src="https://polyfill.io/v3/polyfill.min.js?features=ResizeObserver"></script>

Leave a comment