Since version 6, you can now use the function chart.setTheme(isDarkMode ? 'dark' : 'default');.
chart.setTheme(isDarkMode ? 'dark' : 'default');