简体   繁体   English

PyCharm无法识别D3.js

[英]D3.js is not recognized by PyCharm

  1. I have installed the D3.js library from the Javascript tab in Settings 我已经从“设置”中的“ Javascript”选项卡安装了D3.js库
  2. Also imported the src using <script src="https://d3js.org/d3.v4.min.js"></script> 还使用<script src="https://d3js.org/d3.v4.min.js"></script>导入了src

  3. Here is my app.py: 这是我的app.py:

     @app.route('/') def my_form(): return render_template('circle.html') 
  4. Here is circle.html 这是circle.html

     <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="https://d3js.org/d3.v4.min.js"></script> </head> <body> <script> var canvas = d3.select("body") .append("svg") .attr("width",500) .attr("width",300); var circle = canvas.append("circle") .attr("cx", 250) .attr("cy", 250) .attr("r", 50) .attr("fill","red"); </script> </body> </html> 

Anybody knows why? 有人知道为什么吗?

The problem is, I suppose, a typo in your Javascript code: 我想问题是您的Javascript代码中有错字:

var canvas = d3.select("body")
               .append("svg")
               .attr("width",500)
               .attr("width",300);

As you can see, you didn't set the height property; 如您所见,您没有设置height属性; instead you set twice the width property. 而是将宽度属性设置为两倍。

Check this fiddle for the complete code. 检查此小提琴以获得完整的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM