parsing dates using time in d3

社会主义新天地 提交于 2019-12-25 07:44:34

问题


How can I get something like this to work?

Example date format:

6/20/2016 10:30:00 AM

Example operation I want to perform:

parseDate(data["Checkin"]).getMonth() + 1

Current parseDate function:

var parseDate = d3.time.format("%m/%d/%Y %H:%M:%S %p").parse;

I am getting a data.slice is not a function TypeError when calling a d3 graphing function after the following:

var data = d3.csv("Sales Export Friendly 3-19-17.csv", function(data) {
    return {
        unit: data["Unit Booked"],
        date: parseDate(data["Booking Date"]).getMonth() + 1,
        checkin: parseDate(data["Checkin"]).getMonth() + 1,
        LOS: new Date(data["Checkout"]).valueOf() - new Date(data["Checkin"]).valueOf()/(24*60*60*1000),
        total: +data["Total Stay"],
        avgNight: (+data["Total Stay"]) / ((new Date(data["Checkout"]).valueOf() - new Date(data["Checkin"]).valueOf())/(24*60*60*1000)),
        }

来源:https://stackoverflow.com/questions/42990052/parsing-dates-using-time-in-d3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!