color opacitiy based on value

18 views
Skip to first unread message

Dev C

unread,
Mar 8, 2021, 2:23:03 AM3/8/21
to d3...@googlegroups.com
In my D3jS 5 I am using color opacity based on blue color but sometime values like 0 and 1, I can not see much difference, here is the code I have.

.append("rect")
.attr("x", (d) => this.xScale(d.day))
.attr("y", (d) => this.yScale(d.time))
.attr("width", this.xScale.bandwidth())
.attr("height", this.yScale.bandwidth())
.on("mouseover", this.mouseOverHandler)
.on("mouseleave", this.mouseLeaveHandler)
.style("fill", "white")
.transition(t)
.delay((d, i) => i * 20)
.style("fill", (d) => this.colorRange(d.value));


and defined colorRange:{} and assigned as below:

this.colorRange = d3
.scaleLinear()
.range(["#B7C0FC", "#216BFF"])
.domain([1, 1000]);
},

Anybody can help me on what basis color can be differentiated if values are like 0 and 1
Reply all
Reply to author
Forward
0 new messages