这可能是一件非常简单的事情,但一直未能弄清楚。我有一个带有图例的多线图。我已经按照下面的格式指定了parameter_id作为关键字。访问键值?
Array[3]
0: Object
key: "1"
values: Array[11]
0: Object
client_id: "1"
dateTimeReceived: "2013-03-12 05:54:10"
dateTimeTaken: Tue Mar 12 2013 05:53:41 GMT+0000 (GMT Standard Time)
id: "1"
inspectionPoint_id: "1"
parameterType: "Temperature"
parameter_id: "1"
reading: 2.1
testSourceLocationDescription: "test source"
testSourceLocationLatitude: "53.000000000000000"
testSourceLocationLongitude: "-7.000000000000000"
testSourceLowerLimit: "4"
testSourceUpperLimit: "25"
testSource_id: "1"
unitMeasurement: "°C"
__proto__: Object
我的问题是,明明传说文本显示的ID - 但我想它显示的参数类型。我是否需要将parameterType指定为第二个键(如果可能,请避免此操作),还是有任何方法可以访问此值?
PS - 我最初使用parameterType作为键,但元素在更新时未被正确绑定。
你是如何生成的图形? – 2013-03-12 13:40:46
这里 - https://gist.github.com/Majella/ab32fe0151fd487da3f6 – Newbie 2013-03-12 14:43:21
你有没有尝试改变legend.append('文本')下的文本“.text(function(d){return d.key;}) “to”.text(function(d){return d.parmaeterType;})“ – 2013-03-12 14:50:13