2017-03-17 20 views
1

紐約時報圖形編輯亞當pearce最近發佈的紐約時報的原始版本「你畫它」 - 使用D3的代碼。當試圖重用它時,我收到以下錯誤消息:d3.conventions不是在script.js的功能

「d3.conventions不是script.js中的函數」。

這是代碼:

的index.html

<!DOCTYPE html> 
 
<meta charset='utf-8'> 
 
<link rel="stylesheet" type="text/css" href="style.css"> 
 

 
<body></body> 
 

 
<script src='d3v4.js'></script> 
 
<script src='_script.js'></script>

的script.js

var data = [ 
 
     {"year": 2001, "debt": 31.4}, 
 
     {"year": 2002, "debt": 32.6}, 
 
     {"year": 2003, "debt": 34.5}, 
 
     {"year": 2004, "debt": 35.5}, 
 
     {"year": 2005, "debt": 35.6}, 
 
     {"year": 2006, "debt": 35.3}, 
 
     {"year": 2007, "debt": 35.2}, 
 
     {"year": 2008, "debt": 39.3}, 
 
     {"year": 2009, "debt": 52.3}, 
 
     {"year": 2010, "debt": 60.9}, 
 
     {"year": 2011, "debt": 65.9}, 
 
     {"year": 2012, "debt": 70.4}, 
 
     {"year": 2013, "debt": 72.6}, 
 
     {"year": 2014, "debt": 74.4}, 
 
     {"year": 2015, "debt": 73.6}, 
 
    ] 
 
    
 
    var ƒ = d3.f 
 
    
 
    var sel = d3.select('body').html('') 
 
    var c = d3.conventions({ 
 
     parentSel: sel, 
 
     totalWidth: sel.node().offsetWidth, 
 
     height: 400, 
 
     margin: {left: 50, right: 50, top: 30, bottom: 30} 
 
    })

我在哪裏可以找到d3.conventions?非常感謝你的幫助!

完整代碼可以在這裏找到:https://bl.ocks.org/1wheel/07d9040c3422dac16bd5be741433ff1e

+0

閱讀:https://github.com/1wheel/d3-starterkit –

回答