diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-07-26 19:47:45 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-07-26 19:47:45 +0200 |
commit | c1c2c875fb3695c061e7e6ccabeb2d15e7fb3643 (patch) | |
tree | 8655982aaabe2c9f66b12024f303d30bb52f4b8f /pages | |
parent | 671afb4dc4214e7d916479d6a55e74c5c05ef618 (diff) | |
parent | b3a68e76949b8ff1e048122a487fd5326b39ec40 (diff) |
merging refactoring
Diffstat (limited to 'pages')
-rw-r--r-- | pages/index.tsx | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/pages/index.tsx b/pages/index.tsx index 3ded283..59a15f2 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -9,14 +9,11 @@ import type { import { OrgRoamGraphReponse, OrgRoamLink, OrgRoamNode } from '../api' import { GraphData, NodeObject } from 'force-graph' -import Head from 'next/head' - import { useWindowSize } from '@react-hook/window-size' import { useAnimation } from '@lilib/hooks' -import { Button, Box, IconButton, useTheme, useDisclosure, Flex } from '@chakra-ui/react' +import { Box, useTheme } from '@chakra-ui/react' -import { ChevronLeftIcon, SettingsIcon } from '@chakra-ui/icons' import { initialPhysics, initialFilter } from '../components/config' import { Tweaks } from '../components/tweaks' @@ -247,16 +244,9 @@ export const Graph = function (props: GraphProps) { }, [filter, graphData.nodes, linksByNodeId]) const filteredLinks = useMemo(() => { - return graphData.links.filter((link) => { - // we need to cover both because force-graph modifies the original data - // but if we supply the original data on each render, the graph will re-render sporadically - //const sourceId = typeof link.source === 'object' ? link.source.id! : (link.source as string) - //const targetId = typeof link.target === 'object' ? link.target.id! : (link.target as string) - let showNode = true - if (!filter.parents && link.type === 'parent') { - showNode = false - } - return link.type !== 'cite' && showNode + return graphData.links.filter((linkArg) => { + const link = linkArg as OrgRoamLink + return link.type !== 'cite' && (filter.parents || link.type !== 'parent') }) }, [filter, JSON.stringify(graphData.links)]) @@ -331,6 +321,7 @@ export const Graph = function (props: GraphProps) { fg.d3Force('y', null) threeDim ? fg.d3Force('z', null) : null } + physics.linkStrength && fg.d3Force('link').strength(physics.linkStrength) physics.linkIts && fg.d3Force('link').iterations(physics.linkIts) physics.charge && fg.d3Force('charge').strength(physics.charge) |