参考错误 - 日期 [英] Reference Error - date
问题描述
我正在尝试获取我的日期值来解析日期的正确格式但是我在控制台调试界面上遇到以下错误:
ReferenceError:未定义dt - >错误
I am trying to get my date value to parse correct format of date but however i am experiencing the following error on the console debugging interface :
ReferenceError: dt is not defined --> error
function drawVisualization(dataValues, chartTitle, columnNames, categoryCaption) {
if (dataValues.length < 1)
return;
var data = new google.visualization.DataTable();
data.addColumn('string', columnNames.split(',')[0]);
data.addColumn('number', columnNames.split(',')[1]);
data.addColumn('string', columnNames.split(',')[2]);
data.addColumn('datetime', columnNames.split(',')[3]);
for (var i = 0; i < dataValues.length; i++) {
var date = new Date(parseInt(dt.getValue(row, 3))); // error line
data.addRow([dataValues[i].ColumnName, dataValues[i].Value, dataValues[i].Type, date]);
}
var dateFormatter = new google.visualization.DateFormat({ pattern: 'dd MM yyyy' });
var line = new google.visualization.ChartWrapper({
'chartType': 'LineChart',
'containerId': 'PieChartContainer',
'options': {
'width': 950,
'height': 450,
'legend': 'right',
'hAxis': {
'format': "dd-MM-yyyy",
'hAxis.maxValue': 'viewWindow.max',
'maxValue': new Date(2014, 05, 30), 'minValue': new Date(2014, 04, 05),
'viewWindow': { 'max': new Date(2014, 05, 30) },
},
'title': chartTitle,
'chartArea': { 'left': 100, 'top': 100, 'right': 0, 'bottom': 100 },
'tooltip': { isHtml: true }
},
'view': {
'columns': [{
type: 'string',
label: data.getColumnLabel(3),
calc: function (dt, row) {
var date = new Date(parseInt(dt.getValue(row, 3)));
return dateFormatter.formatValue(date);
}
}, 1, {
type: 'string',
role: 'tooltip',
calc: function (dt, row) {
return 'Name: ' + dt.getValue(row, 0) + ', Decimal Price: ' + +dt.getValue(row, 1) + ', Date: ' + +dt.getFormattedValue(row, 3);
}
}]
}
});
new google.visualization.Dashboard(document.getElementById('PieChartExample')).bind([categoryPicker], [line]).draw(data);
}
我还尝试使用以下内容编辑错误行:
var date = new Date(parseInt(dataValues [i] .getValue(row,3)));
但是上面的行代码显示了类似的错误消息,例如:
未捕获的ReferenceError:行是未定义 - >错误
请咨询。非常感谢。
I have also tried editing to the error line with the following:
var date = new Date(parseInt(dataValues[i].getValue(row, 3)));
However the above line code shows a similar error message such as:
Uncaught ReferenceError: row is not defined --> error
Please advice. Many thanks.
推荐答案
我看到'dt'和'row'在使用之前没有在任何地方声明。
你的意思是用数据代替'dt'吗?
What i am seeing that 'dt' and 'row' are not declared anywhere before being used here.
Do you mean to use 'data' in place of 'dt' ?
这篇关于参考错误 - 日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!