Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set cables variable from javascript #955

Open
VhArno opened this issue Jan 11, 2025 · 4 comments
Open

Set cables variable from javascript #955

VhArno opened this issue Jan 11, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@VhArno
Copy link

VhArno commented Jan 11, 2025

Link to simple, reproducible example patch
https://cables.gl/p/6KSE4y

Describe the bug
I am unable to set the value of a variable from outside of cables.gl. I have followed a YouTube tutorial video and tried the same stuff in the video for myself but nothing worked (see third and fourth screenshot). I am embedding my patch (see second screenshot).
My project is written in Vue.js 3.0.

Trying to set cables variable in code:
image

Cables.gl patch embedded:
image

Trying to set cables.gl variable in console:
image
image

@VhArno VhArno added bug Something isn't working new labels Jan 11, 2025
@pandrr
Copy link
Member

pandrr commented Jan 13, 2025

Screenshot 2025-01-13 at 11 28 45
  • embedding remote url from cables.gl via iframe, you cannot set vars like this

@steam0r steam0r removed the new label Jan 13, 2025
@VhArno
Copy link
Author

VhArno commented Jan 19, 2025

Is there another way to set variables from my website? The console was just an example and to show it didn't work. Could I maybe export my cables patch a different way to set the variable?

@steam0r
Copy link
Collaborator

steam0r commented Jan 20, 2025

if you export the patch as html you should be able to set all these variables:

https://cables.gl/docs/4_export_embed/dev_embed/export_zip/export_zip

@VhArno
Copy link
Author

VhArno commented Jan 20, 2025

I exported the patch as html adn put in in my Vue.js project. However I cant change the width or height. it stays the same (width: 1139px, height: 919px). Also when switching to a different page on my website the patch dissapears. There are no errors shown when switching page, only on the first load.

These are the console errors when initially loading the page:
Image

Also another error I have no idea how to fix or why it is even there. In my patch I do a request to a wikidata endpoint and display the received data. When I embed my patch as an iframe on my page that request fails because of cors only on Firefox, on Google Chrome or Edge it works perfectly. I do the same request on my website and in cables.gl. The one in cables fails with the following

error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the external resource at https://dbpedia.org/sparql?query=%0APREFIX%20dbo%3A%20%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%0A%0ASELECT%20%3Fcountry%20%3Fcapital%0AWHERE%20%7B%0A%20%20%3Fcountry%20dbo%3Acapital%20%3Fcapital%20.%0A%20%20%3Fcountry%20a%20dbo%3ACountry%20.%0A%7D%0ALIMIT%2010%0A&format=json . (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘https://linksphere.arnovanhee.ikdoeict.be’).

My website: https://linksphere.arnovanhee.ikdoeict.be/
My cables.gl patch: https://cables.gl/p/6KSE4y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants