Freecodecamp: [beta] test conflicts with challenge requirement.

Created on 29 Jan 2017  路  7Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge add-labels-to-scatter-plot-circles has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

This instruction:

Set the x attribute so it's 5 units more than the value you used for the cx attribute on the circle.

seems to be in conflict with the second test case:

The first label should have text of "34, 78", an x value of 34, and a y value of 422.

With the above instruction, shouldn't the value of the x attribute for the text element be 39 and not 34 as the test case states? This is the output received following the above instructions on the developer console:

screen shot 2017-01-29 at 04 50 49

Here is the current code used:


<body>
<script>
  const dataset = [
                [ 34,    78 ],
                [ 109,   280 ],
                [ 310,   120 ],
                [ 79,    411 ],
                [ 420,   220 ],
                [ 233,   145 ],
                [ 333,   96 ],
                [ 222,   333 ],
                [ 78,    320 ],
                [ 21,    123 ]
              ];


  const w = 500;
  const h = 500;

  const svg = d3.select("body")
                .append("svg")
                .attr("width", w)
                .attr("height", h);

  svg.selectAll("circle")
     .data(dataset)
     .enter()
     .append("circle")
     .attr("cx", (d, i) => d[0])
     .attr("cy", (d, i) => h - d[1])
     .attr("r", 5);

  svg.selectAll("text")
     .data(dataset)
     .enter()
     .append("text")
     // Add your code below this line
     .attr("x", (d, i) => d[0] + 5)
     .attr("y", (d, i) => h - d[1])
     .text(d => d[0] + ", " + d[1]);


     // Add your code above this line
</script>
</body>

The code above still passes the challenge regardless of the stated above reasons.

help wanted

All 7 comments

@cdrainxv thanks for the issue. I think what the tests are saying is that "34, 78" is merely indicating x- and y-values respectively, not actual x- and y-values. But then again, this does seem confusing.

I would be for changing all the tests to reflect their actual x and y coordinates. So the second tests should be changed to

The first label should have text of "34, 78", an x value of 39, and a y value of 422.

cc/ @freeCodeCamp/moderators

Yes, the "34, 78" does indicate the text for the label of the first circle based on the dataset array, but the actual x-value to which I was alluding (and hopefully the challenge requirements was as well) was the x-coordinate for the _positioning_ of the text element. An x-value of 39 for the text element x attribute would place the label "34, 78" 5 units to the right of the circle data points. This should result in the following text element:
<text x="39" y="422">34, 78</text>, which would satisfy the fix you suggested. Thanks!

@cdrainxv - yes, good catch on that test! The x-value used to position the text should be 39, not 34 and @erictleung your suggestion will fix this test message. I just went through the other tests and it looks like they are using the correct numbers, so I think it's just this second test that needs to be fixed.

Can I take this up?

@Manish-Giri go for it!

@erictleung Just saw in chat that @cdrainxv was doing the PR when I posted. So I'll wait for another 'help wanted' issue.

@Manish-Giri: It seems that I can't setup a local instance of the fcc repo on my machine. Please feel free to take up this issue. I'll pursue another one as soon as I resolve my own issues. Thanks!

Was this page helpful?
0 / 5 - 0 ratings