Pregunta

Sorry all!! I know there are several (many) post regarding JSON and google api. I read them all and tried fixing the problem for several days. I am going to explode if I have to clear my browsing history, again, to start with a "fresh" mind... I could really use some help. Any and all help would be greatly appreciated.

Console error prints : "TypeError: b[le] is not a function"

Here is my function:

function timeline() {
    $.post('NewQuery.php', function ( data ) {
        alert (data);
        var data = new google.visualization.DataTable(JSON.parse(data));  

        var view = new google.visualization.DataView(data)
        view.setColumns ([0,2]) 

        chart = new google.visualization.LineChart(document.getElementById('chart2'));
        chart.draw(view);   
    });
}

Here is the JSON object that is 'alerted'- I formatted it to make it more legible.

{
    "cols":[
        {"label":"Dia","type":"date"},
        {"label":"Fruta","type":"string"},
        {"label":"CostoTotal","type":"number"}
    ],
    "rows":[
        {"c":[{"v":"Dia(2014, 3, 9)"},{"v":"Kiwis"},{"v":2628}]},
        {"c":[{"v":"Dia(2014, 3, 18)"},{"v":"Cerezos"},{"v":3200841}]},
        {"c":[{"v":"Dia(2014, 3, 23)"},{"v":"Peras"},{"v":113696}]},
        {"c":[{"v":"Dia(2014, 3, 1)"},{"v":"Cerezos"},{"v":4294967295}]}
    ]
}
¿Fue útil?

Solución

The problem is with your date strings, they should use the word "Date", not "Dia". This:

"Dia(2014, 3, 9)"

should be this:

"Date(2014, 3, 9)"
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top