D3.js中的sequence.copy()函數用於構造並返回原始比例的副本。原始比例的任何更改都不會影響複印比例,反之亦然。順序刻度類似於連續刻度。在連續範圍內,域和範圍之間的映射是連續進行的。唯一的區別是此標度的輸出範圍由其內插器固定,並且該範圍無法更改。
用法:
sequential.copy()
參數:該函數不接受任何參數。
返回值:此函數返回原始比例的副本。
下麵給出了D3.js中sequence.copy()的一些示例:
範例1:
HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://d3js.org/d3.v6.min.js">
</script>
</head>
<body>
<h2 style="color:green">
GeeksforGeeks
</h2>
<h4> D3.js | sequential.copy() Function </h4>
<script>
var sequential = d3.scaleSequential();
// Default scale is identity function
document.write("<h4>From original scale:</h4>")
document.write("<p>sequential(0.2):",
sequential(0.2) + "</p>");
document.write("<p>sequential(0.5):",
sequential(0.5) + "</p>");
// Creating copy of the original scale
var sequentialCopy = sequential.copy();
document.write("<h4>From copy scale:</h4>")
document.write("<p>sequentialCopy(0.2):",
sequentialCopy(0.2) + "</p>");
document.write("<p>sequentialCopy(0.5):",
sequentialCopy(0.5) + "</p>");
</script>
</body>
</html>
輸出:
範例2:複印比例的任何更改都不會影響原始比例。
HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://d3js.org/d3.v6.min.js">
</script>
</head>
<body>
<h2 style="color:green">
GeeksforGeeks
</h2>
<h4> D3.js | sequential.copy() Function </h4>
<script>
var sequential = d3.scaleSequential();
// Default scale is identity function
document.write("<h4>From original scale:</h4>");
document.write("<p>sequential(0.4):",
sequential(0.4) + "</p>");
document.write("<p>sequential(0.6):",
sequential(0.6) + "</p>");
// Creating copy of the original scale
var sequentialCopy = sequential.copy();
sequentialCopy.domain([1, 2]);
document.write(
"<h4>From copy scale after changing domain:</h4>");
document.write("<p>sequentialCopy(0.4):",
sequentialCopy(0.4) + "</p>");
document.write("<p>sequentialCopy(0.6):",
sequentialCopy(0.6) + "</p>");
</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 sequential.copy() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。