Dear all, I’m drawing a very simple bar graph, as Two bar chart, the original design was: 2 exactly same grey bars parallel to the x-axis, 2 bars means two species in the data file. However, currently I can only make one bar showing here, could you please tell me where should I correct to let the second one showing right below the first bar?
Here’s the bit of code where you lay down the bars:
.join("rect") .attr('class', 'bar') .attr("fill", "#F0F0F0") // color, grey .attr("x", d => x(d.Pmax)) .attr("y", d => y(d.species)) .attr("x", margin.left) // adjust the location of bars .attr("y", height/4) // <------ Delete this! .attr("width", d => x(d.Pmax)) .attr("height", y.bandwidth())
Note that you’ve defined the
y attribute twice and the second (bad) definition overwrites the first good one. Just delete that second line as indicated.
Thank you very much professor!