D3.js中的d3.scaleQuantile()的quantile()函數用於返回對應於給定輸入值的範圍內的值。此輸入值位於指定的域中。
用法:
quantile( value )
參數:此函數接受上麵給定並在下麵描述的單個參數:
- value:它采用位於域中的數值。
返回值:此函數返回對應於指定範圍的值。
以下示例程序旨在說明D3.js中的quantile()函數:
例:
HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://d3js.org/d3.v4.min.js">
</script>
<script src="https://d3js.org/d3-color.v1.min.js">
</script>
<script src=
"https://d3js.org/d3-interpolate.v1.min.js">
</script>
<script src=
"https://d3js.org/d3-scale-chromatic.v1.min.js">
</script>
</head>
<body>
<h1 style="color:green">GeeksforGeeks</h1>
<p>d3.scaleQuantile | quantile() Function </p>
<script>
var quantile = d3.scaleQuantile()
// Setting domain and range
// for the scale
.domain([1, 10])
.range([0, 960]);
// Printing the output using the
// quantile() function
document.write(
"<h3>" + quantile(1) + "</h3>");
document.write(
"<h3>" + quantile(5) + "</h3>");
document.write(
"<h3>" + quantile(9) + "</h3>");
document.write(
"<h3>" + quantile(10) + "</h3>");
</script>
</body>
</html>
輸出:
相關用法
- d3.js scaleQuantile()用法及代碼示例
- d3.js d3.quantile()用法及代碼示例
- d3.js quantile.invertExtent()用法及代碼示例
- d3.js quantile.copy()用法及代碼示例
- d3.js quantile.range()用法及代碼示例
- d3.js quantile.domain()用法及代碼示例
- 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()用法及代碼示例
注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 D3.js scaleQuantile quantile() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。