d3.js中的band.step()函數用於查找頻段的階躍,該階躍是通過查找相鄰頻段的起點之間的距離來計算的。
用法:
band.step()
參數:此函數不接受任何參數。
返回值:此函數返回相鄰頻段起點之間的距離。
範例1:
HTML
<!DOCTYPE html>
<html>
<head>
<script src=
"https://d3js.org/d3.v4.min.js">
</script>
</head>
<body>
<script>
// Creating the band scale with
// specified domain and range
var A = d3.scaleBand()
.domain([10, 20, 30, 40, 50])
.range([0, 10]);
// Using the step() function
let step_val = A.step();
// Printing the Output
console.log("Step Of A:", step_val);
</script>
</body>
</html>
輸出:
Step Of A: 2
範例2:
HTML
<!DOCTYPE html>
<html>
<head>
<script src=
"https://d3js.org/d3.v4.min.js">
</script>
</head>
<body>
<script>
// Creating the band scale with
// specified domain and range
var B = d3.scaleBand()
.domain(["one", "two",
"three", "four"])
.range([0, 60]);
// Using the step() function
let step_val = B.step();
// Printing the Output
console.log("Step in B:", step_val);
</script>
</body>
</html>
輸出:
Step in B: 15
相關用法
- PHP imagecreatetruecolor()用法及代碼示例
- p5.js year()用法及代碼示例
- d3.js d3.utcTuesdays()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP Ds\Sequence last()用法及代碼示例
- PHP array_udiff_uassoc()用法及代碼示例
- PHP geoip_continent_code_by_name()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP GmagickPixel setcolor()用法及代碼示例
- PHP opendir()用法及代碼示例
- PHP cal_to_jd()用法及代碼示例
- d3.js d3.bisectLeft()用法及代碼示例
- PHP stream_get_transports()用法及代碼示例
- PHP Ds\Deque pop()用法及代碼示例
注:本文由純淨天空篩選整理自jana_sayantan大神的英文原創作品 D3.js band.step() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。