nvd3不显示值为1000或更高的数据的图形

时间:2013-03-05 18:32:50

标签: graph d3.js nvd3.js

我正在为具有离散条形图的电子邮件活动设置分析,我发现nvd3有一个奇怪的错误,其中任何值为1000或更高的数据点都无法正确呈现。

这里是jsfiddle

http://jsfiddle.net/aMnSb/

 var data = [{
key: "Cumulative Return",
values: [
    {"label" : "delivered","value" : "999","color" : "458ec1",},{"label" : "opened","value" : "176","color" : "65a1cb",},{"label" : "clicked","value" : "8","color" : "7fb1d4",},{"label" : "unopened","value" : "487","color" : "aacce3",},{"label" : "bounced","value" : "357","color" : "eec4cc",},{"label" : "unsubscribed","value" : "1","color" : "e39ba9",},                 ]

}];

有效,但这不起作用

var data_large = [{
    key: "Cumulative Return",
    values: [
        {"label" : "delivered","value" : "1000","color" : "458ec1",},{"label" : "opened","value" : "176","color" : "65a1cb",},{"label" : "clicked","value" : "8","color" : "7fb1d4",},{"label" : "unopened","value" : "487","color" : "aacce3",},{"label" : "bounced","value" : "357","color" : "eec4cc",},{"label" : "unsubscribed","value" : "1","color" : "e39ba9",},                    ]
}];

1 个答案:

答案 0 :(得分:1)

您会看到此行为,因为JSON中的数字实际上不是数字,而是字符串(用引号括起来)。如果您删除JSON中数字周围的引号,它就可以工作。