d3.js庫中的band()函數用於從對應於給定輸入域的範圍返回波段的起點。
用法:
band(value);
參數:該函數采用上麵給出的和下麵描述的單個參數。
- Value:這接受來自指定域的值。
返回值:此函數返回指定範圍內的值。
例:下麵的示例演示上述函數。
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" path1tent=
"width=device-width, initial-scale = 1.0" />
<script src="https://d3js.org/d3.v4.min.js">
</script>
</head>
<body>
<script>
// Create the band scale with
// specified domain and range.
var band = d3.scaleBand()
.domain([0, 1, 2, 3, 4, 5])
.range([1, 10]);
// Discrete values are automatically
// created by the band function
// band of the range is [1, 10]
console.log("band(0):", band(0));
console.log("band(1):", band(1));
console.log("band(2):", band(2));
console.log("band(3):", band(3));
</script>
</body>
</html>
輸出:
相關用法
- d3.js band.round()用法及代碼示例
- d3.js band.rangeRound()用法及代碼示例
- d3.js band.copy()用法及代碼示例
- d3.js band.domain()用法及代碼示例
- d3.js band.range()用法及代碼示例
- d3.js band.step()用法及代碼示例
- d3.js band.bandwidth()用法及代碼示例
- 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()用法及代碼示例
注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 D3.js bandScale band() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。