Plotly data from nested for loop
<p>In c# codebehind I define a few Lists this way:</p>

<pre><code>public List&lt;string&gt; divs = new List&lt;string&gt;();
public List&lt;List&lt;string&gt;&gt; names = new List&lt;List&lt;string&gt;&gt;();
public List&lt;List&lt;List&lt;string&gt;&gt;&gt; labels = new List&lt;List&lt;List&lt;string&gt;&gt;&gt;();
public List&lt;List&lt;List&lt;double&gt;&gt;&gt; longitude = new List&lt;List&lt;List&lt;double&gt;&gt;&gt;();
</code></pre>

<p>Quite large lists I know but I feel it's necessary for getting all my info from my source organized correctly.</p>

<p>in JS I serialize these like this:</p>

<pre><code>var divArr = &lt;%=new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(divs)%&gt;;
var names = &lt;%=new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(names)%&gt;;
var lbl = &lt;%=new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(labels)%&gt;;
var long = &lt;%=new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(longitude)%&gt;;
</code></pre>

<p>And then I try to do a function to plot all this on separate graphs. 10 graphs in total on my page that can have several lines on all of them. Trying to make my page as dynamic as possible. So I have a function to loop through all of this and try to plot it all.</p>

<pre><code>function doGraph(){
    for(index = 0; index &lt; divArr.length; ++index){
        (function() {

            var data = [];
            for(indx = 0; indx &lt; lbl[index].length; ++indx){
                var trace = {
                    name: names[index][indx],
                    x: lbl[index][indx],
                    y: long[index][indx],
                    mode:'lines'
                };
                data.push(trace);
            }

            var gd = document.getElementById(divArr[index]);
            plotly.newPlot(gd,data);

                })();
            }
}
</code></pre>

<p>And it ALMOST works. Every graph seems to plot the first set of data given to it but nothing afterwords. Maybe I've been staring at this too long but I just can't see what I'm doing wrong here but I'm sure it's something I've just over looked. Or maybe I'm overreaching and I can't do this sort of thing? Any insight is appreciated!</p>