Load CSV data via Ajax for display in Highcharts
<p>I am having problems loading some external CSV data via Ajax into Highcharts.
It's especially the step of passing the returned values into Highcharts which I don't get...</p>

<p>The first function loads the data:</p>

<pre><code>function requestData() {
    $.ajax({
        type: "GET",
        url: "xxx",
        dataType: "text",
        success: function(data) 
        {
            var series_return = processData(data);

            // like this???
            //chart.addSeries({
            //  name: "NPP",
            //  data: series_return
            //});                       
        }
    });
};          
</code></pre>

<p>The data are being processed here, as the first couple of lines contain only text:</p>

<pre><code>function processData(allText) 
{
    var allTextLines = allText.split(/\r\n|\n/);
    var lines = []; var n = 0; var series_return = [];

    for (var i=1; i&lt;allText.length; i++) 
    {
        if (allTextLines[i])
        {
            if ((allTextLines[i].substring(0,2) == "19") || (allTextLines[i].substring(0,2) == "20"))
            {
                n++;
                series_return[n] = allTextLines[i];
            }
        }                   
    }

    return series_return;
}
</code></pre>

<p></p>

<p>The data look like this then:</p>

<pre><code>[1: "2015/12/01,15.0,-90.0,0.11532234042553188", 2: "2015/11/01,15.0,-90.0,0.10756382978723407"]
</code></pre>

<p>The Highcharts script:</p>

<pre><code>// ---------------------------------------------------
// ---------------      Highcharts     ---------------
// ---------------------------------------------------

$(document).ready(function() 
{
    chart = new Highcharts.Chart(
    {
        chart: 
        {
            renderTo: 'div_graph',
            defaultSeriesType: 'spline',
            marginLeft: 120,
            marginTop: 100,
            events: {
                load: requestData
            }
        },
        xAxis: 
        {
            gridLineWidth: 1,
            gridLineDashStyle: 'Dot',
            tickWidth: 0,
            type: 'datetime'
        },
        yAxis: 
        {
            gridLineWidth: 1,
            gridLineDashStyle: 'Dot'
        },
        plotOptions: 
        {
            series: 
            {
                connectNulls: false,
                shadow: false,
                lineWidth: 2,
                color: '#3f9aff',
                marker: 
                {
                    enabled: false
                }
            }
        },  
        series: [{
            name: 'NPP',
            data: []
        }]
    });
});     
</code></pre>

<p>So, what is the correct way of passing the data over to Highcharts? I looked quite around, and tested things here and there, but in vain.</p>

<p>Thanks for any hints!</p>