Created
July 29, 2020 22:45
-
-
Save zaynaib/ccf64423e1f1eacef2508f7b29664a19 to your computer and use it in GitHub Desktop.
Broken example of bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const barRect = wrapper.append("g") | |
.selectAll('rect') | |
.data(types) | |
.join('rect') | |
// xScale takes the type, returns the left/right location | |
.attr("x", d => xScale(d)) | |
// yScale gets the count from the object | |
.attr("y", d => yScale(byType[d].length)) | |
.attr("width", xScale.bandwidth()) | |
// height has to be the distance from bar top to chart bottom | |
.attr("height", d=> dimensions.boundedHeight - yScale(byType[d].length)) | |
.attr("fill","teal") | |
.append("text") | |
.attr("x", d => xScale(d)) | |
// yScale gets the count from the object | |
.attr("y", d => yScale(byType[d].length-5)) | |
.text("hello") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const barRect = wrapper.append("g") | |
.selectAll('rect') | |
.data(types) | |
.join('rect') | |
// xScale takes the type, returns the left/right location | |
.attr("x", d => xScale(d)) | |
// yScale gets the count from the object | |
.attr("y", d => yScale(byType[d].length)) | |
.attr("width", xScale.bandwidth()) | |
// height has to be the distance from bar top to chart bottom | |
.attr("height", d=> dimensions.boundedHeight - yScale(byType[d].length)) | |
.attr("fill","teal") | |
wrapper.append("g").selectAll("text") | |
.data(types) | |
.join("text") | |
.attr("x", d=>xScale(d)) | |
.attr("y", d => yScale(byType[d].length)) | |
.text(d => byType[d].length) | |
.attr('fill','purple') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment