當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


d3.js brushX()用法及代碼示例

這個d3.brushX()函數在D3.js中用於使用新的一維畫筆x-尺寸。

用法:

d3.brushX();

參數:該函數不接受任何參數。

返回值:此函數沿x軸返回新創建的一維筆刷

例:在此示例中,我們將使用此方法在SVG元素上創建一維畫筆和大小為600×600像素的x軸畫筆。



HTML

<!DOCTYPE html>  
<html>  
      
<head>  
    <title>  
        D3.js | d3.brushX() Function  
    </title>  
      
    <script src =  
        "https://d3js.org/d3.v4.min.js">  
    </script>  
</head>  
  
<body>  
    <svg width=600 height=600 id="brush"></svg> 
    <script>  
          
        // Selecting SVG element 
        d3.select("#brush") 
        // Creating a brush along x-axis  
        // using the d3.brush function 
        .call( d3.brushX()              
        // Initialise the brush area:start at  
        // 0,0 and finishes at given width,height 
        .extent( [ [0,0], [600,600] ] )        
      ) 
    </script>  
</body>  
  
</html>

輸出:

參考: https://devdocs.io/d3~5/d3-brush#brushX

相關用法


注:本文由純淨天空篩選整理自taran910大神的英文原創作品 D3.js brushX() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。