My code looks like this:
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:
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.
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? 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.