Highchart: how to update a dynamic chart by clicking on a button?
<p>I intend to have a button on my web page so that upon clicking a button, a point will be added to a chart <strong>without redrawing the whole chart</strong> (the chart is a modified version of this <a href="http://www.highcharts.com/demo/dynamic-update" rel="nofollow">http://www.highcharts.com/demo/dynamic-update</a>). However, my current code is not working.</p>

<p>Here is the code in concern: <a href="http://jsfiddle.net/wtvaz9gc/7/" rel="nofollow">http://jsfiddle.net/wtvaz9gc/7/</a></p>

<pre><code>var series;

$(function drawCharts(numberOfPoint) {
                    // if(typeof chartData == undefined){
                    //  chartData = $(dataStore.getXml());
                    // }

                    $("#b").click(function(){
            series.addPoint([3,3]);
                })
                    $(document).ready(function () {
                        Highcharts.setOptions({
                            global: {
                                useUTC: false
                            }
                        });

                        $('#container').highcharts({
                            chart: {
                                type: 'line',
                                animation: Highcharts.svg, // don't animate in old IE
                                marginRight: 10,
                                events: {
                                    load: function () {
                                        series = this.series[0];
                                        // window.myGlobal1 = this.series[0].data[this.series[0].data.length - 1].y;
                                        // console.log(window.myGlobal1 + " " + this.series[0].data[this.series[0].data.length - 1].y);
                                    },
                                }
                            },
                            title: {
                                text: '' 
                            },
                            xAxis: {
                                title: {
                                   text: 'Jahre'
                                },
                            //    gridLineWidth: 0,
                             //   lineWidth:1,
                                startOnTick: true,
                                tickPixelInterval: 40,
                                min: 0,
                                max: 10,
                                plotLines: [{
                                    value: 0,
                                    width: 1,
                                    color: '#808080'
                                }]
                            },

                            yAxis: {
                                title: {
                                    text: 'Vermögen(in EUR)'
                                },
                                labels: {
                                    enabled: true
                                },
                                min: 0,
                                max: 100,
                                plotLines: [{
                                    value: 0,
                                    width: 1,
                                    color: '#808080'
                                }]
                            },
                            tooltip: {
                                enabled : false,
                                formatter: function () {
                                    return '&lt;b&gt;' + this.series.name + '&lt;/b&gt;&lt;br/&gt;' +
                                    Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '&lt;br/&gt;' +
                                    Highcharts.numberFormat(this.y, 2);
                                }
                            },
                            legend: {
                                enabled: false
                            },
                            exporting: {
                                enabled: false
                            },
                            series: [{
                                name: 'Random data',
                                data: ($(function () {
                                // generate an array of random data
                                var data = [],
                                time = (new Date()).getTime(),
                                i, preValue;

                                for (i = 0; i &lt; numberOfPoint; i += 1) {
                                    if(i == 0){
                                        data.push({
                                            x: i,
                                            y: 10
                                        });
                                    } else {
                                        data.push({
                                            x: i,
                                            y: chartData["wealth"][0][i]
                                        });
                                    }
                                }
                                // showMsg(data);
                                // console.log(data);
                                return data;
                            }()))
                            }]
                        });
                    });
                });
</code></pre>

<p>When I tries to run it in chrome, I got the following error report:
highcharts.js:Uncaught TypeError: i.splice is not a function
addPoint    @   highcharts.js:...</p>

<p>How should I use the function "addPoint" in this case?
Or should I use other method to achieve the purpose?</p>