title: Javscript Plotly error: 'calling plotly as if redrawing but this container doesn't have a plot yet"
body: <p>I am trying to plot a different pie chart based on user selection on a dropdown list.  The console.log is outputting the correct info, but the plotting area throws an error: "Calling Plotly.plot as if redrawing but this container doesn't yet have a plot."  Below is my code (sorry it's a bit long), but I'll try to summarize the issue I face. </p>
  
  <pre><code>function nameChanged(){
      var selected_month = d3.select('#selMonth').property('value');
      var selected_researcher = d3.select('#selName').property('value');     
      var proj_name = []
      var proj_hrs = []
      d3.json('mar_byweek.json').then((data)=&gt;{ 
  
      if ((selected_month ==="march")&amp;&amp; (selected_researcher ==='amber')
          //some other code here to do something, which works //
          d3.json('marAmber_byprod.json').then((data) =&gt;{
              proj_name = data.map(row =&gt; row.Product);
              proj_hrs = data.map(row =&gt;row.Total);
              console.log(proj_name, proj_hrs)
          })};
  
      if ((selected_month ==="march")&amp;&amp; (selected_researcher ==='gwen')) {
          //some other code here to do something, which works//
  
          d3.json('marGwen_byprod.json').then((data) =&gt;{
              proj_name = data.map(row =&gt; row.Product);
              proj_hrs = data.map(row =&gt;row.Total);
              console.log(proj_name, proj_hrs)
          })};
  
          var trace_project = {
              labels: [proj_name],
              values: [proj_hrs],
              type: "pie",
          }
          Plotly.newPlot('month_pie', trace_project)
      }) 
  </code></pre>
  
  <p>For EACH "if" condition, the console.log is showing the correct "proj_name" and "proj_hrs" arrays.  But in plotting, the error shows "Calling Plotly.plot as if redrawing but this container doesn't yet have a plot." </p>
  
  <p>Please help! Deeply appreciated!!! </p>