gpt4 book ai didi

javascript - 未定义不是一个函数 - Javascript 中的错误

转载 作者:行者123 更新时间:2023-12-02 18:30:40 24 4
gpt4 key购买 nike

timechart = new google.visualization.Dashboard(document.getElementById('timechart'));

我得到undefined is not a function on this line。我在同一页面上初始化了其他图表,它们工作正常。作为引用,我的其余相关代码:

var timechartGraph = new google.visualization.ChartWrapper({
'chartType': 'LineChart',
'containerId': 'timechart-graph',
'options': {
// Use the same chart area width as the control for axis alignment.
'legend': {'position': 'right'}

},
// Convert the first column from 'date' to 'string'.
'view': {
'columns': [
{
'calc': function(dataTable, rowIndex) {
return dataTable.getFormattedValue(rowIndex, 11);
},
'type': 'string'
},1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}
});

var timechartRangeSlider = new google.visualization.ControlWrapper({
'controlType': 'ChartRangeFilter',
'containerId': 'timechart-range-slider',
'options': {
// Filter by the date axis.
'filterColumnIndex': 11,
'ui': {
'chartType': 'LineChart',
'chartOptions': {
'hAxis': {'baselineColor': 'none'}
},
// Display a single series that shows the closing value of the stock.
// Thus, this view has two columns: the date (axis) and the stock value (line series).
'chartView': {
'columns': [11, 12]
},
// 1 day in milliseconds = 24 * 60 * 60 * 1000 = 86,400,000
//'minRangeSize': 86400000
}
},
// Initial range: 2012-02-09 to 2012-03-20.
//'state': {'range': {'start': new Date(2012, 1, 9), 'end': new Date(2012, 2, 20)}}
});

timechartData = new google.visualization.DataTable();

timechart = new google.visualization.Dashboard(document.getElementById('timechart'));
timechart.bind(timechartRangeSlider, timechartGraph);

最佳答案

如果您现在只加载 corechart,您的代码可能如下所示:

google.load('visualization', '1', {
'packages': ['corechart']
});

您还必须加载控件包,如下所示:

google.load('visualization', '1', {
'packages': ['corechart', 'controls']
});

这应该定义 google.visualization.Dashboard。

关于javascript - 未定义不是一个函数 - Javascript 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17836192/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com