Data visualization with D3 -- Use Dynamic Scales

I am going through the D3 tutorial and I am a total novice on D3. I am a little frustrated. I cannot console.log out anything. I cannot tell if my code produce the results as specified by the tests except to run the test. I can’t see the range. I can’t see anyting. I don’t feel that there are enough exercises in D3 to fully understand the topic. I am near the end of the 29 courses listed and I am not clear on anything. This is frustrating.

Help us help you. You need to link to the project and show us the code you’ve tried so that we can debug.

As far as logging, anywhere you can use a callback to return a value, you can log. The example code for the exercise is

const xScale = d3.scaleLinear()
  .domain([0, d3.max(dataset, (d) => d[0])])
  .range([padding, w - padding]);

If you want to log from the callback in d3.max(), change the callback:

const xScale = d3.scaleLinear()
  .domain([0, d3.max(dataset, (d) => {
    console.log(d);
    return d[0];
  })])
  .range([padding, w - padding]);

I agree that the course is lacking. When you are trying to use console.log in the the stringed together methods you need to use a call back function with a return value. You would put your console.log in the callback before the return.

I found the following two sites very helpful to learn d3…

Using d3

d3

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.