Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating single node #361

Open
l99057j opened this issue Feb 24, 2024 · 1 comment
Open

Updating single node #361

l99057j opened this issue Feb 24, 2024 · 1 comment

Comments

@l99057j
Copy link

l99057j commented Feb 24, 2024

I'm using the library to display a hierarchical workflow with the status of each task being updated in real time. After the initial display of the chart, a SignalR connection is established. When a task's status changes, a message is received and the underlying chart data is updated...

let task = chart.data().find(x => x.id.toLowerCase() === status.taskId.toLowerCase());
if (task) {
task.status = status.taskStatus;
task.startTime = status.startTime;
task.finishTime = status.finishTime;
}

... and I then refresh the node like so...

function refreshNode(id) {
let node = chart.getChartState().allNodes.find(x => x.id == id);
if (node) {
chart.update(node);
}
}

Console statements in my nodeContent function show that even though I'm passing a node to chart.update ALL nodes are being re-rendered. Is there a way to force an update on a single node to avoid unnecessary processing?

@bumbeishvili
Copy link
Owner

bumbeishvili commented Feb 25, 2024

Since it's an HTML, you can just get the dom element of that specific node via pre set id or class using js and update it like that

Or probably a better way would be

function refreshNode(id) {
        let attrs = chart.getChartState()

      attrs.svg
            .selectAll(".node-foreign-object-div")
             .filter(x => x.id == id);
            .html(function (d, i, arr) {
                return attrs.nodeContent.bind(this)(d, i, arr, attrs)
            })

  }
}

  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants