-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up visualization of team.json data with vis.js network
Vis.js: https://visjs.org/, https://lobid.org/gnd/116994061#rels See #427
- Loading branch information
Showing
7 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,9 @@ typings/ | |
# gatsby files | ||
.cache/ | ||
public | ||
bin | ||
target | ||
tmp | ||
|
||
# Mac files | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { Component, createRef } from "react"; | ||
import { DataSet, Network} from 'vis-network/standalone/esm/vis-network'; | ||
|
||
import "./css/lobid.css"; | ||
|
||
export class Visual extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.props = props; | ||
this.state = { | ||
infoToggled: false | ||
}; | ||
this.network = {}; | ||
this.appRef = createRef(); | ||
} | ||
|
||
componentDidMount() { | ||
console.log("Props", this.props) | ||
|
||
var ns = [ | ||
{ id: 'm', label: "Members","shape":"dot","size":"5"}, | ||
{ id: 'o', label: "Offers","shape":"dot","size":"5"} | ||
]; | ||
this.props.members.forEach((item,index) => { ns.push({ id: "m"+index, label: item.member.name, "shape":"box" }); }); | ||
this.props.products.forEach((item,index) => { ns.push({ id: "o"+index, label: item.name, "shape":"box" }); }); | ||
const nodes = new DataSet(ns); | ||
|
||
var es = []; | ||
this.props.members.forEach((item,index) => { es.push({ from: 'm', to: 'm'+index }); }); | ||
this.props.products.forEach((item,index) => { es.push({ from: 'o', to: 'o'+index }); }); | ||
const edges = new DataSet(es); | ||
|
||
const data = { | ||
nodes: nodes, | ||
edges: edges | ||
}; | ||
const options = {}; | ||
this.network = new Network(this.appRef.current, data, options); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div id="lobid-network" ref={this.appRef} /> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from "react"; | ||
import { graphql } from "gatsby"; | ||
import { Visual } from "../components/visual.html"; | ||
|
||
export default ({ data }) => ( | ||
<Visual | ||
members = {data.dataJson.member} | ||
products = {data.dataJson.makesOffer} | ||
/> | ||
); | ||
|
||
export const query = graphql` | ||
query { | ||
dataJson { | ||
makesOffer { | ||
alternateName { | ||
de | ||
} | ||
id | ||
name | ||
} | ||
member { | ||
member { | ||
id | ||
image | ||
name | ||
} | ||
roleName { | ||
de | ||
} | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters