d3.js中的band.bandwidth()函数用于查找每个波段的宽度。
用法:
band.bandwidth()
参数:此函数不接受任何参数。
返回值:此函数返回每个波段的宽度。
范例1:
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>
// Creating the band scale with
// specified domain and range.
var A = d3.scaleBand()
.domain([10, 20, 30, 40, 50])
.range([0, 10]);
// Applying bandwith() Function
let gfg = A.bandwidth();
// Printing the Output
console.log("Bandwith Of A:",gfg);
</script>
</body>
</html>
输出:
Bandwith Of A: 2
范例2:
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>
// Creating the band scale with
// specified domain and range.
var B = d3.scaleBand()
.domain(["one", "two", "three", "four"])
.range([0, 60]);
// Applying bandwith() Function
let gfg = B.bandwidth();
// Printing the Output
console.log("Bandwith Of each band in B:",gfg);
</script>
</body>
</html>
输出:
Bandwith Of each band 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.bandwidth() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。