        ensureChart();
      }
      if (e.target.id === 'canvasBg') {
        state.canvasBg = e.target.value;
        document.querySelector('canvas').style.background = state.canvasBg;
        ensureChart();
      }
      if (e.target.id === 'textColor') {
        state.textColor = e.target.value;
        ensureChart();
      }
    });

    $('#btnRegen').addEventListener('click', () => ensureChart());
    $('#btnSave').addEventListener('click', () => {
      if (!chart) return;
      const link = docume