point.domain()函數用於將磅秤的範圍設置為指定的值數組。數組中的第一個元素映射到範圍中的第一個點,域中的第二個值映射到第二個點,依此類推。
用法:
point.domain([domain]);
參數:此函數接受上麵給定和下麵描述的單個參數:
- domain:此參數設置點刻度的域,即最小值和最大值。
返回值:此函數不返回任何內容。
下麵給出的是上麵給出的函數的一些例子。
範例1:
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UTF-8" />
<meta name = "viewport"
path1tent = "width=device-width,
initial-scale = 1.0"/>
<title>GeekforGeeks</title>
<script src =
"https://d3js.org/d3.v4.min.js">
</script>
</head>
<style>
</style>
<body>
<script>
// Creating the point scale with
// specified domain and range.
var point = d3.scalePoint()
.domain([1, 2, 3, 4]);
console.log("point(1):", point(1));
console.log("point(2):", point(2));
console.log("point(3):", point(3));
console.log("point(4):", point(4));
</script>
</body>
</html>
輸出:
範例2:
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UTF-8" />
<meta name = "viewport"
path1tent = "width=device-width,
initial-scale = 1.0"/>
<title>GeekforGeeks</title>
<script src =
"https://d3js.org/d3.v4.min.js">
</script>
</head>
<style>
</style>
<body>
<script>
// Creating the point scale with specified domain and range.
var point = d3.scalePoint()
.domain([1, 2, 3, 4])
.range([10, 50]);
console.log("point(1):", point(1));
console.log("point(2):", point(2));
console.log("point(3):", point(3));
console.log("point(4):", point(4));
</script>
</body>
</html>
輸出:
相關用法
- PHP Ds\Set xor()用法及代碼示例
- p5.js value()用法及代碼示例
- d3.js d3.sum()用法及代碼示例
- p5.js pan()用法及代碼示例
- PHP max( )用法及代碼示例
- d3.js d3.mean()用法及代碼示例
- PHP ord()用法及代碼示例
- d3.js d3.min()用法及代碼示例
- p5.js nfs()用法及代碼示例
- p5.js nf()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- p5.js nfc()用法及代碼示例
- p5.js nfp()用法及代碼示例
- d3.js now()用法及代碼示例
- PHP Ds\Set last()用法及代碼示例
- PHP Ds\Set add()用法及代碼示例
注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 D3.js point.domain() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。