<!DOCTYPE html>
<
html
>
<
head
>
</
script
>
</
script
>
<
script
src
=
</
script
>
<
script
src
=
</
script
>
<
style
>
div {
width: 200px;
height: 40px;
text-align: center;
background-color: rgb(100, 150, 200);
}
</
style
>
</
head
>
<
body
>
<
h1
style
=
"color: green"
>
GeeksforGeeks
</
h1
>
<
p
>time.interpolate() Function </
p
>
<
div
class
=
"b1"
>time(4.5)</
div
>
<
div
class
=
"b2"
>time(40)</
div
>
<
div
class
=
"b3"
>time(11.5)</
div
>
<
div
class
=
"b4"
>time(99.5)</
div
>
<
script
>
var time = d3.scaleTime()
// Setting domain and range
// for the scale
.domain([0, 100])
.range(["blue", "yellow", "green"])
// Using the specified interpolation
.interpolate(
d3.interpolateCubehelix.gamma(0.5)
);
var color1 = time(4.5);
var color2 = time(40);
var color3 = time(11.5);
var color4 = time(99.5);
var div1 = document.querySelector(".b1")
.style.backgroundColor = color1;
var div2 = document.querySelector(".b2")
.style.backgroundColor = color2;
var div3 = document.querySelector(".b3")
.style.backgroundColor = color3;
var div4 = document.querySelector(".b4")
.style.backgroundColor = color4;
</
script
>
</
body
>
</
html
>