d3.js中的threshold.copy()函数用于创建和返回阈值刻度的精确副本。原始比例的任何更改都不会影响复印比例。
用法:
threshold.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>threshold.copy() Function </p>
<script>
var threshold = d3.scaleThreshold()
// Domain
.domain([1, 2, 3, 4])
// Range for the domain
.range([10, 20, 30, 40, 50]);
document.write("<h3>threshold(1):"
+ threshold(1) + "</h3>");
document.write("<h3>threshold(3):"
+ threshold(3) + "</h3>");
document.write(
"<p> This is from copy scale.</p>");
var thresholdCopy = threshold.copy();
document.write("<h3>thresholdCopy(1):"
+ thresholdCopy(1) + "</h3>");
document.write("<h3>thresholdCopy(3):"
+ thresholdCopy(3) + "</h3>");
</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>threshold.copy() Function </p>
<script>
var threshold = d3.scaleThreshold()
// Domain
.domain([1, 2, 3, 4])
// Range for the domain
.range([10, 20, 30, 40, 50]);
var thresholdCopy = threshold.copy();
document.write(
"<div style=line-height:5px><h3>threshold(1):"
+ threshold(1) + "</h3>");
document.write("<h3>threshold(3):"
+ threshold(3) + "</h3>");
// Making changes on the original scale
threshold.range([100, 200, 300, 400, 500]);
document.write(
"<p> After making changes in the original scale</p>");
document.write("<h3>threshold(3):"
+ threshold(3) + "</h3>");
document.write("<p> This is from copy scale.</p>");
document.write("<h3>thresholdCopy(1):"
+ thresholdCopy(1) + "</h3>");
document.write("<h3>thresholdCopy(3):"
+ thresholdCopy(3) + "</h3></div>");
</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.copy() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。