不同的尺度与连续尺度非常相似。唯一的区别是此标度的输出范围由内插器固定,因此该范围不可配置。
d3.js中的diverging.copy()函数用于构造并返回原始比例的精确副本。原始比例的任何更改都不会影响复印比例,反之亦然。
用法:
diverging.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.v6.min.js">
</script>
</head>
<style>
</style>
<body>
<h2 style="color:green"> GeeksforGeeks </h2>
<h4> D3.js | diverging.copy() Function </h4>
<script>
var diverging =
d3.scaleDiverging(d3.interpolateSpectral);
// Default domain is used i.e [0, 1]
document.write(
"<b>From original scale:</b>");
document.write(
"<p>diverging(0.1):", diverging(0.1) + "</p>");
document.write(
"<p>diverging(0.2):", diverging(0.2) + "</p>");
document.write(
"<p>diverging(0.3):", diverging(0.3) + "</p>");
document.write("<b>From copy scale:</b>");
var divergingCopy = diverging.copy();
document.write(
"<p>divergingCopy(0.1):", divergingCopy(0.1) + "</p>");
document.write(
"<p>divergingCopy(0.2):", divergingCopy(0.2) + "</p>");
document.write(
"<p>divergingCopy(0.3):", divergingCopy(0.3) + "</p>");
</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.v6.min.js"></script>
</head>
<style>
</style>
<body>
<h2 style="color:green"> GeeksforGeeks </h2>
<h4> D3.js | diverging.copy() Function </h4>
<script>
var diverging =
d3.scaleDiverging(d3.interpolateSpectral);
// Default domain is used i.e [0, 1]
document.write(
"<b>From original scale:</b>");
document.write(
"<p>diverging(0.1):", diverging(0.1) + "</p>");
document.write(
"<p>diverging(0.2):", diverging(0.2) + "</p>");
document.write(
"<b>Change in copy scale does not"+
" effect original scale:</b>");
var divergingCopy = diverging.copy();
// Domain is changed to [10, 100]
divergingCopy.domain([10, 100])
document.write(
"<p>divergingCopy(0.1):", divergingCopy(0.1) + "</p>");
document.write(
"<p>divergingCopy(0.2):", divergingCopy(0.2) + "</p>");
</script>
</body>
</html>
输出:
相关用法
- PHP imagecreatetruecolor()用法及代码示例
- p5.js year()用法及代码示例
- d3.js d3.utcTuesdays()用法及代码示例
- PHP ImagickDraw getTextAlignment()用法及代码示例
- PHP Ds\Sequence last()用法及代码示例
- PHP array_udiff_uassoc()用法及代码示例
- PHP geoip_continent_code_by_name()用法及代码示例
- d3.js d3.map.set()用法及代码示例
- PHP GmagickPixel setcolor()用法及代码示例
- PHP opendir()用法及代码示例
- PHP cal_to_jd()用法及代码示例
- d3.js d3.bisectLeft()用法及代码示例
- PHP stream_get_transports()用法及代码示例
- PHP Ds\Deque pop()用法及代码示例
注:本文由纯净天空筛选整理自tarun007大神的英文原创作品 D3.js diverging.copy() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。