Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroyChart() on Map/Scatter seems to be incomplete #214

Open
theweaklink opened this issue May 18, 2018 · 0 comments
Open

destroyChart() on Map/Scatter seems to be incomplete #214

theweaklink opened this issue May 18, 2018 · 0 comments

Comments

@theweaklink
Copy link

  • Operating System and version: Ubuntu 16.04
  • Browser and version: Firefox 60.0.1
  • Steps to reproduce:
  1. Create a Map or Scatter, e.g. one of the pointMapChart + pointLayer in the examples
  2. Destroy the chart with pointMapChart.destroyChart()
  3. Re-create a brand new chart => Error related to chartBody being undefined, the new chart still displays properly
  • Description of issue:
    It looks like destroying the chart does not clean up the chart registry and therefore the old chart is still attempted to be rendered (and fails because it was previoulsy destroyed). After some digging, it looks like a simple call to deregisterChart() in the destroyChart() method solves the problem:
  _chart.destroyChart = function() {
    deregisterChart(_chart, _chart.chartGroup())
    ...  

Also, I found out that if we switch between a Scatter and a Map (i-e: destroy the scatter, create a new map in the same <div> container), the X and Y axis of the scatter are now shown on the maps. Since the axis are elements in the container, adding the following to the destroyChart() seems to make things right:

  _chart.destroyChart = function() {
    deregisterChart(_chart, _chart.chartGroup())
    _chart
      .root()
      .attr("style", "")
      .attr("class", "")
      .html("")
    ...

I am not enough familiar with the chart rendering elements and lifecycle to know if this is actually a correct fix and whether it is the only calls to make. I hope it helps though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant