D3.js issue in React.js Project












0















I'm facing an issue in my react.js web app. I am using import * as d3 from 'd3' to import everything and save it to d3 namespace but getting an error called - Cannot read property 'stack' of undefined. Any help regarding the issue ?



Click here to see the => Demo



I tried installing d3-shape and using import * as stack from 'd3-shape' and import stack from 'd3-shape' - both the things and getting the same problem again.



Here's my code:



import React, { Component } from "react";
import * as d3 from "d3";
// import d3 from "d3-shape";
// import d3 from "d3";
// import * as stack from 'd3-shape';
import "d3-tip";
import { render } from 'react-dom';
import barData from "./JSON/barData.jsx";

class App extends Component {
componentDidMount() {
console.log("componentDidMount", this.props.id);
console.log(barData);
var margin = { top: 20, right: 160, bottom: 35, left: 0 };

var width = 500 - margin.left - margin.right,
height = 162 - margin.top - margin.bottom;

var svg = d3
.select("#dashboard_bar_graph_101")
.append("svg")
.attr("width", width)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr(
"transform",
"translate(" + margin.left + "," + margin.top + ")"
);

/* Data in strings like it would be if imported from a csv */

var data = barData;

//var parse = d3.time.format("%Y").parse;

// Transpose the data into layers
var dataset = d3.layout.stack()(
["view"].map(function(fruit) {
return data.map(function(d) {
return { x: d.year, y: +d[fruit] };
});
})
);

// Set x, y and colors
var x = d3.scale
.ordinal()
.domain(
dataset[0].map(function(d) {
return d.x;
})
)
.rangeRoundBands([10, width - 10], 0.02);

var y = d3.scale
.linear()
.domain([
0,
d3.max(dataset, function(d) {
return d3.max(d, function(d) {
return d.y0 + d.y;
});
})
])
.range([height, 0]);

var colors = ["#39d9F3"];

// Define and draw axes
var yAxis = d3.svg
.axis()
.scale(y)
.orient("left")
.ticks(5)
.tickSize(-width, 0, 0)
.tickFormat(function(d) {
return d;
});

var xAxis = d3.svg
.axis()
.scale(x)
.orient("bottom")
.tickFormat(data.year);

svg
.append("g")
.attr("class", "y axis")
.call(yAxis);

svg
.append("g")
.attr("class", "x axis legend_texts_two")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);

// Create groups for each series, rects for each segment
var groups = svg
.selectAll("g.cost")
.data(dataset)
.enter()
.append("g")
.attr("class", "cost")
.style("fill", function(d, i) {
return colors[i];
});

var rect = groups
.selectAll("rect")
.data(function(d) {
return d;
})
.enter()
.append("rect")
.attr("x", function(d) {
return x(d.x);
})
.attr("y", function(d) {
return y(d.y0 + d.y);
})
.attr("height", function(d) {
return y(d.y0) - y(d.y0 + d.y);
})
.attr("width", "20px")
.on("mouseover", function() {
tooltip.style("display", null);
})
.on("mouseout", function() {
tooltip.style("display", "none");
})
.on("mousemove", function(d) {
var xPosition = d3.mouse(this)[0] - 15;
var yPosition = d3.mouse(this)[1] - 25;
tooltip.attr(
"transform",
"translate(" + xPosition + "," + yPosition + ")"
);
tooltip.select("text").text(d.y);
})
.style("fill", function(d, i) {
return colors[i];
});

// Draw legend
/*var legend = svg
.selectAll(".legend")
.data(colors)
.enter()
.append("g")
.attr("class", "legend")
.attr("transform", function(d, i) {
return "translate(30," + i * 19 + ")";
});

legend
.append("rect")
.attr("x", width - 18)
.attr("width", 18)
.attr("height", 18)
.style("fill", function(d, i) {
return colors.slice().reverse()[i];
});

legend
.append("text")
.attr("x", width + 5)
.attr("y", 9)
.attr("dy", ".35em")
.style("text-anchor", "start")
.text(function(d, i) {
switch (i) {
case 0:
return "View";
case 0:
return "View";
case 2:
return "Click";
}
});*/

// Prep the tooltip bits, initial display is hidden
var tooltip = svg
.append("g")
.attr("class", "tooltip")
.style("display", "none");

tooltip
.append("rect")
.attr("width", 30)
.attr("height", 20)
.attr("fill", "white")
.style("opacity", 0.5);

tooltip
.append("text")
.attr("x", 15)
.attr("dy", "1.0em")
.style("text-anchor", "middle")
.attr("font-size", "12px")
.attr("font-weight", "bold");
}

