简体   繁体   中英

C3js and D3js Error: Invalid value for <g> attribute transform=“translate(0,NaN)”

I'm trying to create a bunch of panels with d3js and then trying to fill those panels with graphs using C3js. For some reason, I keep getting:

Error: Invalid value for <g> attribute transform="translate(0,NaN)"

When I hardcode the panels, it works just fine. Here is some example code that shows the error: https://jsfiddle.net/tgp9gqfb/2/

Any direction on what I'm doing wrong?

Instead of doing it with setting data and making divs:

d3.select("#page-wrapper").selectAll("div")
            .data(order_labels["a"]);

Do the same with a for loop:

  order_labels["a"].forEach(function(d) {
    new_panels = d3.select("#page-wrapper").append('div').attr('class', "panel panel-default");
    new_panels.append('div').attr('class', "panel-heading").text(function() {
      return readable_lables[d];
    });
    new_panels.append('div').attr('class', "panel-body").append('div').attr("id", function() {
      return d + "graph_wrapper";
    });
    new_panels.append('div').attr('class', "panel-footer");
  });

I agree the way you doing is correct but the internal c3 error is because of the data in the div that is the reason why i am asking you to do the same with the for loop.

Working code here

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM