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

question about data #25

Open
lilychou0912 opened this issue Mar 28, 2020 · 4 comments
Open

question about data #25

lilychou0912 opened this issue Mar 28, 2020 · 4 comments

Comments

@lilychou0912
Copy link

Can I load data via a json variable rather than loading a json file?

@Airzihao
Copy link
Collaborator

Airzihao commented Mar 29, 2020

Thanks for your trial, we offer an API fromGson(gson: Gson) which can support you to load data via a gson variable. However, in the html demo, you can't load data without a json file, string or a proper url.
By the way, Gson is short for graph json here.

@Sallylearning
Copy link

Thanks for your trial, we offer an API fromGson(gson: Gson) which can support you to load data via a gson variable. However, in the html demo, you can't load data without a json file, string or a proper url.
By the way, Gson is short for graph json here.

could you please show me an example about how to use the API fromGson(gson: Gson)。thanks a lot。

@Sallylearning
Copy link

does this means I can't use a ajax to gain a json data or use a variable which be assigned JSON data in a html demo?
like:

var test_data = {Gson data... }
app.loadGson(test_data);

@HC-teemo
Copy link
Collaborator

does this means I can't use a ajax to gain a json data or use a variable which be assigned JSON data in a html demo?
like:

var test_data = {Gson data... }
app.loadGson(test_data);

you can use fromGson(gson: Gson) like this example:

var app = new igraph.GraphNavigator(document.getElementById('graphArea'), 'LIGHT');
let gson = {
    "categories": {
        "person": "Person"
    },
    "data": {
        "nodes": [{
            "label": "Alice",
            "value": 2,
            "id": 1,
            "categories": ["person"],
            "info": ""
        },{
            "label": "Bob",
            "value": 1,
            "id": 2,
            "categories": ["person"],
            "info": ""
        }],
        "edges": [{
            "id": 1,
            "label": "friend",
            "from": 1,
            "to": 2
        }]
    }
}
app.connectService(igraph.LocalGraph.fromGson(gson));

image
app.loadGson(url_or_gson: string | gson) is a good idea, we will consider adding it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants