這個d3.brush()函數在D3.js中用於新創建2-D畫筆。該筆刷一般是創建SVG元素的。
用法:
d3.brush();
參數:該函數不接受任何參數。
返回值:此函數返回一個新創建的筆刷。
例:在此示例中,我們將使用此方法在SVG元素上創建大小為600×600像素的畫筆。
HTML
<!DOCTYPE html>
<html>
<head>
<title>
D3.js | d3.brush() 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 using the
// d3.brush function
.call( d3.brush()
// Initialise the brush area:start at
// 0,0 and finishes at given width,height
.extent( [ [0,0], [600,600] ] )
)
</script>
</body>
</html>
輸出:畫筆創建成功,您可以使用此畫筆拖動以創建矩形。
相關用法
- PHP ord()用法及代碼示例
- d3.js d3.hsl()用法及代碼示例
- p5.js arc()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP each()用法及代碼示例
- CSS hsl()用法及代碼示例
- d3.js d3.mean()用法及代碼示例
- d3.js d3.map.get()用法及代碼示例
- d3.js d3.sum()用法及代碼示例
- PHP next()用法及代碼示例
- PHP Ds\Map put()用法及代碼示例
- d3.js d3.map.has()用法及代碼示例
- PHP pow( )用法及代碼示例
- p5.js nfc()用法及代碼示例
- PHP pi( )用法及代碼示例
- p5.js nf()用法及代碼示例
注:本文由純淨天空篩選整理自taran910大神的英文原創作品 D3.js brush() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。