D3 json stock chart not displaying

僤鯓⒐⒋嵵緔 提交于 2019-11-29 12:59:02

d3.json does not accept an accessor (or row) function. It has to be just:

d3.json(url[, callback])

In your code:

d3.json("bboList.json", function(d) {
    d.timeStr = parseTime(d.timeStr);
    d.bid = +d.bid;
    return d;
}, function(error, data) {
    if (error) throw error;
    //...
});

Everything between the URL and function(error, data) is the row function.

Solution: remove it, and coerce the values to numbers and dates using a forEach:

d3.json("bboList.json", function(error, data) {
    if (error) throw error;

    data.forEach(d => {
        d.timeStr = parseTime(d.timeStr);
        d.bid = +d.bid;
    });

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