Make ECharts.js full screen

I have been trying to reproduce this Highcharts.js functionality in Echarts.js to make a plot full screen: https://www.highcharts.com/demo/line-basic.

Note that by clicking on the top right button you can select a full screen mode, which can then be disabled by pressing Esc.

I have tried creating a custom button in Echarts.js like this one in Highcharts https://jsfiddle.net/BlackLabel/1ga2fqL0/ without much success:

btn.addEventListener('click', function() {
  Highcharts.FullScreen = function(container) {
    this.init(container.parentNode); // main div of the chart
  };

  Highcharts.FullScreen.prototype = {
    init: function(container) {
      if (container.requestFullscreen) {
        container.requestFullscreen();
      } else if (container.mozRequestFullScreen) {
        container.mozRequestFullScreen();
      } else if (container.webkitRequestFullscreen) {
        container.webkitRequestFullscreen();
      } else if (container.msRequestFullscreen) {
        container.msRequestFullscreen();
      }
    }
  };
  chart.fullscreen = new Highcharts.FullScreen(chart.container);
})

Any ideas?