render() {
return (
<div id="dashboard_bar_graph_101" style={{ textAlign: "center" }} />
);
}
}

render(<App />, document.getElementById('root'));









share|improve this question





























    0















    I'm facing an issue in my react.js web app. I am using import * as d3 from 'd3' to import everything and save it to d3 namespace but getting an error called - Cannot read property 'stack' of undefined. Any help regarding the issue ?



    Click here to see the => Demo



    I tried installing d3-shape and using import * as stack from 'd3-shape' and import stack from 'd3-shape' - both the things and getting the same problem again.



    Here's my code:



    import React, { Component } from "react";
    import * as d3 from "d3";
    // import d3 from "d3-shape";
    // import d3 from "d3";
    // import * as stack from 'd3-shape';
    import "d3-tip";
    import { render } from 'react-dom';
    import barData from "./JSON/barData.jsx";

    class App extends Component {
    componentDidMount() {
    console.log("componentDidMount", this.props.id);
    console.log(barData);
    var margin = { top: 20, right: 160, bottom: 35, left: 0 };

    var width = 500 - margin.left - margin.right,
    height = 162 - margin.top - margin.bottom;

    var svg = d3
    .select("#dashboard_bar_graph_101")
    .append("svg")
    .attr("width", width)
    .attr("height", height + margin.top + margin.bottom)
    .append("g")
    .attr(
    "transform",
    "translate(" + margin.left + "," + margin.top + ")"
    );

    /* Data in strings like it would be if imported from a csv */

    var data = barData;

    //var parse = d3.time.format("%Y").parse;

    // Transpose the data into layers
    var dataset = d3.layout.stack()(
    ["view"].map(function(fruit) {
    return data.map(function(d) {
    return { x: d.year, y: +d[fruit] };
    });
    })
    );

    // Set x, y and colors
    var x = d3.scale
    .ordinal()
    .domain(
    dataset[0].map(function(d) {
    return d.x;
    })
    )
    .rangeRoundBands([10, width - 10], 0.02);

    var y = d3.scale
    .linear()
    .domain([
    0,
    d3.max(dataset, function(d) {
    return d3.max(d, function(d) {
    return d.y0 + d.y;
    });
    })
    ])
    .range([height, 0]);

    var colors = ["#39d9F3"];

    // Define and draw axes
    var yAxis = d3.svg
    .axis()
    .scale(y)
    .orient("left")
    .ticks(5)
    .tickSize(-width, 0, 0)
    .tickFormat(function(d) {
    return d;
    });

    var xAxis = d3.svg
    .axis()
    .scale(x)
    .orient("bottom")
    .tickFormat(data.year);

    svg
    .append("g")
    .attr("class", "y axis")
    .call(yAxis);

    svg
    .append("g")
    .attr("class", "x axis legend_texts_two")
    .attr("transform", "translate(0," + height + ")")
    .call(xAxis);

    // Create groups for each series, rects for each segment
    var groups = svg
    .selectAll("g.cost")
    .data(dataset)
    .enter()
    .append("g")
    .attr("class", "cost")
    .style("fill", function(d, i) {
    return colors[i];
    });

    var rect = groups
    .selectAll("rect")
    .data(function(d) {
    return d;
    })
    .enter()
    .append("rect")
    .attr("x", function(d) {
    return x(d.x);
    })
    .attr("y", function(d) {
    return y(d.y0 + d.y);
    })
    .attr("height", function(d) {
    return y(d.y0) - y(d.y0 + d.y);
    })
    .attr("width", "20px")
    .on("mouseover", function() {
    tooltip.style("display", null);
    })
    .on("mouseout", function() {
    tooltip.style("display", "none");
    })
    .on("mousemove", function(d) {
    var xPosition = d3.mouse(this)[0] - 15;
    var yPosition = d3.mouse(this)[1] - 25;
    tooltip.attr(
    "transform",
    "translate(" + xPosition + "," + yPosition + ")"
    );
    tooltip.select("text").text(d.y);
    })
    .style("fill", function(d, i) {
    return colors[i];
    });

    // Draw legend
    /*var legend = svg
    .selectAll(".legend")
    .data(colors)
    .enter()
    .append("g")
    .attr("class", "legend")
    .attr("transform", function(d, i) {
    return "translate(30," + i * 19 + ")";
    });

    legend
    .append("rect")
    .attr("x", width - 18)
    .attr("width", 18)
    .attr("height", 18)
    .style("fill", function(d, i) {
    return colors.slice().reverse()[i];
    });

    legend
    .append("text")
    .attr("x", width + 5)
    .attr("y", 9)
    .attr("dy", ".35em")
    .style("text-anchor", "start")
    .text(function(d, i) {
    switch (i) {
    case 0:
    return "View";
    case 0:
    return "View";
    case 2:
    return "Click";
    }
    });*/

    // Prep the tooltip bits, initial display is hidden
    var tooltip = svg
    .append("g")
    .attr("class", "tooltip")
    .style("display", "none");

    tooltip
    .append("rect")
    .attr("width", 30)
    .attr("height", 20)
    .attr("fill", "white")
    .style("opacity", 0.5);

    tooltip
    .append("text")
    .attr("x", 15)
    .attr("dy", "1.0em")
    .style("text-anchor", "middle")
    .attr("font-size", "12px")
    .attr("font-weight", "bold");
    }

    render() {
    return (
    <div id="dashboard_bar_graph_101" style={{ textAlign: "center" }} />
    );
    }
    }

    render(<App />, document.getElementById('root'));









    share|improve this question



























      0












      0








      0








      I'm facing an issue in my react.js web app. I am using import * as d3 from 'd3' to import everything and save it to d3 namespace but getting an error called - Cannot read property 'stack' of undefined. Any help regarding the issue ?



      Click here to see the => Demo



      I tried installing d3-shape and using import * as stack from 'd3-shape' and import stack from 'd3-shape' - both the things and getting the same problem again.



      Here's my code:



      import React, { Component } from "react";
      import * as d3 from "d3";
      // import d3 from "d3-shape";
      // import d3 from "d3";
      // import * as stack from 'd3-shape';
      import "d3-tip";
      import { render } from 'react-dom';
      import barData from "./JSON/barData.jsx";

      class App extends Component {
      componentDidMount() {
      console.log("componentDidMount", this.props.id);
      console.log(barData);
      var margin = { top: 20, right: 160, bottom: 35, left: 0 };

      var width = 500 - margin.left - margin.right,
      height = 162 - margin.top - margin.bottom;

      var svg = d3
      .select("#dashboard_bar_graph_101")
      .append("svg")
      .attr("width", width)
      .attr("height", height + margin.top + margin.bottom)
      .append("g")
      .attr(
      "transform",
      "translate(" + margin.left + "," + margin.top + ")"
      );

      /* Data in strings like it would be if imported from a csv */

      var data = barData;

      //var parse = d3.time.format("%Y").parse;

      // Transpose the data into layers
      var dataset = d3.layout.stack()(
      ["view"].map(function(fruit) {
      return data.map(function(d) {
      return { x: d.year, y: +d[fruit] };
      });
      })
      );

      // Set x, y and colors
      var x = d3.scale
      .ordinal()
      .domain(
      dataset[0].map(function(d) {
      return d.x;
      })
      )
      .rangeRoundBands([10, width - 10], 0.02);

      var y = d3.scale
      .linear()
      .domain([
      0,
      d3.max(dataset, function(d) {
      return d3.max(d, function(d) {
      return d.y0 + d.y;
      });
      })
      ])
      .range([height, 0]);

      var colors = ["#39d9F3"];

      // Define and draw axes
      var yAxis = d3.svg
      .axis()
      .scale(y)
      .orient("left")
      .ticks(5)
      .tickSize(-width, 0, 0)
      .tickFormat(function(d) {
      return d;
      });

      var xAxis = d3.svg
      .axis()
      .scale(x)
      .orient("bottom")
      .tickFormat(data.year);

      svg
      .append("g")
      .attr("class", "y axis")
      .call(yAxis);

      svg
      .append("g")
      .attr("class", "x axis legend_texts_two")
      .attr("transform", "translate(0," + height + ")")
      .call(xAxis);

      // Create groups for each series, rects for each segment
      var groups = svg
      .selectAll("g.cost")
      .data(dataset)
      .enter()
      .append("g")
      .attr("class", "cost")
      .style("fill", function(d, i) {
      return colors[i];
      });

      var rect = groups
      .selectAll("rect")
      .data(function(d) {
      return d;
      })
      .enter()
      .append("rect")
      .attr("x", function(d) {
      return x(d.x);
      })
      .attr("y", function(d) {
      return y(d.y0 + d.y);
      })
      .attr("height", function(d) {
      return y(d.y0) - y(d.y0 + d.y);
      })
      .attr("width", "20px")
      .on("mouseover", function() {
      tooltip.style("display", null);
      })
      .on("mouseout", function() {
      tooltip.style("display", "none");
      })
      .on("mousemove", function(d) {
      var xPosition = d3.mouse(this)[0] - 15;
      var yPosition = d3.mouse(this)[1] - 25;
      tooltip.attr(
      "transform",
      "translate(" + xPosition + "," + yPosition + ")"
      );
      tooltip.select("text").text(d.y);
      })
      .style("fill", function(d, i) {
      return colors[i];
      });

      // Draw legend
      /*var legend = svg
      .selectAll(".legend")
      .data(colors)
      .enter()
      .append("g")
      .attr("class", "legend")
      .attr("transform", function(d, i) {
      return "translate(30," + i * 19 + ")";
      });

      legend
      .append("rect")
      .attr("x", width - 18)
      .attr("width", 18)
      .attr("height", 18)
      .style("fill", function(d, i) {
      return colors.slice().reverse()[i];
      });

      legend
      .append("text")
      .attr("x", width + 5)
      .attr("y", 9)
      .attr("dy", ".35em")
      .style("text-anchor", "start")
      .text(function(d, i) {
      switch (i) {
      case 0:
      return "View";
      case 0:
      return "View";
      case 2:
      return "Click";
      }
      });*/

      // Prep the tooltip bits, initial display is hidden
      var tooltip = svg
      .append("g")
      .attr("class", "tooltip")
      .style("display", "none");

      tooltip
      .append("rect")
      .attr("width", 30)
      .attr("height", 20)
      .attr("fill", "white")
      .style("opacity", 0.5);

      tooltip
      .append("text")
      .attr("x", 15)
      .attr("dy", "1.0em")
      .style("text-anchor", "middle")
      .attr("font-size", "12px")
      .attr("font-weight", "bold");
      }

      render() {
      return (
      <div id="dashboard_bar_graph_101" style={{ textAlign: "center" }} />
      );
      }
      }

      render(<App />, document.getElementById('root'));









      share|improve this question
















      I'm facing an issue in my react.js web app. I am using import * as d3 from 'd3' to import everything and save it to d3 namespace but getting an error called - Cannot read property 'stack' of undefined. Any help regarding the issue ?



      Click here to see the => Demo



      I tried installing d3-shape and using import * as stack from 'd3-shape' and import stack from 'd3-shape' - both the things and getting the same problem again.



      Here's my code:



      import React, { Component } from "react";
      import * as d3 from "d3";
      // import d3 from "d3-shape";
      // import d3 from "d3";
      // import * as stack from 'd3-shape';
      import "d3-tip";
      import { render } from 'react-dom';
      import barData from "./JSON/barData.jsx";

      class App extends Component {
      componentDidMount() {
      console.log("componentDidMount", this.props.id);
      console.log(barData);
      var margin = { top: 20, right: 160, bottom: 35, left: 0 };

      var width = 500 - margin.left - margin.right,
      height = 162 - margin.top - margin.bottom;

      var svg = d3
      .select("#dashboard_bar_graph_101")
      .append("svg")
      .attr("width", width)
      .attr("height", height + margin.top + margin.bottom)
      .append("g")
      .attr(
      "transform",
      "translate(" + margin.left + "," + margin.top + ")"
      );

      /* Data in strings like it would be if imported from a csv */

      var data = barData;

      //var parse = d3.time.format("%Y").parse;

      // Transpose the data into layers
      var dataset = d3.layout.stack()(
      ["view"].map(function(fruit) {
      return data.map(function(d) {
      return { x: d.year, y: +d[fruit] };
      });
      })
      );

      // Set x, y and colors
      var x = d3.scale
      .ordinal()
      .domain(
      dataset[0].map(function(d) {
      return d.x;
      })
      )
      .rangeRoundBands([10, width - 10], 0.02);

      var y = d3.scale
      .linear()
      .domain([
      0,
      d3.max(dataset, function(d) {
      return d3.max(d, function(d) {
      return d.y0 + d.y;
      });
      })
      ])
      .range([height, 0]);

      var colors = ["#39d9F3"];

      // Define and draw axes
      var yAxis = d3.svg
      .axis()
      .scale(y)
      .orient("left")
      .ticks(5)
      .tickSize(-width, 0, 0)
      .tickFormat(function(d) {
      return d;
      });

      var xAxis = d3.svg
      .axis()
      .scale(x)
      .orient("bottom")
      .tickFormat(data.year);

      svg
      .append("g")
      .attr("class", "y axis")
      .call(yAxis);

      svg
      .append("g")
      .attr("class", "x axis legend_texts_two")
      .attr("transform", "translate(0," + height + ")")
      .call(xAxis);

      // Create groups for each series, rects for each segment
      var groups = svg
      .selectAll("g.cost")
      .data(dataset)
      .enter()
      .append("g")
      .attr("class", "cost")
      .style("fill", function(d, i) {
      return colors[i];
      });

      var rect = groups
      .selectAll("rect")
      .data(function(d) {
      return d;
      })
      .enter()
      .append("rect")
      .attr("x", function(d) {
      return x(d.x);
      })
      .attr("y", function(d) {
      return y(d.y0 + d.y);
      })
      .attr("height", function(d) {
      return y(d.y0) - y(d.y0 + d.y);
      })
      .attr("width", "20px")
      .on("mouseover", function() {
      tooltip.style("display", null);
      })
      .on("mouseout", function() {
      tooltip.style("display", "none");
      })
      .on("mousemove", function(d) {
      var xPosition = d3.mouse(this)[0] - 15;
      var yPosition = d3.mouse(this)[1] - 25;
      tooltip.attr(
      "transform",
      "translate(" + xPosition + "," + yPosition + ")"
      );
      tooltip.select("text").text(d.y);
      })
      .style("fill", function(d, i) {
      return colors[i];
      });

      // Draw legend
      /*var legend = svg
      .selectAll(".legend")
      .data(colors)
      .enter()
      .append("g")
      .attr("class", "legend")
      .attr("transform", function(d, i) {
      return "translate(30," + i * 19 + ")";
      });

      legend
      .append("rect")
      .attr("x", width - 18)
      .attr("width", 18)
      .attr("height", 18)
      .style("fill", function(d, i) {
      return colors.slice().reverse()[i];
      });

      legend
      .append("text")
      .attr("x", width + 5)
      .attr("y", 9)
      .attr("dy", ".35em")
      .style("text-anchor", "start")
      .text(function(d, i) {
      switch (i) {
      case 0:
      return "View";
      case 0:
      return "View";
      case 2:
      return "Click";
      }
      });*/

      // Prep the tooltip bits, initial display is hidden
      var tooltip = svg
      .append("g")
      .attr("class", "tooltip")
      .style("display", "none");

      tooltip
      .append("rect")
      .attr("width", 30)
      .attr("height", 20)
      .attr("fill", "white")
      .style("opacity", 0.5);

      tooltip
      .append("text")
      .attr("x", 15)
      .attr("dy", "1.0em")
      .style("text-anchor", "middle")
      .attr("font-size", "12px")
      .attr("font-weight", "bold");
      }

      render() {
      return (
      <div id="dashboard_bar_graph_101" style={{ textAlign: "center" }} />
      );
      }
      }

      render(<App />, document.getElementById('root'));






      javascript reactjs d3.js components web-component






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 4:30







      Subhojit

















      asked Nov 21 '18 at 4:11









      SubhojitSubhojit

      1761319




      1761319
























          1 Answer
          1






          active

          oldest

          votes


















          1














          It looks like the API you are using is from d3 version 3 (current version is 5). So, I recommend uninstall d3 dependency and install d3@3. You also do not need to install modules like 'd3-shape', because they were introduced in version 5.



          Here is the working example of your code: https://stackblitz.com/edit/react-zx6yfc?file=index.js






          share|improve this answer
























          • Yes @Yaroslav you're right. My bad, I was using D3 version of 3.5.17 and it got automatically updated to 5.7.0 which i didn't notice. That's why getting this issue. Thanks for the help. I actually figured it out 3-4 hours ago, but still. Thanks a lot :)

            – Subhojit
            Nov 21 '18 at 12:19











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405149%2fd3-js-issue-in-react-js-project%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          It looks like the API you are using is from d3 version 3 (current version is 5). So, I recommend uninstall d3 dependency and install d3@3. You also do not need to install modules like 'd3-shape', because they were introduced in version 5.



          Here is the working example of your code: https://stackblitz.com/edit/react-zx6yfc?file=index.js






          share|improve this answer
























          • Yes @Yaroslav you're right. My bad, I was using D3 version of 3.5.17 and it got automatically updated to 5.7.0 which i didn't notice. That's why getting this issue. Thanks for the help. I actually figured it out 3-4 hours ago, but still. Thanks a lot :)

            – Subhojit
            Nov 21 '18 at 12:19
















          1














          It looks like the API you are using is from d3 version 3 (current version is 5). So, I recommend uninstall d3 dependency and install d3@3. You also do not need to install modules like 'd3-shape', because they were introduced in version 5.



          Here is the working example of your code: https://stackblitz.com/edit/react-zx6yfc?file=index.js






          share|improve this answer
























          • Yes @Yaroslav you're right. My bad, I was using D3 version of 3.5.17 and it got automatically updated to 5.7.0 which i didn't notice. That's why getting this issue. Thanks for the help. I actually figured it out 3-4 hours ago, but still. Thanks a lot :)

            – Subhojit
            Nov 21 '18 at 12:19














          1












          1








          1







          It looks like the API you are using is from d3 version 3 (current version is 5). So, I recommend uninstall d3 dependency and install d3@3. You also do not need to install modules like 'd3-shape', because they were introduced in version 5.



          Here is the working example of your code: https://stackblitz.com/edit/react-zx6yfc?file=index.js






          share|improve this answer













          It looks like the API you are using is from d3 version 3 (current version is 5). So, I recommend uninstall d3 dependency and install d3@3. You also do not need to install modules like 'd3-shape', because they were introduced in version 5.



          Here is the working example of your code: https://stackblitz.com/edit/react-zx6yfc?file=index.js







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 12:05









          Yaroslav SergienkoYaroslav Sergienko

          40016




          40016













          • Yes @Yaroslav you're right. My bad, I was using D3 version of 3.5.17 and it got automatically updated to 5.7.0 which i didn't notice. That's why getting this issue. Thanks for the help. I actually figured it out 3-4 hours ago, but still. Thanks a lot :)

            – Subhojit
            Nov 21 '18 at 12:19



















          • Yes @Yaroslav you're right. My bad, I was using D3 version of 3.5.17 and it got automatically updated to 5.7.0 which i didn't notice. That's why getting this issue. Thanks for the help. I actually figured it out 3-4 hours ago, but still. Thanks a lot :)

            – Subhojit
            Nov 21 '18 at 12:19

















          Yes @Yaroslav you're right. My bad, I was using D3 version of 3.5.17 and it got automatically updated to 5.7.0 which i didn't notice. That's why getting this issue. Thanks for the help. I actually figured it out 3-4 hours ago, but still. Thanks a lot :)

          – Subhojit
          Nov 21 '18 at 12:19





          Yes @Yaroslav you're right. My bad, I was using D3 version of 3.5.17 and it got automatically updated to 5.7.0 which i didn't notice. That's why getting this issue. Thanks for the help. I actually figured it out 3-4 hours ago, but still. Thanks a lot :)

          – Subhojit
          Nov 21 '18 at 12:19




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405149%2fd3-js-issue-in-react-js-project%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          鏡平學校

          ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

          Why https connections are so slow when debugging (stepping over) in Java?