D3.js pow.range() Function
source link: https://www.geeksforgeeks.org/d3-js-pow-range-function/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
D3.js pow.range() Function
Last Updated: 23-08-2020The pow.range() function in d3.js is used to set the scale’s range to the specified array of values that must contain two or more than two values. The elements in the range can be number or string.
Syntax:
pow.range([range]);
Parameters: This function takes a single parameter that is given above and described below.
- [range]: This is an array that contains the range for the domain specified.
Return Values: This function does not return any value.
Example 1:
filter_none
edit
close
play_arrow
link
brightness_4
code
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
/>
<
meta
name
=
"viewport"
path1tent
=
"width=device-width,initial-scale=1.0"
/>
</
script
>
</
head
>
<
body
>
<
script
>
var pow = d3.scalePow()
// Setting domain for the scale.
.domain([-10, 10])
// Range of numbers
.range([10, 20, 30, 40, 50, 60])
.exponent(2);
console.log("The range of this is "
+ "[10,20,30,40,50,60]: ");
console.log("pow(-4): " + pow(-4));
console.log("pow(4): " + pow(4));
console.log("pow(2.4): " + pow(2.4));
</
script
>
</
body
>
</
html
>
Output:
Example 2:
filter_none
edit
close
play_arrow
link
brightness_4
code
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
/>
<
meta
name
=
"viewport"
path1tent
=
"width=device-width,initial-scale=1.0"
/>
</
script
>
</
head
>
<
body
>
<
script
>
var pow = d3.scalePow()
// Setting domain for the scale.
.domain([-10, 10])
// Range of colors
.range(["red", "blue", "green", "white"])
.exponent(2);
console.log("The range of this is"
+ " [red,blue,green,white]: ");
console.log("pow(-4): " + pow(-4));
console.log("pow(4): " + pow(4));
console.log("pow(2.4): " + pow(2.4));
</
script
>
</
body
>
</
html
>
Output:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to [email protected]. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Be the First to upvote.
No votes yet.
first_page D3.js selection.text() Function last_page D3.js schemeOrRd[] Function
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK