title: Using HighCharts and DotNet.HighCharts to "Play" Multiple Series
body: <p>I have a set of series that I have created using VB.NET and DotNet.HighCharts:</p>
  
  <pre><code>Dim SeriesList4As New List(Of Series)(stfipsList4.Count)
  </code></pre>
  
  <p>What I want to have happen is something similar to <a href="http://jsfiddle.net/8M2fF/">http://jsfiddle.net/8M2fF/</a> except I want to be able to pass in multiple series without knowing before hand how many I have.</p>
  
  <p>The VB code that created that example above is this:</p>
  
  <pre><code>        Dim stfipsList4 = (From r In dt4.AsEnumerable() Select r("areaname")).Distinct().ToList()
          Dim SeriesList4 As New List(Of Series)(stfipsList4.Count)
          Dim seriesItem4(stfipsList4.Count) As Series
          Dim xDate4 As DateTime
          Dim fakeDate4 As String
          Dim sX4 As Integer
  
          sX4 = 1
          For Each state In stfipsList4
              Dim data As New Dictionary(Of DateTime, Decimal)
              Dim stateVal As String = state.ToString
              Dim recCount As Integer = dt4.Rows.Count - 1
              Dim seriesPointCount As Integer = dt4.Compute("Count(population)", "areaname = '" + stateVal + "'")
              Dim chartData As Object(,) = New Object(seriesPointCount - 1, 1) {}
              Dim x As Integer = 0
              For i As Integer = 0 To recCount
                  If dt4.Rows(i)("areaname").ToString = stateVal Then
                      fakeDate4 = "1/1/" + dt4.Rows(i)("periodyear").ToString
                      xDate4 = DateTime.Parse(fakeDate4)
                      chartData.SetValue(xDate4.Date, x, 0)
                      chartData.SetValue(dt4.Rows(i)("population"), x, 1)
                      x += 1
                  End If
  
              Next
  
              seriesItem4(sX4) = New Series With {
                          .Name = state.ToString, _
                          .Data = New Helpers.Data(chartData)
              }
  
              SeriesList4.Add(seriesItem4(sX4))
  
              sX4 = sX4 + 1
          Next
  
          Dim iterateData As String = JsonSerializer.Serialize(seriesItem4(1))
  
              Dim chart4 As Highcharts = New Highcharts("chart4").SetOptions(New Helpers.GlobalOptions() With { _
                  .[Global] = New [Global]() With { _
                          .UseUTC = False _
                      } _
                  }).InitChart(New Chart() With { _
                   .DefaultSeriesType = ChartTypes.Column, _
                   .MarginRight = 10, _
                   .Events = New ChartEvents() With { _
                    .Load = "ChartEventsLoad" _
                   } _
                  }).SetTitle(New Title() With { _
                   .Text = "Population" _
                  }).SetTooltip(New Tooltip() With { _
                      .Formatter = "function() { return '&lt;b&gt;' + this.series.name + '&lt;br/&gt;' + Highcharts.dateFormat('%Y', this.x) +'&lt;/b&gt;: '+ Highcharts.numberFormat(this.y, 0, ','); }" _
                  }).SetXAxis(New XAxis() With { _
                   .Type = AxisTypes.Datetime, _
                   .TickPixelInterval = 150 _
                  }).SetYAxis(New YAxis() With { _
                         .Min = 0, _
                         .Title = New YAxisTitle() With { _
                          .Text = "Population", _
                          .Align = AxisTitleAligns.High _
                          } _
                  }).SetSeries(New Series() With { _
                       .Data = New Helpers.Data(New Object() {}) _
                  }) _
                  .SetOptions(New Helpers.GlobalOptions() With { _
                  .Colors = palette_colors _
                  }) _
                  .AddJavascripVariable("iterated", iterateData.ToString) _
                  .AddJavascripFunction("ChartEventsLoad", "// set up the updating of the chart each second" &amp; vbCr &amp; vbLf &amp; _
                                    " var result = iterated.data;" &amp; vbCr &amp; vbLf &amp; _
                                    " var counter = 0;" &amp; vbCr &amp; vbLf &amp; _
                                    " var series = this.series[0];" &amp; vbCr &amp; vbLf &amp; _
                                    " var loopseries = function() {" &amp; vbCr &amp; vbLf &amp; _
                                    " if (counter &lt;= result.length) {" &amp; vbCr &amp; vbLf &amp; _
                                    " var p = String(result[counter]);" &amp; vbCr &amp; vbLf &amp; _
                                    " var splitp = p.split("","");" &amp; vbCr &amp; vbLf &amp; _
                                    " var x = Number(splitp[0]);" &amp; vbCr &amp; vbLf &amp; _
                                    " var y = Number(splitp[1]);" &amp; vbCr &amp; vbLf &amp; _
                                    " series.addPoint([x, y], true, series.points.length &gt; 10, true);" &amp; vbCr &amp; vbLf &amp; _
                                    " counter++;" &amp; vbCr &amp; vbLf &amp; _
                                    " } else {" &amp; vbCr &amp; vbLf &amp; _
                                    " clearInterval(loopseries);" &amp; vbCr &amp; vbLf &amp; _
                                    " }};" &amp; vbCr &amp; vbLf &amp; _
                                    " setInterval(loopseries, 300);")
  
          ltrChart4.Text = chart4.ToHtmlString()
  </code></pre>
  
  <p>This is just for a single series. I would like to pass in a List(Of Series).
  Things that need to be involved:
  Creating n number of series
  Adding points to each series
  Naming each series</p>
  
  <p>I can handle those items it is just passing in the master series "list" that I cannot accomplish.</p>
  
  <p>EDIT:
  There seems to be some confusion on what I am asking. I am able to pass N number of series to HighCharts via the DotNet.HighCharts API. What I am not currently able to do is pass this same set of series to the javascript function to loop through and "play" the series. Please see:</p>
  
  <pre><code>            .AddJavascripVariable("iterated", iterateData.ToString) _
              .AddJavascripFunction("ChartEventsLoad", "// set up the updating of the chart each second" &amp; vbCr &amp; vbLf &amp; _
                                " var result = iterated.data;" &amp; vbCr &amp; vbLf &amp; _
                                " var counter = 0;" &amp; vbCr &amp; vbLf &amp; _
                                " var series = this.series[0];" &amp; vbCr &amp; vbLf &amp; _
                                " var loopseries = function() {" &amp; vbCr &amp; vbLf &amp; _
                                " if (counter &lt;= result.length) {" &amp; vbCr &amp; vbLf &amp; _
                                " var p = String(result[counter]);" &amp; vbCr &amp; vbLf &amp; _
                                " var splitp = p.split("","");" &amp; vbCr &amp; vbLf &amp; _
                                " var x = Number(splitp[0]);" &amp; vbCr &amp; vbLf &amp; _
                                " var y = Number(splitp[1]);" &amp; vbCr &amp; vbLf &amp; _
                                " series.addPoint([x, y], true, series.points.length &gt; 10, true);" &amp; vbCr &amp; vbLf &amp; _
                                " counter++;" &amp; vbCr &amp; vbLf &amp; _
                                " } else {" &amp; vbCr &amp; vbLf &amp; _
                                " clearInterval(loopseries);" &amp; vbCr &amp; vbLf &amp; _
                                " }};" &amp; vbCr &amp; vbLf &amp; _
                                " setInterval(loopseries, 300);")
  </code></pre>
  
  <p>The .AddJavaScriptVariable expects a string and in-lining the code is giving me invalid object references.</p>