diff --git a/collabnext/openalex/nodes.py b/collabnext/openalex/nodes.py index 4357cbe..cb6ffc0 100644 --- a/collabnext/openalex/nodes.py +++ b/collabnext/openalex/nodes.py @@ -3,19 +3,61 @@ def make_institution_nodes(institutions: list[Institution]) -> list[dict]: return [ - {"id": x["id"], "label": x["display_name"], "type": "INSTITUTION"} + { + "id": x["id"], + "name": x["display_name"], + "institution_type": x["type"], + "homepage": x["homepage_url"], + "works_count": x["works_count"], + "cited_by_count": x["cited_by_count"], + "field": None, + "description": None, + "subfield": None, + "domain": None, + "label": x["display_name"], + "type": "INSTITUTION" + } for x in institutions ] def make_author_nodes(authors: list[Author]) -> list[dict]: return [ - {"id": x["id"], "label": x["display_name"], "type": "AUTHOR"} for x in authors + { + "id": x["id"], + "name": x["display_name"], + "institution_type": None, + "homepage": None, + "works_count": x["works_count"], + "cited_by_count": x["cited_by_count"], + "field": None, + "description": None, + "subfield": None, + "domain": None, + "label": x["display_name"], + "type": "AUTHOR" + } + for x in authors ] def make_work_nodes(works: list[Work]) -> list[dict]: - return [{"id": x["id"], "label": x["title"], "type": "WORK"} for x in works] + return [ + { + "id": x["id"], + "name": None, + "institution_type": None, + "homepage": None, + "works_count": None, + "cited_by_count": None, + "field": None, + "description": None, + "subfield": None, + "domain": None, + "label": x["title"], + "type": "WORK" + } + for x in works] def make_topic_nodes(topics: list[Topic]) -> list[dict]: @@ -23,6 +65,15 @@ def make_topic_nodes(topics: list[Topic]) -> list[dict]: return [ { "id": x["id"], + "name": None, + "institution_type": None, + "homepage": None, + "works_count": None, + "cited_by_count": None, + "field": x["field"]["display_name"], + "description": x.get("description"), + "subfield": x["subfield"]["display_name"], + "domain": x["domain"]["display_name"], "label": x["field"]["display_name"], "type": "TOPIC", } diff --git a/observable/docs/data/graph.sqlite.py b/observable/docs/data/graph.sqlite.py index 4cb170e..ee325f9 100644 --- a/observable/docs/data/graph.sqlite.py +++ b/observable/docs/data/graph.sqlite.py @@ -81,7 +81,20 @@ ] # Create nodes dataframe -df_nodes = pd.DataFrame(nodes, columns=["id", "label", "type"]) +df_nodes = pd.DataFrame(nodes, columns=[ + "id", + "label", + "type", + "name", + "institution_type", + "homepage", + "works_count", + "cited_by_count", + "field", + "description", + "subfield", + "domain", + ]) # Create edges dataframe df_edges = pd.DataFrame( diff --git a/observable/docs/index.md b/observable/docs/index.md index aaa521f..4417da3 100644 --- a/observable/docs/index.md +++ b/observable/docs/index.md @@ -118,6 +118,7 @@ orb.data.setDefaultStyle({ }, }); + // Initialize nodes and edges orb.data.setup({ nodes, edges }); @@ -127,4 +128,15 @@ orb.view.render(() => { }); ``` +```js +orb.events.on('node-click', (event) => { + getData(event) +}); + + +function getData(event) { + console.log('Node clicked: ', event.node); +} +``` +