When I try to load graphviz in an ES6 module, I get errors about .wasm
(index):284 GET https://anki.wip/build/graphvizlib.wasm 404
__webpack_require__.O # chunk loaded:23
(anonymous) # app.scss?8f59:1
webpackJsonpCallback # jsonp chunk loading:72
(anonymous) # app.js:1
index.js:184 Aborted(both async and sync fetching of the wasm failed)
abort # index.js:184
getBinary # index.js:184
My set up is pretty simple, although I've tried many variations of this
yarn add d3-graphviz
# installs d3-graphviz#4.1.1
Then in my js file
import { graphviz } from 'd3-graphviz';
graphviz('#test')
.fade(false)
.renderDot('digraph {a -> b}');
I have read, and re-read, the issue on github at https://github.com/magjac/d3-graphviz/issues/152, and various issues related to running it with Vue and Angular, but still can't figure it out.
I've tried loading the unpkg in my HTML file, but then my javascript module doesn't have access to graphviz.
<script src="https://unpkg.com/viz.js#1.8.0/viz.js" type="javascript/worker"></script>
<script src="https://unpkg.com/#hpcc-js/wasm#0.3.11/dist/index.min.js"></script>
<script src="https://unpkg.com/d3-graphviz#3.0.5/build/d3-graphviz.js"></script>
<script src="//d3js.org/d3.v5.min.js"></script>
Any ideas?
Basically you need to treat the wasm file like any "static asset" (like a png or jpeg). Based on where the browser is looking for the file by default, the quickest solution is to simply copy the wasm file to your public folder.
On the #hpcc-js/wasm side take a look at the "wasmFolder" documentation here: https://github.com/hpcc-systems/hpcc-js-wasm#wasmFolder as it will let you override the default location.
Related
I am trying to learn how to use socket.io and in the tutorial I am doing, they load socket.io on the front end by inserting the following script from cdnjs
script(src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.2/socket.io.min.js')
(Note: It seems that the newest is 2.2.0 and available on https://cdnjs.com/libraries/socket.io)
However, I don't see the link to this library through cdnjs on the socket.io website. If I am understanding the socket.io client-side documentation correctly, the documentation shows setting up the library by doing the following:
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io('http://localhost');
</script>
const io = require('socket.io-client');
// or with import syntax
import io from 'socket.io-client';
Basically, are these two different ways to load the library on the client side and is there a difference? It seems weird to insert the script from cdnjs when it doesn't seem to be on the socket.io website.
When running the examaple found over here: http://bl.ocks.org/micahstubbs/8e15870eb432a21f0bc4d3d527b2d14f
I get the error that world_countries.json can't be found:
Failed to load resource: the server responded with a status of 404
(Not Found) http://localhost:8000/world_countries.json
world_countries.json is used in this piece of code:
queue()
.defer(d3.json, "world_countries.json")
.defer(d3.tsv, "world_population.tsv")
.await(ready);
I figured that world_countries.json might come from topojson, this is the way I load in the existing libraries
<script src="http://d3js.org/queue.v1.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="js/graphs/d3-tip.js"></script>
<script src="js/graphs/map.js"></script>
I was really hoping someone could help me out here!
from the terminal:
curl -O https://raw.githubusercontent.com/jdamiani27/Data-Visualization-and-D3/master/lesson4/world_countries.json
this will download https://raw.githubusercontent.com/jdamiani27/Data-Visualization-and-D3/master/lesson4/world_countries.json to your current working directory.
or just visit https://raw.githubusercontent.com/jdamiani27/Data-Visualization-and-D3/master/lesson4/world_countries.json in the browser, select-all, copy, paste into your favorite text editor and save as world_countries.json, in the same directory as the other files from the d3 example that you are working with.
good luck!
I am trying to make a request using iron-ajax.
My code looks like this:
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
<iron-ajax
id="fetch"
url="myapi.com/resource"
method="GET"
content-type="application/json"
handle-as="json"
on-response="storeData"
debounce-duration="300" auto>
</iron-ajax>
I consistently get this error and have linked to the source below.
Uncaught TypeError: request.completes.then is not a function
https://github.com/PolymerElements/iron-ajax/blob/master/iron-ajax.html#L447
When I log the spawned iron-request object request.completes out to my console, I see the below object.
g
_callbacks: Object
_pendingCallbacks: Object
ctx: null
promiser: ()
__proto__ : Object
I am using the following versions, and polymer serve to run the app locally.
iron-ajax: 1.4.3
polymer: 1.7
The awful resolution to this is that I had a naming conflict. I use bloodhound.js in this project and recently switched from a manually downloaded file over to bower. The bloodhound registered on bower is NOT the library written by twitter. It is an entirely different, one-starred, zero-forked library, last updated in 2014 that happens to overwrite the Promise prototype at a global scope :(
Thanks to all for your consideration and help!
I'm playing around with the phoenix framework. I copied the chat example entirely but I'm not getting any results.
In fact when I write console.log("testing") in my app.js I notice that my console does not log anything...
I am getting the error referenced in this link:
phoenix framework - invalid argument at new Socket - windows
However that error seems to be related to Brunch not working in windows. When I brunch build, I can confirm that app.js has the console.log("testing") that I included.
Nevertheless, I don't see that console log when I visit my localhost:4000.
Why is JS not executing?
Turns out the guide is missing a key line that made it not work.
The guide has the following:
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="<%= static_path(#conn, "/js/app.js") %>"></script>
</body>
But that is missing the below line which you can put above the body tag.
<script>require("web/static/js/app")</script>
Even as Chowza already solved this question I would like to propose another, possible cleaner solution, using the autoRequire feature of Brunch.io.
The problem occurs because Brunch.io does not autoRequire the app.js under Windows correctly. Chowza worked around this issue by requiring the file manually in the html. You can omit the manual require if you alter the /brunch-config.js as follows: Change from
modules: {
autoRequire: {
"js/app.js": ["web/static/js/app"]
}
}
To
modules: {
autoRequire: {
"js/app.js": ["web/static/js/app"],
"js\\app.js": ["web/static/js/app"]
}
}
This way the app.js is autoRequired, even if you work on a Windows based system.
I would like to mention, that this solution is based on the link Chowza himself posted, so all credit goes to him for pointing to the link.
im beginning with Ajax, i have problem with including Ajax files.
Ajax code written in original page (like index.php) and placed in (head) section works fine, but when i try to place code in external file (in js folder, where is placed prototype.js file), i don't get any response, not even in Firefox Error Console.
I haven't changed Ajax code except url for calling PHP function.
edit:
calling ajax files:
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/myValidation.js"></script>
</head><body>
....
Username: <input type="text" name="uname" id='uname' />
Available?
<span id="result"></span>
Email address: <input type="text" name="email" />
...
I embaded this function call in html. Validate function is from book "PHP and Script.aculo.us Web 2.0 app interfaces"
myValidation.js
function Validate(){
var user=$('uname');
var name="uname="+user.value;
var pars=name;
new Ajax.Request(
'myValidation.php',
{
method:'post', parameters:pars, asynchronous:true, onComplete: showAvailable
}
);
}
function showAvailable(originalRequest){
var newData=originalRequest.responseText;
$('result').innerHTML=newData;
}
This example is from mentioned book
You haven't shown us your myValidation.js file, but here are the typical reasons I see when people move from inline script blocks to external files and things stop working:
They put script blocks in the external JavaScript files. You probably didn't do that, but I've seen it often enough to mention it. Your external script is pure JavaScript, so for instance it should be:
function Validate() {
// ...
}
not:
<script type='text/javascript'>
function Validate() {
// ...
}
</script>
I've seen the latter a fair bit.
They put the JavaScript file in a location that doesn't match their script tag src.
They left an opening <!-- or closing --> in the script. Important not to do that, in external JavaScript files those are syntax errors.
They're using a web server that's case sensitive and the src attribute and the file's actual name don't match.
They're using a web server sensitive to permissions and the file doesn't have the right permissions.
In the case of the last two above, it's easy to check: Just open a new tab and actually enter the URL of the JavaScript file. If you see the JavaScript, great; if not, you probably have more information.
For issues like this (and hundreds of others), there's nothing like having a decent toolset. For debugging JavaScript on browsers, there are quite a few. There's Firebug (a Firefox add-in), Chrome's and Safari's Development Tools (built into the browsers), Microsoft Visual Studio or Script Debugger for debugging with IE, etc. Firebug and Dev Tools would both tell you about broken src links, as well as any exceptions, etc.
Have you checked that those files are accessible from the HTML code? And more - have you placed you scripts in the bottom of the page - because AJAX will bind it's handlers only to existing elements?
Problem solved.
In /js/ folder i had one php file, that i put there just because of simplicity. After moving it to other location all worked. Don't know if that is rule, nut no php files in /js/ folder. Thanks T.J and Tomasz