Quantile.copy()函數返回原始比例的精確副本。如果在任何一個比例尺上進行任何更改,都不會影響另一個比例尺。
用法:
quantile.copy();
參數:此函數不接受任何參數。
返回值:此函數返回原始比例的副本。
以下示例說明了D3.js中的Quantile.copy()函數:
範例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;">GeekforGeeks</h2>
<p>quantile.copy() Function</p>
<script>
var quantile = d3.scaleQuantile()
// Setting domain for the scale.
.domain([1, 2, 15, 19])
// Discrete range
.range(["red", "green", "black", "blue"]);
// Printing the output.
document.write("<h3>Form original scale:</h3>");
document.write("<span>quantile(1):"
+ quantile(1) + "</span><br>");
document.write("<span>quantile(15):"
+ quantile(15) + "</span><br>");
document.write("<h3>Form copy scale:</h3>");
var copyscale = quantile.copy();
document.write("<span>copyscale(1):"
+ copyscale(1) + "</span><br>");
document.write("<span>copyscale(15):"
+ copyscale(15) + "</span><br>");
</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;">GeekforGeeks</h2>
<p>quantile.copy() Function </p>
<script>
var quantile = d3.scaleQuantile()
// Setting domain for the scale.
.domain([1, 2, 15, 19])
// Discrete range
.range(["red", "green", "black", "blue"]);
// Printing the output.
document.write("<h3>Form original scale:</h3>");
document.write("<span>quantile(2):"
+ quantile(2) + "</span><br>");
document.write("<span>quantile(19):"
+ quantile(19) + "</span><br>");
document.write("<h3>Form copy scale:</h3>");
// Changing th copy scale.
var copyscale = quantile.copy()
.range([1.22, 11.5421, 2.2154, 3.2154]);
document.write("<span>copyscale(2):"
+ copyscale(2) + "</span><br>");
document.write("<span>copyscale(19):"
+ copyscale(19) + "</span><br>");
</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 quantile.copy() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。