[英]Why isn't my SVG being created?
My code looks like this: 我的代码如下所示:
Index.html Index.html
<head>
<script type="text/javascript" src="d3/d3.js"></script>
</head>
<body>
<script type="text/javascript" src="Fuel_Plan.js"></script>
<div class="mydiv">
</div>
</body>
Fuel_Plan.js: Fuel_Plan.js:
var width = 800;
var height = 300;
var svg = d3.select(".mydiv")
.append("svg")
.attr("width", width )
.attr("height", height );
What am I trying to achieve? 我想达到什么目的? Draw a blank SVG (and append a background image to it, but that is for later!) So I select "mydiv" and i append an SVG to it, then I give it attrs, of width and height.
绘制一个空白的SVG(并在其上附加背景图像,但这是供以后使用!)因此,我选择“ mydiv”,然后在其上附加一个SVG,然后为其指定宽度和高度的属性。
When I go into my browser though, I am seeing this: 但是,当我进入浏览器时,会看到以下信息:
As you can see it's not correctly displaying the SVG, can someone help me what I'm doing wrong here? 如您所见,它无法正确显示SVG,有人可以帮助我在这里做错什么吗? I'm sure i'm missing something basic!
我确定我缺少基本的东西!
Console is empty 控制台为空
<div class="mydiv">
</div>
<script type="text/javascript" src="Fuel_Plan.js"></script>
above will work, script was running before div was created. 以上工作正常,脚本在创建div之前运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.