当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


d3.js Symbols symbolSquare用法及代码示例


d3.symbolSquare属性是D3.js中的符号类型。它是一个 square-shaped可以使用的符号类型。

用法:

d3.symbolSquare 

范例1:

HTML

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
  
    <script src= 
        "https://d3js.org/d3.v5.min.js"> 
    </script> 
</head> 
  
<body> 
  
    <h1 style="text-align:center; color:green;"> 
        GeeksforGeeks 
    </h1> 
  
    <h3 style="text-align:center;"> 
        D3.js | symbolSquare 
    </h3> 
  
    <center> 
    <svg id="gfg" width="100" height="100"></svg> 
    </center> 
  
    <script> 
        // symbolSquare 
        var sym = d3.symbol() 
            .type(d3.symbolSquare).size(500); 
        d3.select("#gfg") 
            .append("path") 
            .attr("d", sym) 
            .attr("fill", "green") 
            .attr("transform", "translate(50,50)"); 
    </script> 
</body> 
  
</html>

输出:



范例2:

HTML

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
  
    <script src= 
        "https://d3js.org/d3.v5.min.js"> 
    </script> 
</head> 
  
<body> 
  
    <h1 style="text-align:center; color:green;"> 
        GeeksforGeeks 
    </h1> 
  
    <h3 style="text-align:center;"> 
        D3.js | symbolSquare 
    </h3> 
  
    <center> 
    <svg id="gfg" width="100" height="100"></svg> 
    </center> 
  
    <script> 
        // symbolSquare 
        var sym = d3.symbol() 
            .type(d3.symbolSquare).size(500); 
        d3.select("#gfg") 
            .append("path") 
            .attr("d", sym) 
            .attr("fill", "none") 
            .attr("stroke","green") 
            .attr("stroke-width","5px") 
            .attr("transform", "translate(50,50)"); 
    </script> 
</body> 
  
</html>

输出:




相关用法


注:本文由纯净天空筛选整理自taran910大神的英文原创作品 D3.js Symbols symbolSquare Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。