Data Visualization: Bar Chart Project -- failing 3 tests

Hey all, this is my first Forum post. Please let me know if I’m putting my code in the wrong place or making any other embarrassing noob errors.

It looks to me as if I’ve met the constraints for the Data Visualization: Bar Chart project, but I can’t pass three of the tests: x-axis alignment of the bars, and the two tooltip tests (User Stories #10, 12, & 13). What am I missing?

Here’s a link to my project with the test suite included.

And here’s my code. Thanks in advance!

d3.json("").then(function(dataset) {
  const h = 400;
  const w = 800;
  const padding = 50;
  const barWidth = w/;
  var msDatesData ={
    return i[0];
  var datesData ={
    return new Date(i[0]);
  var numbersData ={
    return i[1];
  var minDate = new Date(d3.min(datesData));
  var maxDate = new Date(d3.max(datesData));
  maxDate.setMonth(maxDate.getMonth() + 3);
  const xScale = d3.scaleTime().domain([minDate,maxDate])
                                 .range([padding, w-padding]);
  const yScale = d3.scaleLinear().domain([0,d3.max(numbersData)])
                                 .range([h-padding, padding]);
  const xAxis = d3.axisBottom(xScale);
  const yAxis = d3.axisLeft(yScale);

  const svg ="body")
  svg.append("g").attr("transform", "translate(0, " + (h-padding) + ")")
     .append("g").attr("transform", 'translate('+padding+', '+(padding-h)+')')

                    .text((d)=>'$'+d[1]+' BILLION');

I figured out the x-axis problem:
I was appending the y-axis to the x-axis rather than to the svg element.

The tooltip problem is still unsolved.

I think the problem with the tooltip code was that there is a requirement to have the pop-up text appear immediately after the mouse is over the shape, rather than fading in. The lessons only teach you the fade-in method. The other method is more complex, and I had to copy most of the code from the example. I understand it now, but I was hoping to be able to figure how to do it on my own from online manuals without looking at the example code. Nope!

1 Like