Vega: Problem with embed.js

Created on 26 Jul 2017  路  5Comments  路  Source: vega/vega

I am trying to load this web page containing vega view using this server script:
screen shot 2017-07-26 at 9 14 20 pm

The testgram.html goes like:
screen shot 2017-07-26 at 9 14 09 pm

But the chrome console throws an exception:
screen shot 2017-07-26 at 9 12 21 pm

What could be the problem? is there a problem with my code or with vega-embed.js?

question

All 5 comments

It looks like non-JSON data is being passed into JSON.parse. I would check the content of testgram.json and then check if it is being loaded correctly. By passing in a string name only (no URL protocol or directory) it should be looking for that file at the same directory location as testgram.html.

Hey! Thanks for the reply. So, vega.embed() works now when passed url: https://raw.githubusercontent.com/histogrammar/histogrammar-python/vega/histogrammar/plot/vega/testgram/testgram.json

Thanks for the help.

So vega.embed() will load a vega specification from remote server only? I can't load local vega specifications?

@debuggermalhotra, no, you can load a local spec (either via URL or as object). Detailed docs are at https://github.com/vega/vega-embed.

A single file (such as blah.vg.json) should be treated as a URL without a specified protocol (default is http://) or directory (default is the same directory as the calling web page). In your case I suspect the error arose due to trying to access a file that does not exist at the default location, followed by a failure to parse the returned 404 page (hence the failure of JSON parsing on the initial < character). But that is just a guess.

In any case, vega-embed should provide better error handling for load failures, and I've opened a new issue for that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

divico picture divico  路  4Comments

david-littlefield picture david-littlefield  路  4Comments

kanitw picture kanitw  路  3Comments

nyurik picture nyurik  路  5Comments

sonlichao picture sonlichao  路  4Comments