How to import and use D3-tube-map in react.js
up vote
1
down vote
favorite
I have imported tube-map from d3.js in my reactjs project. But getting the following issue for not importing it properly. The issue I'm getting is shown in below sceenshot:
Following is the code I'm using. I've installed d3-tube-map using npm. Maybe I'm lacking on properly importing the exported value of d3-tube-map. Any help about this issue?
import React, { Component } from "react";
// import d3 from "d3";
import d3 from "d3-tube-map";
import "d3-tip";
import tubeData from "./JSON/tube_data.jsx";
class TubeMap extends Component {
componentDidMount() {
var container = d3.select("#tube_map_101");
var width = 700;
var height = 400;
var map = d3
.tubeMap()
.width(width)
.height(height)
.margin({
top: 20,
right: 20,
bottom: 40,
left: 100
})
.on("click", function(name) {
console.log(name);
});
// d3.json("./stations.json", function (error, data) {
container.datum(tubeData).call(map);
var svg = container.select("svg");
zoom = d3
.zoom()
.scaleExtent([0.5, 6])
.on("zoom", zoomed);
var zoomContainer = svg.call(zoom);
var initialScale = 2;
var initialTranslate = [100, 200];
zoom.scaleTo(zoomContainer, initialScale);
zoom.translateTo(
zoomContainer,
initialTranslate[0],
initialTranslate[1]
);
function zoomed() {
svg.select("g").attr("transform", d3.event.transform.toString());
}
// });
}
render() {
return <div id="tube_map_101" />;
}
}
export default TubeMap;
javascript reactjs d3.js react-redux react-component
add a comment |
up vote
1
down vote
favorite
I have imported tube-map from d3.js in my reactjs project. But getting the following issue for not importing it properly. The issue I'm getting is shown in below sceenshot:
Following is the code I'm using. I've installed d3-tube-map using npm. Maybe I'm lacking on properly importing the exported value of d3-tube-map. Any help about this issue?
import React, { Component } from "react";
// import d3 from "d3";
import d3 from "d3-tube-map";
import "d3-tip";
import tubeData from "./JSON/tube_data.jsx";
class TubeMap extends Component {
componentDidMount() {
var container = d3.select("#tube_map_101");
var width = 700;
var height = 400;
var map = d3
.tubeMap()
.width(width)
.height(height)
.margin({
top: 20,
right: 20,
bottom: 40,
left: 100
})
.on("click", function(name) {
console.log(name);
});
// d3.json("./stations.json", function (error, data) {
container.datum(tubeData).call(map);
var svg = container.select("svg");
zoom = d3
.zoom()
.scaleExtent([0.5, 6])
.on("zoom", zoomed);
var zoomContainer = svg.call(zoom);
var initialScale = 2;
var initialTranslate = [100, 200];
zoom.scaleTo(zoomContainer, initialScale);
zoom.translateTo(
zoomContainer,
initialTranslate[0],
initialTranslate[1]
);
function zoomed() {
svg.select("g").attr("transform", d3.event.transform.toString());
}
// });
}
render() {
return <div id="tube_map_101" />;
}
}
export default TubeMap;
javascript reactjs d3.js react-redux react-component
What is the reason of deleting your question from 2018-11-16 09:33:17Z stackoverflow.com/questions/53334987/… and posting the same question 30 hours later at 2018-11-17 14:35:40Z? This is the 3rd time you post the same question
– rioV8
Nov 17 at 16:57
Because I wanted a solution and there might be a lack of noticing questions here i don't know why.
– Subhojit
Nov 17 at 17:01
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have imported tube-map from d3.js in my reactjs project. But getting the following issue for not importing it properly. The issue I'm getting is shown in below sceenshot:
Following is the code I'm using. I've installed d3-tube-map using npm. Maybe I'm lacking on properly importing the exported value of d3-tube-map. Any help about this issue?
import React, { Component } from "react";
// import d3 from "d3";
import d3 from "d3-tube-map";
import "d3-tip";
import tubeData from "./JSON/tube_data.jsx";
class TubeMap extends Component {
componentDidMount() {
var container = d3.select("#tube_map_101");
var width = 700;
var height = 400;
var map = d3
.tubeMap()
.width(width)
.height(height)
.margin({
top: 20,
right: 20,
bottom: 40,
left: 100
})
.on("click", function(name) {
console.log(name);
});
// d3.json("./stations.json", function (error, data) {
container.datum(tubeData).call(map);
var svg = container.select("svg");
zoom = d3
.zoom()
.scaleExtent([0.5, 6])
.on("zoom", zoomed);
var zoomContainer = svg.call(zoom);
var initialScale = 2;
var initialTranslate = [100, 200];
zoom.scaleTo(zoomContainer, initialScale);
zoom.translateTo(
zoomContainer,
initialTranslate[0],
initialTranslate[1]
);
function zoomed() {
svg.select("g").attr("transform", d3.event.transform.toString());
}
// });
}
render() {
return <div id="tube_map_101" />;
}
}
export default TubeMap;
javascript reactjs d3.js react-redux react-component
I have imported tube-map from d3.js in my reactjs project. But getting the following issue for not importing it properly. The issue I'm getting is shown in below sceenshot:
Following is the code I'm using. I've installed d3-tube-map using npm. Maybe I'm lacking on properly importing the exported value of d3-tube-map. Any help about this issue?
import React, { Component } from "react";
// import d3 from "d3";
import d3 from "d3-tube-map";
import "d3-tip";
import tubeData from "./JSON/tube_data.jsx";
class TubeMap extends Component {
componentDidMount() {
var container = d3.select("#tube_map_101");
var width = 700;
var height = 400;
var map = d3
.tubeMap()
.width(width)
.height(height)
.margin({
top: 20,
right: 20,
bottom: 40,
left: 100
})
.on("click", function(name) {
console.log(name);
});
// d3.json("./stations.json", function (error, data) {
container.datum(tubeData).call(map);
var svg = container.select("svg");
zoom = d3
.zoom()
.scaleExtent([0.5, 6])
.on("zoom", zoomed);
var zoomContainer = svg.call(zoom);
var initialScale = 2;
var initialTranslate = [100, 200];
zoom.scaleTo(zoomContainer, initialScale);
zoom.translateTo(
zoomContainer,
initialTranslate[0],
initialTranslate[1]
);
function zoomed() {
svg.select("g").attr("transform", d3.event.transform.toString());
}
// });
}
render() {
return <div id="tube_map_101" />;
}
}
export default TubeMap;
javascript reactjs d3.js react-redux react-component
javascript reactjs d3.js react-redux react-component
asked Nov 17 at 14:35
Subhojit
140116
140116
What is the reason of deleting your question from 2018-11-16 09:33:17Z stackoverflow.com/questions/53334987/… and posting the same question 30 hours later at 2018-11-17 14:35:40Z? This is the 3rd time you post the same question
– rioV8
Nov 17 at 16:57
Because I wanted a solution and there might be a lack of noticing questions here i don't know why.
– Subhojit
Nov 17 at 17:01
add a comment |
What is the reason of deleting your question from 2018-11-16 09:33:17Z stackoverflow.com/questions/53334987/… and posting the same question 30 hours later at 2018-11-17 14:35:40Z? This is the 3rd time you post the same question
– rioV8
Nov 17 at 16:57
Because I wanted a solution and there might be a lack of noticing questions here i don't know why.
– Subhojit
Nov 17 at 17:01
What is the reason of deleting your question from 2018-11-16 09:33:17Z stackoverflow.com/questions/53334987/… and posting the same question 30 hours later at 2018-11-17 14:35:40Z? This is the 3rd time you post the same question
– rioV8
Nov 17 at 16:57
What is the reason of deleting your question from 2018-11-16 09:33:17Z stackoverflow.com/questions/53334987/… and posting the same question 30 hours later at 2018-11-17 14:35:40Z? This is the 3rd time you post the same question
– rioV8
Nov 17 at 16:57
Because I wanted a solution and there might be a lack of noticing questions here i don't know why.
– Subhojit
Nov 17 at 17:01
Because I wanted a solution and there might be a lack of noticing questions here i don't know why.
– Subhojit
Nov 17 at 17:01
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Yes, your imports aren't quite right. If you look at the example provided on the npm page for this module, it uses both d3 and d3-tube-map.
<script src="https://d3js.org/d3.v4.js"></script>
<script src="../dist/d3-tube-map.js"></script>
Which gives a clue, but doesn't help much with how to do this using ES6 imports. Looking at the code for the module over on github, I would try this first (many lines excluded):
import tubeMap from "d3-tube-map";
...
var map = tubeMap()
What I noticed on github is that the tubeMap module already imports d3 inside it. So maybe you don't need to import d3 yourself.
If the above doesn't work, you may have to import both d3 and d3-tube-map, in which case I'm not sure how they should work together as imports. If that's the case, I would open an issue on github with the author to get an example.
Thanks a lot for your time @Todd. I have just tried the first solution which is to import only d3-tube-map and it's causing an error - d3.tubeMap is not a function and also tried the second option to import both d3 and d3-tube-map and this case is also causing an error - Uncaught TypeError: _d2.default.tubeMap is not a function.
– Subhojit
Nov 17 at 17:22
@Subhojit I'm not sure how to get the imports right, but as your next step you should open an issue at the git repo. In the meantime, if you want to post your code on jsfiddle.net and add the link to your question, I will be happy to see if I can get it working and update my answer.
– Todd Chaffee
Nov 17 at 17:55
Hi Todd, I've shared the editor url here - stackblitz.com/edit/react-9sfz89
– Subhojit
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Yes, your imports aren't quite right. If you look at the example provided on the npm page for this module, it uses both d3 and d3-tube-map.
<script src="https://d3js.org/d3.v4.js"></script>
<script src="../dist/d3-tube-map.js"></script>
Which gives a clue, but doesn't help much with how to do this using ES6 imports. Looking at the code for the module over on github, I would try this first (many lines excluded):
import tubeMap from "d3-tube-map";
...
var map = tubeMap()
What I noticed on github is that the tubeMap module already imports d3 inside it. So maybe you don't need to import d3 yourself.
If the above doesn't work, you may have to import both d3 and d3-tube-map, in which case I'm not sure how they should work together as imports. If that's the case, I would open an issue on github with the author to get an example.
Thanks a lot for your time @Todd. I have just tried the first solution which is to import only d3-tube-map and it's causing an error - d3.tubeMap is not a function and also tried the second option to import both d3 and d3-tube-map and this case is also causing an error - Uncaught TypeError: _d2.default.tubeMap is not a function.
– Subhojit
Nov 17 at 17:22
@Subhojit I'm not sure how to get the imports right, but as your next step you should open an issue at the git repo. In the meantime, if you want to post your code on jsfiddle.net and add the link to your question, I will be happy to see if I can get it working and update my answer.
– Todd Chaffee
Nov 17 at 17:55
Hi Todd, I've shared the editor url here - stackblitz.com/edit/react-9sfz89
– Subhojit
2 days ago
add a comment |
up vote
0
down vote
Yes, your imports aren't quite right. If you look at the example provided on the npm page for this module, it uses both d3 and d3-tube-map.
<script src="https://d3js.org/d3.v4.js"></script>
<script src="../dist/d3-tube-map.js"></script>
Which gives a clue, but doesn't help much with how to do this using ES6 imports. Looking at the code for the module over on github, I would try this first (many lines excluded):
import tubeMap from "d3-tube-map";
...
var map = tubeMap()
What I noticed on github is that the tubeMap module already imports d3 inside it. So maybe you don't need to import d3 yourself.
If the above doesn't work, you may have to import both d3 and d3-tube-map, in which case I'm not sure how they should work together as imports. If that's the case, I would open an issue on github with the author to get an example.
Thanks a lot for your time @Todd. I have just tried the first solution which is to import only d3-tube-map and it's causing an error - d3.tubeMap is not a function and also tried the second option to import both d3 and d3-tube-map and this case is also causing an error - Uncaught TypeError: _d2.default.tubeMap is not a function.
– Subhojit
Nov 17 at 17:22
@Subhojit I'm not sure how to get the imports right, but as your next step you should open an issue at the git repo. In the meantime, if you want to post your code on jsfiddle.net and add the link to your question, I will be happy to see if I can get it working and update my answer.
– Todd Chaffee
Nov 17 at 17:55
Hi Todd, I've shared the editor url here - stackblitz.com/edit/react-9sfz89
– Subhojit
2 days ago
add a comment |
up vote
0
down vote
up vote
0
down vote
Yes, your imports aren't quite right. If you look at the example provided on the npm page for this module, it uses both d3 and d3-tube-map.
<script src="https://d3js.org/d3.v4.js"></script>
<script src="../dist/d3-tube-map.js"></script>
Which gives a clue, but doesn't help much with how to do this using ES6 imports. Looking at the code for the module over on github, I would try this first (many lines excluded):
import tubeMap from "d3-tube-map";
...
var map = tubeMap()
What I noticed on github is that the tubeMap module already imports d3 inside it. So maybe you don't need to import d3 yourself.
If the above doesn't work, you may have to import both d3 and d3-tube-map, in which case I'm not sure how they should work together as imports. If that's the case, I would open an issue on github with the author to get an example.
Yes, your imports aren't quite right. If you look at the example provided on the npm page for this module, it uses both d3 and d3-tube-map.
<script src="https://d3js.org/d3.v4.js"></script>
<script src="../dist/d3-tube-map.js"></script>
Which gives a clue, but doesn't help much with how to do this using ES6 imports. Looking at the code for the module over on github, I would try this first (many lines excluded):
import tubeMap from "d3-tube-map";
...
var map = tubeMap()
What I noticed on github is that the tubeMap module already imports d3 inside it. So maybe you don't need to import d3 yourself.
If the above doesn't work, you may have to import both d3 and d3-tube-map, in which case I'm not sure how they should work together as imports. If that's the case, I would open an issue on github with the author to get an example.
answered Nov 17 at 16:10
Todd Chaffee
3,3361828
3,3361828
Thanks a lot for your time @Todd. I have just tried the first solution which is to import only d3-tube-map and it's causing an error - d3.tubeMap is not a function and also tried the second option to import both d3 and d3-tube-map and this case is also causing an error - Uncaught TypeError: _d2.default.tubeMap is not a function.
– Subhojit
Nov 17 at 17:22
@Subhojit I'm not sure how to get the imports right, but as your next step you should open an issue at the git repo. In the meantime, if you want to post your code on jsfiddle.net and add the link to your question, I will be happy to see if I can get it working and update my answer.
– Todd Chaffee
Nov 17 at 17:55
Hi Todd, I've shared the editor url here - stackblitz.com/edit/react-9sfz89
– Subhojit
2 days ago
add a comment |
Thanks a lot for your time @Todd. I have just tried the first solution which is to import only d3-tube-map and it's causing an error - d3.tubeMap is not a function and also tried the second option to import both d3 and d3-tube-map and this case is also causing an error - Uncaught TypeError: _d2.default.tubeMap is not a function.
– Subhojit
Nov 17 at 17:22
@Subhojit I'm not sure how to get the imports right, but as your next step you should open an issue at the git repo. In the meantime, if you want to post your code on jsfiddle.net and add the link to your question, I will be happy to see if I can get it working and update my answer.
– Todd Chaffee
Nov 17 at 17:55
Hi Todd, I've shared the editor url here - stackblitz.com/edit/react-9sfz89
– Subhojit
2 days ago
Thanks a lot for your time @Todd. I have just tried the first solution which is to import only d3-tube-map and it's causing an error - d3.tubeMap is not a function and also tried the second option to import both d3 and d3-tube-map and this case is also causing an error - Uncaught TypeError: _d2.default.tubeMap is not a function.
– Subhojit
Nov 17 at 17:22
Thanks a lot for your time @Todd. I have just tried the first solution which is to import only d3-tube-map and it's causing an error - d3.tubeMap is not a function and also tried the second option to import both d3 and d3-tube-map and this case is also causing an error - Uncaught TypeError: _d2.default.tubeMap is not a function.
– Subhojit
Nov 17 at 17:22
@Subhojit I'm not sure how to get the imports right, but as your next step you should open an issue at the git repo. In the meantime, if you want to post your code on jsfiddle.net and add the link to your question, I will be happy to see if I can get it working and update my answer.
– Todd Chaffee
Nov 17 at 17:55
@Subhojit I'm not sure how to get the imports right, but as your next step you should open an issue at the git repo. In the meantime, if you want to post your code on jsfiddle.net and add the link to your question, I will be happy to see if I can get it working and update my answer.
– Todd Chaffee
Nov 17 at 17:55
Hi Todd, I've shared the editor url here - stackblitz.com/edit/react-9sfz89
– Subhojit
2 days ago
Hi Todd, I've shared the editor url here - stackblitz.com/edit/react-9sfz89
– Subhojit
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53352210%2fhow-to-import-and-use-d3-tube-map-in-react-js%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
What is the reason of deleting your question from 2018-11-16 09:33:17Z stackoverflow.com/questions/53334987/… and posting the same question 30 hours later at 2018-11-17 14:35:40Z? This is the 3rd time you post the same question
– rioV8
Nov 17 at 16:57
Because I wanted a solution and there might be a lack of noticing questions here i don't know why.
– Subhojit
Nov 17 at 17:01