react-family-tree icon indicating copy to clipboard operation
react-family-tree copied to clipboard

is it possible to change the connector of the tree from left to right(Horizontal)

Open iceboy07 opened this issue 2 years ago • 4 comments

Im trying to translate the node horizontally. so i modified the below code " transform: translate(${node.left * (WIDTH / 2)}px, ${ node.top * (HEIGHT / 2) }px)"

              as

"transform:translate(${node.top * (WIDTH / 2)}px, ${ node.left * (HEIGHT / 2) }px)`"

       the node is changed. But the connector/link isnt changing/ transforming. is there any way?

iceboy07 avatar Nov 20 '23 18:11 iceboy07

You can find connector's styles here https://github.com/SanichKotikov/react-family-tree/blob/master/src/connector.tsx#L20 So, if you want to change it, you have to use relatives-tree directly.

SanichKotikov avatar Nov 21 '23 20:11 SanichKotikov

@iceboy07 if you wanna change direction of "tree", you may wrap return result from relatives-tree and correct values.

SanichKotikov avatar Nov 22 '23 08:11 SanichKotikov

can you specify which file as im new to Typescript. its bit confusing

and is it these lines i need to make changes.. "export const rightOf = (family: Family): number => family.X + widthOf(family); export const bottomOf = (family: Family) => family.Y + heightOf(family);"

iceboy07 avatar Nov 23 '23 16:11 iceboy07

import calcTree from 'relatives-tree';

function changeCoordinates(treeData) {
  // Here you can change the coordinates as you wish and return updated tree data
}

const treeData = calcTree(nodes, { rootId });
const data = changeCoordinates(treeData);

SanichKotikov avatar Nov 24 '23 15:11 SanichKotikov