I've been experimenting with CodePlayground by google, and wrote this code to display a chart:

function drawVisualization() {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'County');
    data.addColumn('date', 'Year');
    data.addColumn('number', 'STD Rate');
    data.addColumn('number', 'Teen Pregnancy');
    data.addRows([
        ['Region 1', new Date(2001), 14.1, 49.2],
        ['Region 2', new Date(2001), 8.5, 41.6],
        ['Region 1', new Date(2002), 13.9, 45.1],
        ['Region 2', new Date(2002), 9.6, 39.7],
        ['Region 1', new Date(2003), 13.4, 45.8],
        ['Region 2', new Date(2003), 8.2, .8.7]
    ]);

    var motionchart = new google.visualization.MotionChart(
    document.getElementById('visualization'));
    motionchart.draw(data, {
        'width': 800,
        'height': 400
    });
}

I keep getting the error missing ] after element but I've been comparing it to the sample code below and can't find what it is talking about

function drawVisualization() {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Fruit');
    data.addColumn('date', 'Date');
    data.addColumn('number', 'Sales');
    data.addColumn('number', 'Expenses');
    data.addColumn('string', 'Location');
    data.addRows([
        ['Apples', new Date(1988, 0, 1), 1000, 300, 'East'],
        ['Oranges', new Date(1988, 0, 1), 950, 200, 'West'],
        ['Bananas', new Date(1988, 0, 1), 300, 250, 'West'],
        ['Apples', new Date(1988, 1, 1), 1200, 400, 'East'],
        ['Oranges', new Date(1988, 1, 1), 900, 150, 'West'],
        ['Bananas', new Date(1988, 1, 1), 788, 617, 'West']
    ]);

    var motionchart = new google.visualization.MotionChart(
    document.getElementById('visualization'));
    motionchart.draw(data, {
        'width': 800,
        'height': 400
    });
}

Any thoughts?

share|improve this question
1  
Instead of using StackOverflow, you should use a validator like jshint.com for your syntax issues. – the system Feb 28 at 4:01

closed as too localized by David Wolever, the system, Sudhir, dfsq, MrCode Feb 28 at 10:14

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

modify your last entry. There is an extra .

['Region 2', new Date(2003), 8.2, 8.7 ]
share|improve this answer
Thanks, It still isn't working but that is definitely an issue. – camdenl Feb 28 at 7:03
i checked it here.code.google.com/apis/ajax/playground/… its working – Toms Feb 28 at 7:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.