我想按年篩選我的數據,但不知道在哪裏/如何從我的數據集(從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