我想按年筛选我的数据,但不知道在哪里/如何从我的数据集(从csv加载)解析出我的年份。 (draw(d)和plot_loans(d)函数都被调用)。 我得到的错误:TypeError:d.ListingCreationDate.getUTCFullYear不是一个构造函数。TypeError:d.ListingCreationDate.getUTCFullYear不是构造函数
function draw(d) {
function plot_loans(d){
function update(year){
var filtered = d.filter(function(d){
return new d.ListingCreationDate.getUTCFullYear() === year;
});
}
}
这是我的装载功能:
d3.csv("loandata_sample.csv", function(d) {
return {
ListingKey: d.ListingKey,
ListingCreationDate: Date(d.ListingCreationDate)
};
当我试图ListingCreationDate:新的日期(d.ListingCreationDate)我得到一个无效的日期返回 – mleafer
当我实现你的第一个建议,(返程(新日期( d.ListingCreationDate))。getUTCFullYear()=== year;)和called update(2010);在控制台窗口中,我收到一个错误,指出更新未定义。 – mleafer