0

I want to create an angular nvd3 multibar chart using the following json data.

json:
[
    {
        "ccpProducts": "CME",
        "color": "red",
        "values": [
            {
                "dates": "2015-07-01 00:00:00.0",
                "noOfTrades": 5281
            }
        ]
    },
    {
        "ccpProducts": "LCH",
        "color": "#6b486b",
        "values": [
            {
                "dates": "2015-07-01 00:00:00.0",
                "noOfTrades": 5281
            }
        ]
    }
]
4

1 回答 1

0

由于values是一个对象数组,因此您不能像您正在做的那样通过它们的索引访问它的属性(对象属性没有排序):

// d[0] and d[1] are undefined!
x: function(d){ return new d[0]; },
y: function(d){ return d[1]; }

相反,您应该这样做:

x: function(d){ return new d['dates']; },
y: function(d){ return d['numOfTrades']; }

您还可以将数据格式转换为bar.json.

于 2015-09-01T08:02:15.537 回答