From 0db3dbb47b1041fe98cfae1fe5e1ca6de4a0113b Mon Sep 17 00:00:00 2001 From: theosanderson Date: Sat, 10 Jul 2021 14:44:55 +0100 Subject: [PATCH] updates Former-commit-id: ec35c5d593f54df0da48ce0769624037575c606d --- public/cog_global_tree.newick.REMOVED.git-id | 1 + src/App.jsx | 40 +++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 public/cog_global_tree.newick.REMOVED.git-id diff --git a/public/cog_global_tree.newick.REMOVED.git-id b/public/cog_global_tree.newick.REMOVED.git-id new file mode 100644 index 00000000..d36bf178 --- /dev/null +++ b/public/cog_global_tree.newick.REMOVED.git-id @@ -0,0 +1 @@ +dfec1fcd21f6ba8420045894f854363de63746f3 \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index dff681a5..c41105cc 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -2,13 +2,13 @@ import "./App.css"; import React, { useEffect, useState, useCallback ,useMemo} from "react"; import Deck from "./Deck"; import SearchPanel from "./components/SearchPanel"; -//import axios from "axios"; +import axios from "axios"; import AboutOverlay from "./components/AboutOverlay"; import { BrowserRouter as Router } from "react-router-dom"; import { CgListTree } from "react-icons/cg"; //import {FaGithub} from "react-icons/fa"; import { BsInfoSquare } from "react-icons/bs"; -import "./helpers/tree.js" +import {kn_expand_node,kn_reorder,kn_parse,kn_calxy} from "./helpers/tree.js"; var protobuf = require("protobufjs"); protobuf.parse.defaults.keepCase = true; @@ -57,21 +57,33 @@ function App() { const [aboutEnabled, setAboutEnabled] = useState(false); - useEffect(() => { - const tree = window.kn_parse(window.newick) - - window.kn_reorder(tree,tree.root) - tree.node_order = window.kn_expand_node(tree,tree.root) - window.kn_calxy(tree,true) - window.tree=tree - +useEffect(() => { + axios.get('/cog_global_tree.newick') + .then(function (response) { + // handle success + console.log(response) + console.log("start") + const tree = kn_parse(response.data) + console.log("order") + kn_reorder(tree,tree.root) + console.log("expand") + tree.node_order = kn_expand_node(tree,tree.root) + tree.parents[tree.root]=tree.root + console.log("xy") +kn_calxy(tree,true) + console.log("done") tree.x=tree.x.map(a=>15*(a+0.1)) tree.y=tree.y.map(a=>30*(a+0.1)) - //tree.names=tree.node.map(a=>a.name) tree.ids = [...Array(tree.names.length).keys()]; - //tree.parents=tree.node.map(a=>tree.node.findIndex(x=>x===a)) - setNodeData({ status: "loaded", data: {node_data:tree} }); - }, [nodeData.status]); + setNodeData( { status: "loaded", data: {node_data:tree}}) + }) + + + },[]) + + + + const data = useMemo( ()=>nodeData.status === "loaded" ? nodeData.data