[英]D3.js Invisible rect element when using d3 append to add “rect” elements to an svg
[英]Unable to append a rect to a SVG using d3
我在html主體的div內有一個SVG,並且我正在使用d3向此SVG附加“矩形”,但是未生成rect。
<script>
//Select the SVG Container
var svgContainer = d3.select("#svg_container");
//Draw the Rectangle
var rectangle = svgContainer.append("rect").attr("x", 10).attr("y", 10).attr("width", 50).attr("height", 100);
<svg id="svg_container" width="1000px" height="800px"</svg>
下面是一個plunkr添加- https://embed.plnkr.co/aNW8NtiRfS6FkSQMHtkB/
在生成“矩形”的任何幫助將不勝感激。
加載庫后,需要加載script.js。
http://plnkr.co/edit/8qxmu5KpPZroGhB1odGK?p=預覽
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="script.js"></script>
</head>
<body ng-app="MyApp">
<div id="container" ng-controller="driversController">
<div id="ElementPane" class="container">
<svg id="svg_container" width="1000px" height="800px"></svg>
</div>
</div>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.