2013-03-07 12 views
-1

我只想開始學習D3並在Rails中有一個項目來玩弄它。我可以在D3中寫出最基本的東西來看看

我有一個運行軌道服務器 - 本地主機 - 我已經在index.html的寫了這:

<!DOCTYPE html> 
<meta charset="utf-8"> 
<style> 
    body { font: 12px Arial;} 
    path { 
     stroke: steelblue; 
     stroke-width: 2; 
     fill: none; 
    } 
    .axis path, .axis line { 
     fill: none; 
     stroke: grey; 
     stroke-width: 1; shape-rendering: crispEdges; 
    } 
</style> 
<body> 
<p> Hi i am here</p> 
<script src="http://d3js.org/d3.v3.min.js"></script> 


</body> 

現在的我打字那裏開始,看到在一些最基本的東西瀏覽器嗎?

+1

我不明白什麼回報率有什麼關係,爲什麼正常的教程像[這一個](http://mbostock.github.com/d3/tutorial /bar-1.html)不適合你。 – explunit 2013-03-07 18:52:42

回答

1

這裏是一個示例代碼來畫一個圓:

<script> 
    d3.selectAll("body") //select the body 
     .append("svg") // add an svg element to the body 
     .append("circle") // add a circle to the svg element 
     .attr("r", 40) // add attributes to the circle 
     .attr("cx", 50) 
     .attr("cy", 50) 
</script> 

這裏是你的代碼「已完成」一的jsfiddle:http://jsfiddle.net/Bd7HA/


如果你不意味着圖形的東西,你可以也是這樣做的,它基本上在「body」標籤內寫入「Hello World」。

<script> 
    d3.selectAll("body").text("Hello World") 
</script> 

的jsfiddle:http://jsfiddle.net/chrisJamesC/Bd7HA/5/

相關問題