point.copy()函數用於構造並返回當前刻度的副本。對這兩個比例進行的任何更改都是相互獨立的,即,複製比例的更改不會影響原始比例,反之亦然。
用法:
point.copy();
參數:此函數不接受任何參數。
返回值:此函數返回當前刻度的副本。返回類型是一個函數。
下麵給出的是上麵給出的函數的一些例子。
範例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>
<body>
<script>
// Creating the point scale with specified domain and range.
var point = d3.scalePoint()
.domain([1, 2, 3, 4])
.range([1, 5]);
var copyScale = point.copy();
console.log("From original scale:");
console.log("point(1):", point(1));
console.log("point(2):", point(2));
console.log("From copy scale:");
console.log("copyScale(1):", copyScale(1));
console.log("copyScale(2):", copyScale(2));
</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>
<body>
<script>
// Creating the point scale with specified domain and range.
var point = d3.scalePoint()
.domain([1, 2, 3, 4])
.range([1, 5]);
console.log("From original scale befire making changes:");
console.log("point(1):", point(1));
console.log("point(2):", point(2));
// Making copy of the original scale
var copyScale = point.copy();
point.round([1, 5]);
console.log("From original scale after making changes:");
console.log("point(1):", point(1));
console.log("point(2):", point(2));
console.log("From copy scale:");
// Changes in original scale does not
// Affect copy scale
console.log("copyScale(1):", copyScale(1));
console.log("copyScale(2):", copyScale(2));
</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 point.copy() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。