Ruby on rails 3.2 我能在D3中写的最基本的东西就是看东西

Ruby on rails 3.2 我能在D3中写的最基本的东西就是看东西,ruby-on-rails-3.2,d3.js,Ruby On Rails 3.2,D3.js,我只想开始学习D3,并在Rails中有一个项目来使用它 我有一个正在运行的rail服务器—localhost—我已经在index.html中编写了以下内容: <!DOCTYPE html> <meta charset="utf-8"> <style> body { font: 12px Arial;} path { stroke: steelblue; stroke-width: 2; fill:

我只想开始学习D3,并在Rails中有一个项目来使用它

我有一个正在运行的rail服务器—localhost—我已经在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>

正文{font:12px Arial;}
路径{
笔画:钢蓝;
笔画宽度:2;
填充:无;
}
.轴路径,.轴线{
填充:无;
笔画:灰色;
笔划宽度: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>

d3.selectAll(“主体”)//选择主体
.append(“svg”)//将svg元素添加到正文中
.append(“circle”)//向svg元素添加一个圆
.attr(“r”,40)//向圆添加属性
.attr(“cx”,50)
.attr(“cy”,50)
下面是一个代码为“已完成”的JSFIDLE:


如果你不是指图形,你也可以这样做,在“body”标签里写上“helloworld”


d3.选择全部(“正文”)。文本(“你好世界”)

JSFIDLE:

我不明白RoR与它有什么关系,也不明白为什么像这样的普通教程不适合您。
<script>
    d3.selectAll("body").text("Hello World")
</script>