threshold.domain()函數用於設置閾值刻度的域。此處給出的值必須為非降序排列,否則,刻度的行為是不確定的。
用法:
threshold.domain([domain]);
參數:此函數接受上麵給定和下麵描述的單個參數。
- domain:此參數按排序順序接受元素數組,該數組設置了比例域。
返回值:此函數不返回任何值。
以下示例程序旨在說明閾值.D3.js中的domain()函數
範例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>
<h2 style="color:green;">GeeksforGeeks</h2>
<p>threshold.domain() Function</p>
<script>
var threshold = d3.scaleThreshold()
// Setting domain for the scale.
.domain([1, 2, 3, 4])
.range([10, 20, 30, 40, 50]);
let val1 = threshold(1);
let val2 = threshold(2);
let val3 = threshold(4);
document.write("<h4>" + val1 + "</h4>");
document.write("<h4>" + val2 + "</h4>");
document.write("<h4>" + val3 + "</h4>");
</script>
</body>
</html>
輸出:
範例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>
<h2 style="color:green;">GeeksforGeeks</h2>
<p>threshold.domain() Function </p>
<script>
var threshold = d3.scaleThreshold()
// Setting domain for the scale.
.domain([1, 2, 3, 4]);
document.write("<h4>" + threshold(0) + "</h4>");
document.write("<h4>" + threshold(4) + "</h4>");
</script>
</body>
</html>
輸出:
相關用法
- PHP Ds\Set add()用法及代碼示例
- PHP each()用法及代碼示例
- PHP Ds\Map put()用法及代碼示例
- PHP Ds\Set first()用法及代碼示例
- PHP Ds\Set last()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- p5.js pan()用法及代碼示例
- p5.js value()用法及代碼示例
- PHP Ds\Map xor()用法及代碼示例
- PHP Ds\Set contains()用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- d3.js lch()用法及代碼示例
- d3.js d3.max()用法及代碼示例
- p5.js hue()用法及代碼示例
- p5.js min()用法及代碼示例
- p5.js red()用法及代碼示例
注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 D3.js threshold.domain() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。