0

Software used:

  • Elixir v1.10.2
  • Phoenix 1.5.0-rc0
  • LiveView 0.12.1
  • macOS Cataline 10.15.4
  • Tried on Safari and Firefox

I have a LiveView set up nicely with a chart (from Highcharts) showing some data. The chart is enclosed in a div with the phx-update="ignore" attribute which works great. However, moving away from the current LiveView and coming back to it makes the chart disappear.

When I first visit the LiveView page:

enter image description here

After navigating away then coming back with <%= live_patch "Dashboard, ... %> or <%= live_redirect "Dashboard", ... %>:

enter image description here

dashboard_live.html.leex:

<div phx-update="ignore" id="custom-chart">
    <figure id="main-chart" class="highcharts-figure">
        <div class="chart-container" id="<%= @chart_id %>"></div>
    </figure>
    <script id="main-chart-data">
        ....
    </script>
</div>

The chart displays normally after I refresh the page.

Abdullah Esmail
  • 216
  • 2
  • 6

1 Answers1

1

The initialization of the chart must be done through LiveView hooks.

The answer was given in elixirforums by LostKobrakai

Abdullah Esmail
  • 216
  • 2
  • 6