Skip to content
Snippets Groups Projects
Commit a0ef2e62 authored by Jean-Clement Gallardo's avatar Jean-Clement Gallardo
Browse files

Add read mappings from JSONGraph

parent 0cb6ab80
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ import type { GraphStyleProperties } from "../types/GraphStyleProperties";
* @param jsonGraph JSONGraph object stringify
* @returns {Network, GraphStyleProperties} Return network object and graphStyleProperties object
*/
export function readJsonGraph(jsonGraph: string): { network: Network, networkStyle: GraphStyleProperties } {
export function readJsonGraph(jsonGraph: string): { network: Network, networkStyle: GraphStyleProperties, mappings: {[key: string]: any} } {
const jsonObject = JSON.parse(jsonGraph);
const network: Network = {
......@@ -22,6 +22,8 @@ export function readJsonGraph(jsonGraph: string): { network: Network, networkSty
nodeStyles: {}
}
let mappings = {};
if (!jsonObject.graph) {
throw new Error("graph attribute lacking in json graph format")
}
......@@ -163,7 +165,11 @@ export function readJsonGraph(jsonGraph: string): { network: Network, networkSty
}
}
return { network, networkStyle };
if (jsonObject.graph.metadata.mappings) {
mappings = jsonObject.graph.metadata.mappings;
}
console.log(mappings);
return { network, networkStyle, mappings };
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment