title: Adding a series dynamically with HighCharts Stock Charts
body: <p>I have the following code: <a href="http://jsfiddle.net/maniator/vTjW8/" rel="nofollow noreferrer">http://jsfiddle.net/maniator/vTjW8/</a></p>
  <pre><code>var createChartTemplate = function() {
      return {
          chart: new Highcharts.StockChart({
  
              chart: {
                  renderTo: 'container'
              },
              series: []
          }),
          addSeries: function(name) {
              this.chart.addSeries({
                  name: name,
                  data: [],
                  id: Math.floor(Math.random()*1000)
              });
          },
          addPoint: function(data, series) {
              var seriesIndex = this.seriesExists(series);
              if (!(seriesIndex === false)) {
                  this.chart.series[seriesIndex].addPoint(data, false);
              }
              this.chart.redraw();
          },
          seriesExists: function(series) {
              var seriesIndex = false;
              $.each(this.chart.series, function(index, item) {
                  if ($.trim(item.name) == $.trim(series)) {
                      seriesIndex = index;
                      return false;
                  }
              });
              return seriesIndex;
          }
      }
  }
  $(function() {
      var data = usdeur.splice(0, 700);
      var chart = createChartTemplate();
      chart.addSeries(&quot;New Series&quot;);
      for (var i = 0; i &lt; data.length; i++) {
          chart.addPoint(data[i], &quot;New Series&quot;);
      }
  
  });
  </code></pre>
  <p>It has the following error in the console:</p>
  <blockquote>
  <p>Uncaught TypeError: Cannot read property 'options' of undefined</p>
  </blockquote>
  <p>This code works fine if it is a normal highchart, but for some reason it does not work with a HighStock chart.</p>
  <p>How can I make it so that it works with the chart type that I need?</p>
  <hr />
  <h3>Update:</h3>
  <p>I figures out a sort of way around getting the 1st series dynamically, but then when I try to add a second series it has an error of:</p>
  <blockquote>
  <p>Uncaught TypeError: Cannot read property 'stacks' of undefined</p>
  </blockquote>
  <p>Fiddle: <a href="http://jsfiddle.net/maniator/V5WAJ/" rel="nofollow noreferrer">http://jsfiddle.net/maniator/V5WAJ/</a></p>