vis.js removing whole graph when deleting single nodeWhen to use double or single quotes in JavaScript?How to find event listeners on a DOM node when debugging or from the JavaScript code?Remove all child elements of a DOM node in JavaScriptFiltering disconnected nodes in vis.jsHow to retrieve data from api res.send?vis.js node placement when physics is disabledincrease node size vis.jsVis.js not showing graph when many nodes are addedHow to extract a title of nodes in Network graph in Vis.jsconsole logging data with ajax post method
New coworker has strange workplace requirements - how should I deal with them?
What are ways to record who took the pictures if a camera is used by multiple people?
Sum and average calculator
Squares inside a square
Can two aircraft be allowed to stay on the same runway at the same time?
Can UV radiation be safe for the skin?
Fishing from underwater domes
How could reincarnation magic be limited to prevent overuse?
What is the definition of belonging in axiomatic set theory?
Create a list of snaking numbers under 50,000
Why don't "echo -e" commands seem to produce the right output?
Is it good practice to speed up and slow down where not written in a song?
Should a TA point out a professor's mistake while attending their lecture?
Ways you can end up paying interest on a credit card if you pay the full amount back in due time
How do I get my neighbour to stop disturbing with loud music?
Where should I draw the line on follow up questions from previous employer
Colored grid with coordinates on all sides?
Quick Tilepaint Puzzles: Corridors and Corners
Can a system of three stars exist?
Is Chuck the Evil Sandwich Making Guy's head actually a sandwich?
Ideas behind the 8.Bd3 line in the 4.Ng5 Two Knights Defense
Does the telecom provider need physical access to the SIM card to clone it?
I was given someone else's visa, stamped in my passport
Four day weekend?
vis.js removing whole graph when deleting single node
When to use double or single quotes in JavaScript?How to find event listeners on a DOM node when debugging or from the JavaScript code?Remove all child elements of a DOM node in JavaScriptFiltering disconnected nodes in vis.jsHow to retrieve data from api res.send?vis.js node placement when physics is disabledincrease node size vis.jsVis.js not showing graph when many nodes are addedHow to extract a title of nodes in Network graph in Vis.jsconsole logging data with ajax post method
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to delete a node from a vis.js graph. When the function is applied, instead of the node and its outgoing edges being deleted the entire graph gets erased. I want the changes to be kept intact when the page gets refreshed. The calls related to this are deleteNode
(in index.html) and app.delete
(in index.js).
index.html:
var deleteNode = function(data, callback)
$.ajax(
method: "delete",
url: "/api/node",
data: node: data.nodes[0] ,
success: function(result)
callback(result);
)
;
index.js:
app.delete("/api/node", function(req, res)
var deleteNode = req.body.node;
var deleteResult =
nodes:[],
edges: []
;
var updatedNodes = _.filter(data.nodes, function(node)
var keep = (node.id !== deleteNode);
if(!keep)
deleteResult.nodes.push(node);
return keep;
);
var updatedEdges = _.filter(data.edges, function(edge)
var keep = (edge.from !== deleteNode) );
data.nodes = updatedNodes;
data.edges = updatedEdges;
res.send(deleteResult).end();
);
javascript jquery ajax api vis.js
add a comment |
I'm trying to delete a node from a vis.js graph. When the function is applied, instead of the node and its outgoing edges being deleted the entire graph gets erased. I want the changes to be kept intact when the page gets refreshed. The calls related to this are deleteNode
(in index.html) and app.delete
(in index.js).
index.html:
var deleteNode = function(data, callback)
$.ajax(
method: "delete",
url: "/api/node",
data: node: data.nodes[0] ,
success: function(result)
callback(result);
)
;
index.js:
app.delete("/api/node", function(req, res)
var deleteNode = req.body.node;
var deleteResult =
nodes:[],
edges: []
;
var updatedNodes = _.filter(data.nodes, function(node)
var keep = (node.id !== deleteNode);
if(!keep)
deleteResult.nodes.push(node);
return keep;
);
var updatedEdges = _.filter(data.edges, function(edge)
var keep = (edge.from !== deleteNode) );
data.nodes = updatedNodes;
data.edges = updatedEdges;
res.send(deleteResult).end();
);
javascript jquery ajax api vis.js
add a comment |
I'm trying to delete a node from a vis.js graph. When the function is applied, instead of the node and its outgoing edges being deleted the entire graph gets erased. I want the changes to be kept intact when the page gets refreshed. The calls related to this are deleteNode
(in index.html) and app.delete
(in index.js).
index.html:
var deleteNode = function(data, callback)
$.ajax(
method: "delete",
url: "/api/node",
data: node: data.nodes[0] ,
success: function(result)
callback(result);
)
;
index.js:
app.delete("/api/node", function(req, res)
var deleteNode = req.body.node;
var deleteResult =
nodes:[],
edges: []
;
var updatedNodes = _.filter(data.nodes, function(node)
var keep = (node.id !== deleteNode);
if(!keep)
deleteResult.nodes.push(node);
return keep;
);
var updatedEdges = _.filter(data.edges, function(edge)
var keep = (edge.from !== deleteNode) );
data.nodes = updatedNodes;
data.edges = updatedEdges;
res.send(deleteResult).end();
);
javascript jquery ajax api vis.js
I'm trying to delete a node from a vis.js graph. When the function is applied, instead of the node and its outgoing edges being deleted the entire graph gets erased. I want the changes to be kept intact when the page gets refreshed. The calls related to this are deleteNode
(in index.html) and app.delete
(in index.js).
index.html:
var deleteNode = function(data, callback)
$.ajax(
method: "delete",
url: "/api/node",
data: node: data.nodes[0] ,
success: function(result)
callback(result);
)
;
index.js:
app.delete("/api/node", function(req, res)
var deleteNode = req.body.node;
var deleteResult =
nodes:[],
edges: []
;
var updatedNodes = _.filter(data.nodes, function(node)
var keep = (node.id !== deleteNode);
if(!keep)
deleteResult.nodes.push(node);
return keep;
);
var updatedEdges = _.filter(data.edges, function(edge)
var keep = (edge.from !== deleteNode) );
data.nodes = updatedNodes;
data.edges = updatedEdges;
res.send(deleteResult).end();
);
javascript jquery ajax api vis.js
javascript jquery ajax api vis.js
edited Mar 28 at 2:19
ottomeister
3,4572 gold badges15 silver badges21 bronze badges
3,4572 gold badges15 silver badges21 bronze badges
asked Mar 28 at 0:10
Julian LanksteadJulian Lankstead
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388323%2fvis-js-removing-whole-graph-when-deleting-single-node%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?
add a comment |
Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?
add a comment |
Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?
Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?
answered Mar 28 at 17:34
pgoldweicpgoldweic
2421 silver badge7 bronze badges
2421 silver badge7 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388323%2fvis-js-removing-whole-graph-when-deleting-single-node%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown