Git Product home page Git Product logo

Comments (3)

ssp3nc3r avatar ssp3nc3r commented on July 24, 2024 2

Yes, your example does write "test" to the console. But if the output is not text, then it just has a generic return. To see this, let's simplify your code above:

// !preview r2d3 data=c(0.3, 0.6, 0.8, 0.95, 0.40, 0.20)
//
// r2d3: https://rstudio.github.io/r2d3
//

var mysvg = svg.selectAll('rect').data(data);
console.log(mysvg);

which only sends the console,

[object Object]

I cross-posted on stack overflow, and someone posted the following workaround: including,

console = d3.window(svg.node()).console;

as the first line of the javascript gives an inspectable object, where you can expand its hierarchy like so,

Screen Shot 2019-04-17 at 3 39 37 PM

Being able to inspect the actual objects like this can be very useful.

from r2d3.

javierluraschi avatar javierluraschi commented on July 24, 2024

This should work correctly, console.log() gets printed to the browser console and also in the actual visualization.

For instance, consider the following example, notice the console.log() statement:

// !preview r2d3 data=c(0.3, 0.6, 0.8, 0.95, 0.40, 0.20)
//
// r2d3: https://rstudio.github.io/r2d3
//

var barHeight = Math.ceil(height / data.length);

svg.selectAll('rect')
  .data(data)
  .enter().append('rect')
    .attr('width', function(d) { 
      console.log("test");
      return d * width;
    })
    .attr('height', barHeight)
    .attr('y', function(d, i) { return i * barHeight; })
    .attr('fill', 'steelblue');

This code triggers both, an update in the console and the visualization, notice the test message:

r2d3-console-log

Could you perhaps provide the sources of your visualization since is probably specific to that particular code or environment?

from r2d3.

shmoss avatar shmoss commented on July 24, 2024

Did this bug ever get fixed? This issue is kind of a deal-breaker for being able to effectively use r2d3. I've documented the issue here, if it's helpful:

https://stackoverflow.com/questions/69859445/de-bugging-r2d3-r-in-inspector-cant-view-data-in-console

Thank you!

from r2d3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.