2013-03-05 55 views
0

我正在嘗試使用離散條形圖設置電子郵件活動的分析,並且我剛發現nvd3有一個奇怪的錯誤,其中值爲1000的任何數據點或更高版本不會正確呈現。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

你因爲在你的JSON的數字是不實際的數字看到這種行爲,但字符串(引號括起來)。它適用於刪除JSON中的數字引號。

+0

謝謝!沒想到這會是一個問題。也許他們應該在圖書館裏做一些parseInt魔術。 – looneydoodle 2013-03-05 18:42:43

+1

實際上這樣做更好,因爲更通用的確保它可以用於更多的項目,雖然有點工作(通常會爲數據轉換創建一些包裝)。 – paxRoman 2013-03-07 09:44:26

+0

然後,也許顯示一條消息將是一個聰明的想法... – maxwell2022 2013-11-22 03:06:18