Javascript 给定DataTable时,Google Charts draw()方法的类型错误

Javascript 给定DataTable时,Google Charts draw()方法的类型错误,javascript,datatable,google-api,google-visualization,Javascript,Datatable,Google Api,Google Visualization,我试图使用HTML和Javascript在Google图表中显示带有范围过滤器的折线图,但每当我运行draw()函数时,代码都会告诉我,我对draw()参数使用了错误的数据类型(它应该是DataTable)。但是,我使用arrayToDataTable()构建数据,根据GoogleCharts API,它创建了一个数据表。这是我的全部代码: <html> <head> <script type="text/javascript" src="h

我试图使用HTML和Javascript在Google图表中显示带有范围过滤器的折线图,但每当我运行
draw()
函数时,代码都会告诉我,我对
draw()
参数使用了错误的数据类型(它应该是
DataTable
)。但是,我使用
arrayToDataTable()
构建数据,根据GoogleCharts API,它创建了一个数据表。这是我的全部代码:

<html>
    <head>
        <script type="text/javascript" src="http://www.google.com/jsapi"></script>
        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
        <script type="text/javascript">
            //Chart data
            google.charts.load('current',{'packages':['controls']});
            google.charts.setOnLoadCallback(drawDashboard);

            function drawDashboard(){
                var dataSet = google.visualization.arrayToDataTable([
                    [{label:'date',type:'datetime'},{label:'Bytes from network:Bytes to network',type:'number'}],
                    [new Date(2016,01,23,00,00),1.0],
                    [new Date(2016,01,23,01,00),1.0075187969924813],
                    [new Date(2016,01,23,03,00),1.126865671641791],
                    [new Date(2016,01,24,22,00),0.987012987012987],
                    [new Date(2016,01,25,01,00),1.0],
                    [new Date(2016,01,25,02,00),0.9166666666666666],
                    [new Date(2016,01,25,10,00),1.0],
                    [new Date(2016,01,26,12,00),1.0],
                    [new Date(2016,01,27,17,00),0.9864864864864865],
                    [new Date(2016,01,28,22,00),0.03125],
                    [new Date(2016,02,01,22,00),0.97],
                ]);

                var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard_div'));

                var dateRangeFilter = new google.visualization.ControlWrapper({'controlType':'ChartRangeFilter','containerId':'filter_div','options': {'filterColumnLabel':'date'}});

                var lineChart = new google.visualization.ChartWrapper({'chartType':'LineChart','containerId':'curve_chart','options':{'title': 'Total Bytes from the Source Network to Total Bytes To the Source Network per Day','curveType': 'function','legend': {'postition':'bottom'}}});

                dashboard.bind(dateRangeFilter,lineChart);

                dashboard.draw(dataSet);
            }
        </script>
    </head>
    <body>
        <!--draw charts using corresponding div tags-->
        <div id="dashboard_div">
            <div id="filter_div"></div>
            <div id="curve_chart" style="width:900px;height:500px"></div>
        </div>
    </body>
</html>

我不确定它为什么抛出这个错误,因为
dataSet
显然是
DataTable
类的一个实例。我多次尝试清除缓存和Cookie,但均无效。

尝试删除对
http://www.google.com/jsapi

您应该只需要
loader.js

我还发现,在使用
loader.js
时,除了
“控件”

google.charts.load('current'{
包:['controls','corechart'],
回调:drawDashboard
});
函数drawDashboard(){
var dataSet=google.visualization.arrayToDataTable([
[{label:'date',type:'datetime'},{label:'Bytes from network:Bytes to network',type:'number'}],
[新日期(2016,01,23,00,00),1.0],
[新日期(2016,01,23,01,00),1.0075187969924813],
[新日期(2016,01,23,03,00),1.126865671641791],
[新日期(2016,01,24,22,00),0.987012987012987],
[新日期(2016,01,25,01,00),1.0],
[新日期(2016,01,25,02,00),0.916666],
[新日期(2016,01,25,10,00),1.0],
[新日期(2016,01,26,12,00),1.0],
[新日期(2016,01,27,17,00),0.9864864864864865],
[新日期(2016,01,28,22,00),0.03125],
[新日期(2016,02,01,22,00),0.97],
]);
var dashboard=newgoogle.visualization.dashboard(document.getElementById('dashboard_div'));
var dateRangeFilter=new google.visualization.ControlWrapper({'controlType':'ChartRangeFilter','containerId':'filter_div','options':{'filterColumnLabel':'date'});
var lineChart=new google.visualization.ChartWrapper({'chartType':'lineChart','containerId':'curve_chart','options':{'title':'Total Bytes from Source Network to Total Bytes to the Source Network Day','curveType':'function','legend':{'position':'bottom});
dashboard.bind(dateRangeFilter、lineChart);
dashboard.draw(数据集);
}


根据谷歌图表的示例页面(以及我看到的大多数其他页面),您只需要导入
控件
包。这是一个新的变更,也需要
corechart
包吗?如果只包含
控件
,则会出现一个错误,说明
google.load不是一个函数
。我发现单独使用
jsapi
时,只需要
'controls'
,而
loader.js
则不需要。显然,最近发布了一个有缺陷的版本-->--删除了“jsapi”大大提高了谷歌图表对我的可靠性。
You called the draw() method with the wrong type of data rather than a DataTable or DataView