Skip to content

Graph not updating when data changes. (TreevizReact) #125

@SamiraHuber

Description

@SamiraHuber

When data changes, the graph stays the same. I updated the percentage, but it is not changing in the graph. I also updated the selectedNode to change the color. But same. Here is my example code:

<TreevizReact
    data={data}
    idKey={'id'}
    relationnalField={'father'}
    nodeWidth={200}
    mainAxisNodeSpacing={2}
    secondaryAxisNodeSpacing={1.3}
    renderNode={(node: any) =>
        `<div style="height:${node.settings.nodeHeight}px;
        display:flex;
        align-items:center;
        background-color:${props.selectedNode?.id == node.data['id'] ? '#cccccc' : '#dfe8df'};
        border-radius: 0.3em;
        padding: 1em;
        margin-left:12px"
        id=${node.data['id']}>
        Node name: ${node.data['name'].split('|')[0]}
        Percentage: ${node.data['percentage']}
        </div>`
    }
    onNodeClick={(event: any) => {
        if (event?.target?.id != null) {
            props.setSelectedNode(ingredients.find((node: any) => node?.id == event?.target?.id));
        }

    }}
    duration={500}
    linkWidth={(node: any) => (node['weight'] * 100)}
    linkShape={'quadraticBeziers'}
/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions