I am not sure if this is an electron issue or a d3 issue (or maybe just user error). However, since it works with an older version of d3 but not the latest, I am routing it here. I do not know
d3 version 4.12 (d3-request 1.0.6) does not work well with electron. In particular, I cannot access local files by relative address, for example d3.csv("data.csv")
I found that, if I comment line 3 in d3-request/builds/d3-request.node.js
//var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
it uses the built-in electron XMLHttpRequest and then works.
When I run an earlier version of d3 (version 3.5.17), which does not have any d3-request module, this issue does not occur and d3.csv("data.csv") succeed
Thank you for the packages.
index.html:
`
<script>
d3 = require("d3");
d3.csv("data.csv", function(data){
console.log(data);
}, function(error, rows){
console.log(rows);
})
</script>
`
package.json (works):
{ "name": "simple", "version": "0.1.0", "main": "./main.js", "scripts": { "start": "electron .", "binary": { "module_name": "simple", "module_path": "./lib/binding/", "host": "localhost" } }, "dependencies": { "electron-prebuilt": "", "electron-debug": "", "d3": "^3.5.6" } }
package.json (fails):
{ "name": "simple", "version": "0.1.0", "main": "./main.js", "scripts": { "start": "electron .", "binary": { "module_name": "simple", "module_path": "./lib/binding/", "host": "localhost" } }, "dependencies": { "electron-prebuilt": "", "electron-debug": "", "d3": "" } }
I am not sure if this is an electron issue or a d3 issue (or maybe just user error). However, since it works with an older version of d3 but not the latest, I am routing it here. I do not know
d3 version 4.12 (d3-request 1.0.6) does not work well with electron. In particular, I cannot access local files by relative address, for example d3.csv("data.csv")
I found that, if I comment line 3 in d3-request/builds/d3-request.node.js
//var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
it uses the built-in electron XMLHttpRequest and then works.
When I run an earlier version of d3 (version 3.5.17), which does not have any d3-request module, this issue does not occur and d3.csv("data.csv") succeed
Thank you for the packages.
index.html:
<script> d3 = require("d3"); d3.csv("data.csv", function(data){ console.log(data); }, function(error, rows){ console.log(rows); }) </script> ``
package.json (works):
{ "name": "simple", "version": "0.1.0", "main": "./main.js", "scripts": { "start": "electron .", "binary": { "module_name": "simple", "module_path": "./lib/binding/", "host": "localhost" } }, "dependencies": { "electron-prebuilt": "", "electron-debug": "", "d3": "^3.5.6" } }package.json (fails):
{ "name": "simple", "version": "0.1.0", "main": "./main.js", "scripts": { "start": "electron .", "binary": { "module_name": "simple", "module_path": "./lib/binding/", "host": "localhost" } }, "dependencies": { "electron-prebuilt": "", "electron-debug": "", "d3": "" } }